public void CreateGameCode() { var board = new Board(); var engine = new RandomEngine(); for (var i = 0; i < 50; i++) { try { board.MovePiece(engine.GenerateMove(board)); } catch (InvalidMoveException) { break; } } this.TestContext.WriteLine("Board board = new Board();"); foreach (var move in board.MoveHistory) { this.TestContext.WriteLine(string.Format(CultureInfo.CurrentCulture, "board.MovePiece(new Coordinate({0}, {1}, {2}), new Coordinate({3}, {4}, {5}));", move.Source.X, move.Source.Y, move.Source.Z, move.Destination.X, move.Destination.Y, move.Destination.Z)); } }
public void GenerateMoveForComplexGame() { var board = EngineTests.GenerateComplexGame(); var engine = new RandomEngine(); var generatedMove = engine.GenerateMove(board.Clone()); this.TestContext.WriteLine(generatedMove.ToString()); this.TestContext.WriteLine("Evaluations: " + engine.Evaluations.ToString(CultureInfo.CurrentCulture)); this.TestContext.WriteLine("Visitations: " + engine.Visitations.ToString(CultureInfo.CurrentCulture)); board.MovePiece(generatedMove); }
public static void UseGoodEngine() { var goodEngine = new RandomEngine(); var board = new Board(); Assert.AreEqual(Player.X, board.CurrentPlayer, "The starting player is invalid."); board.MovePiece(new Point(0, 0), new Point(0, 4)); Assert.AreEqual(Player.O, board.CurrentPlayer, "The player before the generated move is invalid."); var engineMove = goodEngine.GenerateMove(board, new ManualResetEvent(false)); Assert.AreEqual(Player.O, engineMove.Player, "The player after the generated move is invalid."); board.MovePiece(engineMove.Source, engineMove.Destination); Assert.AreEqual(Player.X, board.CurrentPlayer, "The player after the generated move was performed is invalid."); }