public Board(Board cpyBoard) { _players = new[] { new Player(cpyBoard.Players[0].Kind) { CurrentToken = cpyBoard._players[0].CurrentToken}, new Player(cpyBoard.Players[1].Kind) { CurrentToken = cpyBoard._players[1].CurrentToken}, }; int idx = -1; foreach(var field in cpyBoard.FieldBoard) { idx++; if (field == null) continue; if (field.Type == typeof(Move)) _board[idx] = new Move(idx); else { var token = field as Token; var newToken = new Token(token.Color); newToken.IsFlipped = token.IsFlipped; _board[idx] = newToken; } } CurrentTurn = _players.First(pl => pl.Color == cpyBoard.CurrentTurn.Color); }
public void InitGame(int[] playerKinds) { _board = new Board(new[] { new Player((PlayerKind)playerKinds[0]), new Player((PlayerKind)playerKinds[1]) }); }
public static int GetBestMove(Board board, int depth) { Depth = depth; Board = new Board(board); switch(Board.CurrentTurn.Kind) { case PlayerKind.AIRandom: return FindRandom(); case PlayerKind.AICurbs: return FindCurbs(); default: throw new NotImplementedException(); } return -1; }
public List<Node> Children(bool Player) { List<Node> children = new List<Node>(); var randomMoveIdx = Helpers.GenerateRandom(24, 0, 23); var moves = _board.Moves; foreach(var moveIdx in randomMoveIdx) { var childBoard = new Board(_board); if (childBoard.Move(moves[moveIdx])) { var saveMoveID = moves[moveIdx].ID; children.Add(new Node(childBoard) { MoveID = moves[moveIdx].ID }); } } return children; }
public Node(Board board) { _board = board; }