Exemplo n.º 1
0
 public Direction getDirection(GameBoard board)
 {
     if (!board.Equals(board.move(Direction.Up)))
     {
         return Direction.Up;
     }
     else if (!board.Equals(board.move(Direction.Left)))
     {
         return Direction.Left;
     }
     else if (!board.Equals(board.move(Direction.Right)))
     {
         return Direction.Right;
     }
     else if (!board.Equals(board.move(Direction.Down)))
     {
         return Direction.Down;
     }
     else
     {
         return Direction.None;
     }
 }
Exemplo n.º 2
0
        public void compressLeft()
        {
            GameBoard board = new GameBoard(new int[,]{
                                             {2, 2, 0, 0},
                                             {0, 2, 2 , 2},
                                             {0, 0, 4 , 8},
                                             {0, 0, 4 , 4}
                                             }
                                           );

            GameBoard actual = board.move(Direction.Left);

            GameBoard expected = new GameBoard(new int[,]{
                                             {4, 0, 0, 0},
                                             {4, 2, 0 , 0},
                                             {4, 8, 0 , 0},
                                             {8, 0, 0 , 0}
                                             }
                                           );

            Assert.IsTrue(expected.Equals(actual));
        }
Exemplo n.º 3
0
        public void compressDown()
        {
            GameBoard board = new GameBoard(new int[,]{
                                             {2, 2, 0, 0},
                                             {0, 2, 2 , 0},
                                             {0, 2, 4 , 8},
                                             {0, 0, 4 , 4}
                                             }
                                           );

            GameBoard actual = board.move(Direction.Down);
            board.print();

            GameBoard expected = new GameBoard(new int[,]{
                                             {0, 0, 0, 0},
                                             {0, 0,  0, 0},
                                             {0, 2, 2, 8},
                                             {2, 4, 8, 4}
                                             }
                                           );

            Assert.IsTrue(expected.Equals(actual));
        }
Exemplo n.º 4
0
        public void compressRight()
        {
            GameBoard board = new GameBoard(new int[,]{
                                             {2, 2, 2, 0},
                                             {0, 2, 2 , 0},
                                             {0, 0, 4 , 8},
                                             {0, 0, 4 , 4}
                                             }
                                           );

            GameBoard actual = board.move(Direction.Right);

            GameBoard expected = new GameBoard(new int[,]{
                                             {0, 0, 2, 4},
                                             {0, 0, 0, 4},
                                             {0, 0, 4 , 8},
                                             {0, 0, 0 , 8}
                                             }
                                           );

            Assert.IsTrue(expected.Equals(actual));
        }