public Tuple <int, int, Move> ChooseNextMove(List <String> currentMoves, Move player) { Node place = root; foreach (string move in currentMoves) { place = place.ChildExists(move); } return(place.OptimumMove(player)); }
Node AddMove(string move, int row, int col) { var node = current.ChildExists(move); if (node != null) { current = node; } else { node = current.AddChild(move, row, col); current = node; } return(node); }
void UpdateTreeWithGame(List <String> gameMoves, Board.Player winner) { //Bt Default X is the first move in all games //if the winner was X then first move and every other move is a winning move //otherwise first move and all alternate subsequent moves are losing moves //if game was a tie update nothing bool XWinner = winner == Board.Player.X; current = root; foreach (string move in gameMoves) { current = current.ChildExists(move); if (XWinner) { current.RegisterWinningMove() ; } else { current.RegisterLosingMove(); } XWinner = !XWinner; } }