Beispiel #1
0
        private bool IsVisitedPosition(Player player, Direction direction)
        {
            Position pos = new Position(player.GetPosition.Row, player.GetPosition.Col);
            Player bot = new Player(pos);
            bot.Move(direction);
            if (labyrinth[bot.GetPosition.Row, bot.GetPosition.Col] == -1)
            {
                return true;
            }

            return false;
        }
Beispiel #2
0
 public void IsVisitedPosition_Test_True()
 {
     BindingFlags eFlags = BindingFlags.Instance | BindingFlags.NonPublic;
     Playfield palyfield = new Playfield();
     Position position = new Position(3, 5);
     Player player = new Player(position);
     Direction direction = Direction.Left;
     Object[] arguments = new object[] { player, direction };
     MethodInfo testedMethod = typeof(Playfield).GetMethod("IsVisitedPosition", eFlags);
     bool actual = (bool)testedMethod.Invoke(palyfield, arguments);
     bool expected = false;
     Assert.AreEqual(expected, actual);
 }
Beispiel #3
0
 public Player(Position position)
 {
     this.GetPosition = position;
 }
Beispiel #4
0
 public Player()
 {
     this.position = new Position(PlayerRow, PlayerCol);
 }
Beispiel #5
0
 public void RestartDefaultPosition()
 {
     this.position = new Position(PlayerRow, PlayerCol);
 }
 bool isValidPosition(Position position)
 {
     return labyrinth[position.x, position.y] == 0 && position.isValidPosition();
 }
        bool isValidMove(Position position, Direction direction)
        {
            if (position.isWinning()) return false;

            Position newPosition = new Position(position.x, position.y);

            newPosition.move(direction);

            return isValidPosition(newPosition);
        }
 bool isBlankPosition(Position position)
 {
     return labyrinth[position.x, position.y] == -1;
 }
        bool isBlankMove(Position position, Direction direction)
        {
            Position newPosition = new Position(position.x, position.y);

            newPosition.move(direction);

            return isBlankPosition(newPosition);
        }
Beispiel #10
0
        public void reset()
        {
            player = new Position();

            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    labyrinth[i, j] = -1;
                }
            }

            labyrinth[3, 3] = 0;

            Direction d = Direction.Blank;
            Random random = new Random();
            Position tempPos2 = new Position();
            while (!tempPos2.isWinning())
            {
                do
                {
                    int randomNumber = random.Next() % 4;
                    d = (Direction)(randomNumber);
                } while (!isBlankMove(tempPos2, d));

                tempPos2.move(d);

                labyrinth[tempPos2.x, tempPos2.y] = 0;
            }
            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    if (labyrinth[i, j] == -1)
                    {
                        int randomNumber = random.Next();
                        if (randomNumber % 3 == 0) labyrinth[i, j] = 0;
                        else labyrinth[i, j] = 1;
                    }
                }
            }
        }