public void TestExtractDiagU() { TicTacToe t = new TicTacToe("XOX\nOXO\nXXO"); // XOX // OXO // XXO int[] tr1 = { 1, 1, 1 }; CollectionAssert.AreEqual(tr1, t.extract_diagonal_up(6)); CollectionAssert.AreEqual(tr1, t.extract_diagonal_up(4)); CollectionAssert.AreEqual(tr1, t.extract_diagonal_up(2)); int[] tr2 = { 1, 2 }; int[] ta2 = t.extract_diagonal_up(7); // 1, 2 CollectionAssert.AreEqual(tr2, ta2); CollectionAssert.AreEqual(tr2, t.extract_diagonal_up(5)); int[] tr3 = { 2, 2 }; CollectionAssert.AreEqual(tr3, t.extract_diagonal_up(3)); CollectionAssert.AreEqual(tr3, t.extract_diagonal_up(1)); TicTacToe t2 = new TicTacToe( "XOXO\n" + "OXOX\n" + "XXOO\n" + "OOXX\n" + "XOOX"); int[] t2r1 = { 2, 1, 2, 2 }; CollectionAssert.AreEqual(t2r1, t2.extract_diagonal_up(9)); int[] t2r2 = { 2, 1 }; CollectionAssert.AreEqual(t2r2, t2.extract_diagonal_up(18)); int[] t2r3 = { 1, 1, 1 }; CollectionAssert.AreEqual(t2r3, t2.extract_diagonal_up(8)); TicTacToe t3 = new TicTacToe( "XOXOXO\n" + "OXOXOX\n" + "XXOOXO\n"); int[] t3r1 = { 2, 1, 1 }; CollectionAssert.AreEqual(t3r1, t3.extract_diagonal_up(9)); // 4, 1 int[] t3r2 = { 1 }; CollectionAssert.AreEqual(t3r2, t3.extract_diagonal_up(0)); int[] t3r3 = { 1, 1 }; CollectionAssert.AreEqual(t3r3, t3.extract_diagonal_up(16)); // 5, 2 }
public void TestExtractDiagD() { TicTacToe t = new TicTacToe("XOX\nOXO\nXXO"); // XOX // OXO // XXO int[] tr1 = { 1, 1, 2 }; CollectionAssert.AreEqual(tr1, t.extract_diagonal_down(0)); CollectionAssert.AreEqual(tr1, t.extract_diagonal_down(4)); CollectionAssert.AreEqual(tr1, t.extract_diagonal_down(8)); int[] tr2 = { 2, 2 }; int[] ta2 = t.extract_diagonal_down(1); CollectionAssert.AreEqual(tr2, ta2); CollectionAssert.AreEqual(tr2, t.extract_diagonal_down(5)); int[] tr3 = { 2, 1 }; CollectionAssert.AreEqual(tr3, t.extract_diagonal_down(3)); CollectionAssert.AreEqual(tr3, t.extract_diagonal_down(7)); TicTacToe t2 = new TicTacToe( "XOXO\n" + "OXOX\n" + "XXOO\n" + "OOXX\n" + "XOOX"); int[] t2r1 = { 2, 1, 1, 1 }; CollectionAssert.AreEqual(t2r1, t2.extract_diagonal_down(9)); int[] t2r2 = { 2, 2 }; CollectionAssert.AreEqual(t2r2, t2.extract_diagonal_down(12)); int[] t2r3 = { 2, 2, 2 }; CollectionAssert.AreEqual(t2r3, t2.extract_diagonal_down(1)); TicTacToe t3 = new TicTacToe( "XOXOXO\n" + "OXOXOX\n" + "XXOOXO\n"); int[] t3r1 = { 1, 1, 1 }; CollectionAssert.AreEqual(t3r1, t3.extract_diagonal_down(9)); int[] t3r2 = { 1 }; CollectionAssert.AreEqual(t3r2, t3.extract_diagonal_down(12)); int[] t3r3 = { 1, 1 }; CollectionAssert.AreEqual(t3r3, t3.extract_diagonal_down(4)); }
public void TestTicTacToe() { // test default object size TicTacToe t = new TicTacToe(); Assert.That(3, Is.EqualTo(t.width)); Assert.That(3, Is.EqualTo(t.height)); Assert.That(1, Is.EqualTo(t.player_turn)); t = new TicTacToe(5, 4); Assert.That(5, Is.EqualTo(t.width)); Assert.That(4, Is.EqualTo(t.height)); Assert.That(1, Is.EqualTo(t.player_turn)); }
public void BoardAnalyse() { Console.WriteLine("xxxxxxxxxxxxxxx"); TicTacToe t = new TicTacToe( "X.X\n" + "O.O\n" + "X..\n"); RowAnalysis r = t.analyse_board(1); Console.WriteLine(t.ToString()); Console.WriteLine(r.ToString(false)); Console.WriteLine(r.result[0].ToString()); // Assert.That(r.result.Capacity, Is.EqualTo(8)); Assert.That(r.result[0].rank, Is.EqualTo(1f)); Assert.That(r.result[0].position, Is.EqualTo(0)); Assert.That(r.result[0].direction, Is.EqualTo(0)); Assert.That(r.result[0].index, Is.EqualTo(0)); Assert.That(r.result[0].suggestion, Is.EqualTo(1)); Assert.That(r.result[1].rank, Is.EqualTo(1.0f / 3)); Assert.That(r.result[1].position, Is.EqualTo(0)); Assert.That(r.result[1].direction, Is.EqualTo(45)); Assert.That(r.result[1].index, Is.EqualTo(0)); Assert.That(r.result[1].suggestion, Is.EqualTo(2)); Assert.That(r.result[2].rank, Is.EqualTo(1.0f / 3)); Assert.That(r.result[2].position, Is.EqualTo(0)); Assert.That(r.result[2].direction, Is.EqualTo(45)); Assert.That(r.result[2].index, Is.EqualTo(0)); Assert.That(r.result[2].suggestion, Is.EqualTo(2)); /*Assert.That(r.result[1].rank, Is.EqualTo(1)); * Assert.That(r.result[2].rank, Is.EqualTo(0.999f)); * Assert.That(r.result[7].rank, Is.EqualTo(0)); * * Assert.That(r.result[0].rank, Is.EqualTo(1)); * Assert.That(r.result[1].rank, Is.EqualTo(1)); * Assert.That(r.result[2].rank, Is.EqualTo(0.999f)); * Assert.That(r.result[7].rank, Is.EqualTo(0)); */ }
public void TestExtractHorizontal() { TicTacToe t = new TicTacToe("XOX\nOXO\nXXO"); int[] tr1 = { 1, 2, 1 }; CollectionAssert.AreEqual(tr1, t.extract_row(0)); CollectionAssert.AreEqual(tr1, t.extract_row(1)); CollectionAssert.AreEqual(tr1, t.extract_row(2)); int[] tr2 = { 2, 1, 2 }; CollectionAssert.AreEqual(tr2, t.extract_row(3)); CollectionAssert.AreEqual(tr2, t.extract_row(4)); CollectionAssert.AreEqual(tr2, t.extract_row(5)); TicTacToe t2 = new TicTacToe("XOXO\nOXOX\nXXOO\nOOXX\nXOOX"); int[] t2r1 = { 1, 1, 2, 2 }; CollectionAssert.AreEqual(t2r1, t2.extract_row(9)); }
public void TestExtractVertical() { TicTacToe t = new TicTacToe("XOX\nOXO\nXXO"); int[] tr1 = { 1, 2, 1 }; CollectionAssert.AreEqual(tr1, t.extract_column(0)); CollectionAssert.AreEqual(tr1, t.extract_column(3)); CollectionAssert.AreEqual(tr1, t.extract_column(6)); int[] tr2 = { 2, 1, 1 }; CollectionAssert.AreEqual(tr2, t.extract_column(1)); CollectionAssert.AreEqual(tr2, t.extract_column(4)); CollectionAssert.AreEqual(tr2, t.extract_column(7)); TicTacToe t2 = new TicTacToe("XOXO\n" + "OXOX\n" + "XXOO\n" + "OOXX\n" + "XOOX"); int[] t2r1 = { 2, 1, 1, 2, 2 }; CollectionAssert.AreEqual(t2r1, t2.extract_column(9)); }
public void TestExtractColumn2() { TicTacToe t = new TicTacToe("XOX\nOXO\nXXO"); Assert.That(() => t.extract_row(9), Throws.TypeOf <IndexOutOfRangeException>()); }