Tuesday, June 18, 2013

minimax connect-four player

Just quickly modified my minimax tic-tac-toe into minimax connect-four. Had the following bug which took a while to track down

#define COORD(x,y) (x+COLS*y)

// then using COORD(x,y+1) is an error
// the fix is

#define COORD(x,y) ((x)+COLS*(y))

since C macros act textually rather than syntactically.

I had to put a depth limiter on the minimax code since it's trying to solve the game perfectly before playing a single move - but with the alpha-beta optimization (which is what I'll do next) it should play the same moves as a perfect player in a short enough time to be feasible.

No comments:

Post a Comment