
-----------------------------------
rcad
Fri Jul 11, 2008 12:56 pm

Looking for help with my PHP Connect Four game.
-----------------------------------
Hello everyone,
I'm working on a PHP Connect Four game.  I've managed to do some of the basics, but when it comes to the AI, I'm completely lost.  I'm wondering if there is an efficient way to rank each of the 7 potential moves (each column) in an effective way (for example, winning the game = highest, blocking opponent's 3 in a row = second highest, moving into a space that allows the opponent to win = lowest, etc).  Does anybody know of a good way to detect this sort of thing?  The game board is stored in a string with 42 numbers separated by commas so that it may easily be stored in a MySQL database.  I've already written a few functions, enough to play out the first few moves.  I don't have a win detection function yet, so I need to write one of those.  (I think splitting the board into all the possible 4x columns, rows, and diagonals would work, and then scanning for $value . $value . $value . $value in that string could work, with $value being the color (1 being user, 2 being computer).

