public void ComputerMove() { Node next = _node.FindNextMove(_depth); if(next != null) { next._human = true; _node = next; _node._score = _node.Utility(); } _moves++; }
public void Start() { _moves = 0; int[][] state = new int[6][]; for (int i = 0; i < state.Length; i++) { state[i] = new int[7]; for (int j = 0; j < state[i].Length; j++) { state[i][j] = 0; } } _node = new Node(state, true); }
public int Minimax(out Node node, int alpha, int beta, int depth, bool needMax) { node = null; System.Diagnostics.Debug.Assert(_human == needMax); if (depth == 0 || _terminal) { RecursiveScore = _score; return _score; } foreach (Node child in getChildren()) { Node chil = null; int score = child.Minimax(out chil, alpha, beta, depth-1, !needMax); if (!needMax) { if (beta > score) { beta = score; node = child; if (alpha >= beta) { break; } } } else { if (alpha < score) { alpha = score; node = child; if (alpha >= beta) { break; } } } } RecursiveScore = needMax ? alpha : beta; return RecursiveScore; }