RE:TIB:Tick Tack Toe


[Prev][Next][Index][Thread]

RE:TIB:Tick Tack Toe





Chris Roddy wrote:

> Speaking of game playing programs, how does your TTT program work?  I
> just finished a program that plays Kalaha (like Awari, yeah, that game
> with the beans) and it uses a heuristic techinique rather than solving
> out all of the moves.  Just curious how you set up the move generator.

this may be stupid, but what does heuristic mean? :)

I am sure that there is a much faster way, but here is how i made the calc
choose its moves: (calc is x, player is o)
repeat the procedure until an empty square is found:
start out very simple, random, then find better moves:
player moves first

computer move:
choose random square
if center is taken, choose corner, else choose center
if x is in center and o's are on two edges (not corners), then choose the
corner between the two o's
if o is in center, and o and x are on opposing corners, choose a corner
if x is in center, and o's are on opposing corners, choose an edge
if there are two o's in a row, block them
if there are two x's in a row, put in 3rd for three in a row

if you use this strategy for tic tac toe, no one can beat you EVER!  try
it! :)
i used a 3x3 matrix as the ttt squares.  an x has a value of 5, and an o
has a value of  1.
so if the total of a row,column, or diagonal is 3, then o's win. if total
of a row,column, or diagonal is 15, then x's win.  if total of all squares
is 25, then the game is a draw.
a way that i speeded it up is i made it skip the logic needed for previous
or future moves: for example, on the first move, it only needs to know to
go in a corner or the center, not to block 3 in a row.  so it only looks
at that code and skips the rest.  on the second move, it skips the code
for the first move. in order to have different difficulties, i am going to
make it skip certain logic if the difficulty level is set lower.  for
example, on difficulty 4, it could be impossible to beat (current game).
on 3, it could not try to finish 3 in a row, on 2, it could not block your
3 in a row, on 1, it could be totally random.

sorry if this letter was too long.

-brian e. ash
 brian@communityonline.net

let me know if you want a copy of the current version, with or without
docs (docs need to be removed for speed before putting on calc)









References: