söndag 26 december 2010

TRON B - A simplified game of Tron using MINIMAX

I have coded a Tron game clone to further see what the MINIMAX strategy can do. For those who are not familiar with the rules and game mechanics of Tron will here follow a short explanation. Tron is a two-player game where each player controls a square inside a grid. When a player moves her square in a direction (up, down, left or right) the square will move to that location and leave a solid "wall" behind. Do not crash into "walls" or your opponent. If you do, you have lost the game.
The goal is to outlive your opponent.
For the AI of the computer I've implemented a MINIMAX strategy. This time around I'm not going trough the whole game tree (to time consuming for large grids), instead I've limited the search depth. The challenge here is to write a good utility function that evaluate the current game-state "correct". So far i have equipped my utility function to consider the amount of free space and a "trapability" factor when evaluating game-states. It is not the killer I want it to be yet but with a few more "tools" added to the utility function...

The start screen.



A game in action.
Game over!


fredag 3 december 2010

Tic-Tac-Toe using the MINIMAX strategy

I made a Tic-Tac-Toe game to see the minimax strategy in action and it works quite well, the AI still hasn't lost a game yet. There are fewer than 9! (362 880) games states in Tic-Tac-Toe so I can search trough the whole game tree for the optimal move. The utility function check for either a win, a loss, a draw or if the outcome of the game can't be decided yet and return a value accordingly.
I rank win > uncertain > draw > loss.

Tic-Tac-Toe