Minimax for Tic Tac Toe

Started by
20 comments, last by Jeremy Stover 11 years, 10 months ago

i dont see the error in your code here yet. What happens to the value of nValidMoves.Count in the endless loop? Does it decrease and increase? Or does it stay the same? Also, what does the SetSquare function do exactly. Do you have the code for that?


The set Square function only sets the square in the copy of the current game board. And to be honest, it seems like nValid moves is working fine. Towards the start of the game, the count is 6, and after I let it run for a little while, the count is at 2, never at zero as far as I can see though. I do know that I never reach past the' int nscore = Min(allNodes[0,0]);'

BTW, setSquare is now setNewMove, It takes the board that we are testing, the position to place a chip, and either player, or an empty space to play there. You see at the bottom of the Min() and Max() function, I get rid of all the new spaces tested. I think at least. That what I intended.

the code for setNewMove() is...

[source lang="csharp"] /// <summary>
/// Sets the new move into the boardArray
/// </summary>
/// <param name="newMove"> vector2 position in the board array to set the new move</param>
public void setNewMove(Vector2 newMove, int player)
{
boardArray[(int)newMove.X,(int) newMove.Y] = player;

}[/source]


and that is part of my board class, which just holds the actual version of the board, and the one that is being cycled through.

:Thanks for your help btw, I really appreciate it.:
Advertisement
:edit, accidentaly posted twice. Sorry

This topic is closed to new replies.

Advertisement