Build A Simple AI Player
Table of Contents
I received e-mails from Tick5 users who are interested in building AI players but need some helps. I wrote this tutorial in the hope that it will help you building an AI player using Tick5's AI Programming Interface.
In this tutorial, we (you and I) will walk the way step by step towards an AI player which can really play the game, not just goofing around. I assume that you know the game rules and have some programming experience. Please refer to Lua 5.0 Reference Manual and Programming In Lua for Lua syntax and other language features, and Tick5 User's Manual for Tick5's AI Programming interface.
Recall the way we (human players) play the game: we try to make moves that lead to winning patterns; if we see a move that forms a 5-in-a-row, we won't hesitate to make the move and win; if opponent's move forms any threats, we immediately response to block the threats. The following is a simple algorithm we'll use to build an AI player. It's intuitive, because it somewhat reflects the way we play the game.
By the end of the tutorial, the example script will contain reusable code. If you like to get your hands dirty, the script will serve you as a good starting point, from which you can build more sophisticated AI players. All scripts in this tutorial are released under the terms of the MIT license, which means that you don't have to distribute source code if you want to use any code of this tutorial.
Although Lua is not a object-oriented language, it does provide facilities to support object-oriented programming(OOP.) The example scripts in this tutorial will use OOP style.
If you find any issues that are not clearly addressed, or if you have any comments or suggestions, please don't hesitate to let me know. Thanks.
All companion Lua scripts can be downloaded here. You need Tick5 v1.0 to run them.
Copyright © 2007 XMartin Yao
This document is released under the terms of the GNU Free Documentation License.
Last update on May 20, 2007