Exemplo n.º 1
0
        public void TestPlace()
        {
            TicTacToe t = new TicTacToe();

            string s = t.ToString();

            Assert.That("...\n...\n...", Is.EqualTo(s));
            Assert.That(1, Is.EqualTo(t.player_turn));
            Assert.That(3, Is.EqualTo(t.width));
            Assert.That(3, Is.EqualTo(t.height));

            // test x,y place
            t.place(2, 0);
            Assert.AreEqual("..X\n...\n...", t.ToString());
            Assert.AreEqual(2, t.player_turn);

            // test x,y place
            t.place(3);
            Assert.AreEqual("..X\nO..\n...", t.ToString());
            Assert.AreEqual(1, t.player_turn);

            // test x,y place
            t.place(8);
            Assert.AreEqual("..X\nO..\n..X", t.ToString());
            Assert.That(2, Is.EqualTo(t.player_turn));
            Assert.That(3, Is.EqualTo(t.width));
            Assert.That(3, Is.EqualTo(t.height));
        }
Exemplo n.º 2
0
        public void TestParseBoard()
        {
            TicTacToe t;

            t = new TicTacToe(".........");
            Assert.AreEqual("...\n...\n...", t.ToString());
            Assert.AreEqual(3, t.width);
            Assert.AreEqual(3, t.height);
            Assert.AreEqual(0, t.turns);
            Assert.AreEqual(1, t.player_turn);


            t = new TicTacToe("..X.O.X..\n");
            Assert.AreEqual("..X\n.O.\nX..", t.ToString());
            Assert.AreEqual(3, t.width);
            Assert.AreEqual(3, t.height);
            Assert.AreEqual(3, t.turns);
            Assert.AreEqual(2, t.player_turn);

            t = new TicTacToe("..............X.");

            Assert.AreEqual("....\n....\n....\n..X.", t.ToString());
            Assert.AreEqual(4, t.width);
            Assert.AreEqual(4, t.height);
            Assert.AreEqual(1, t.turns);
            Assert.AreEqual(2, t.player_turn);

            t = new TicTacToe("....\n....\n....\n..X.\n....");
            Assert.AreEqual("....\n....\n....\n..X.\n....", t.ToString());
            Assert.AreEqual(4, t.width);
            Assert.AreEqual(5, t.height);
            Assert.AreEqual(1, t.turns);
            Assert.AreEqual(2, t.player_turn);
        }
Exemplo n.º 3
0
        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));
             */
        }