bool isBlankMove(Position position, Direction direction) { Position newPosition = new Position(position.x, position.y); newPosition.move(direction); return(isBlankPosition(newPosition)); }
public bool move(Direction direction) { if (isValidMove(player, direction)) { player.move(direction); } else { return(false); } return(true); }
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)); }
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; } } } } }
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 isBlankMove(Position position, Direction direction) { Position newPosition = new Position(position.x, position.y); newPosition.move(direction); return isBlankPosition(newPosition); }
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; } } } }