예제 #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;
        }
예제 #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);
 }
예제 #3
0
파일: Player.cs 프로젝트: Cerium/Labyrith1
 public Player(Position position)
 {
     this.GetPosition = position;
 }
예제 #4
0
파일: Player.cs 프로젝트: Cerium/Labyrith1
 public Player()
 {
     this.position = new Position(PlayerRow, PlayerCol);
 }
예제 #5
0
파일: Player.cs 프로젝트: Cerium/Labyrith1
 public void RestartDefaultPosition()
 {
     this.position = new Position(PlayerRow, PlayerCol);
 }
예제 #6
0
 bool isValidPosition(Position position)
 {
     return labyrinth[position.x, position.y] == 0 && position.isValidPosition();
 }
예제 #7
0
        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);
        }
예제 #8
0
 bool isBlankPosition(Position position)
 {
     return labyrinth[position.x, position.y] == -1;
 }
예제 #9
0
        bool isBlankMove(Position position, Direction direction)
        {
            Position newPosition = new Position(position.x, position.y);

            newPosition.move(direction);

            return isBlankPosition(newPosition);
        }
예제 #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;
                    }
                }
            }
        }