public void DropTest() { { Board target = new Board(); // TODO: Initialize to an appropriate value target.board = new char[,] { { 'a', 'a', '.' }, { 'a', 'a', '.' }, { '.', '.', '.' }, { 'a', '.', '.' } }; int col = 0; // TODO: Initialize to an appropriate value char side = 'a'; // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; actual = target.Drop(col, side); Assert.AreEqual(expected, actual); //Assert.Inconclusive("Verify the correctness of this test method."); } { Board target = new Board(); // TODO: Initialize to an appropriate value target.board = new char[,] { { 'a', 'a', '.' }, { 'a', 'a', '.' }, { '.', '.', '.' }, { 'a', 'a', 'a' } }; int col = 0; // TODO: Initialize to an appropriate value char side = 'a'; // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; actual = target.Drop(col, side); Assert.AreEqual(expected, actual); //Assert.Inconclusive("Verify the correctness of this test method."); } { Board target = new Board(); // TODO: Initialize to an appropriate value target.board = new char[,] { { 'a', 'a', '.' }, { 'a', 'a', '.' }, { '.', '.', '.' }, { 'a', '.', '.' } }; int col = 1; // TODO: Initialize to an appropriate value char side = 'a'; // TODO: Initialize to an appropriate value bool expected = true; // TODO: Initialize to an appropriate value bool actual; actual = target.Drop(col, side); Assert.AreEqual(expected, actual); Assert.AreEqual('a', target.board[2, 1]); //Assert.Inconclusive("Verify the correctness of this test method."); } }
private static void MakeAMove(char side, Board gameBoard) { int col = MakeAMoveHelper(side, side, gameBoard); //while (gameBoard.IsFull(col)) //{ // ++col; //} gameBoard.Drop(col, side); Console.WriteLine("{0} made a move at {1}. Current board size is {2}.", side, col, gameBoard.cnt); //System.Diagnostics.Debug.WriteLine(gameBoard.ToString()); }
private static int MakeAMoveHelper(char side, char playAs, Board gameBoard) { int score = gameBoard.Score(side, false); if (score != 0) { return score; } if (gameBoard.IsFull()) { return 0; } List<int> scores = new List<int>(3); for (int i = 0; i < 3; ++i) { scores.Add(Board.Lose); } for (int i = 0; i < 3; ++i) { if (!gameBoard.IsFull(i)) { gameBoard.Drop(i, side); scores[i] = (-(MakeAMoveHelper(side, side == Side1 ? Side2 : Side1, gameBoard))); gameBoard.Pop(i); } } return scores.IndexOf(scores.Max()); }