I'm trying to implement a MiniMax algorithm with alpha/beta pruning. Totally stuck and can't see where I'm wrong. The class MiniMax contains a State and an Action. The method getAction returns an Action (supposedly the best action to take). The Game object has two methods, isTerminal returns true if the state is an "end state", ie there are no more children to that state. getUtility returns the value associated with an end state. I'm trying to decide wheter it is Max or Min turn by using the counter round. Currently the algorithm doesn't return the correct action, and at this …

Member Avatar
+0 forum 0

Hello guys, I (attempted to) incorporate the alpha-beta pruning functionality with Negamax in C# and was wondering if you could review my included code for any obvious errors? Negamax Function: public int NegaMax(int[,] board, int depth, int alpha, int beta) { Interlocked.Increment(ref _negaMaxCtr); if (depth == 0) { Interlocked.Increment(ref _zeroCtr); return EvaluateBoard(board); } int[,] legalMoves = GetLegalMoves(board); var possMoveList = new List<int[]>(); int bestScore = -Int32.MaxValue; for (int r = 0; r < 8; r++) for (int c = 0; c < 8; c++) if (legalMoves[r, c] == 1) possMoveList.Add(new [] { r, c }); int n = possMoveList.Count; if …

Member Avatar
+0 forum 0

The End.