def making_moves(): k = 0 while k < 2: player.print(False) print( "Please enter the position you want to put your airplane and his direction: " ) try: x = int(input("X: ")) y = input("Y: ") if y in letters: y = int(letters[y]) dir = int(input("Direction: ")) ar = airplane(x, y, dir) if player.validate_move(ar, 'player') == True: k += 1 player.make_move(ar) ar_ai = ai_move() while ai.validate_move(ar_ai, 'ai') == False: ar_ai = ai_move() ai.make_move(ar_ai) else: print("Invalid input!") except ValueError: print("X and Direction must be int!") player.print(False)
def ai_move(): dir = randint(1, 4) x = 0 y = 0 if dir == 1: x = randint(2, 6) y = randint(3, 6) if dir == 2: x = randint(3, 6) y = randint(3, 7) if dir == 3: x = randint(3, 7) y = randint(3, 6) else: x = randint(3, 6) y = randint(2, 6) return airplane(x, y, dir)
def test_cond1(self): self._repo.make_move(airplane(2,3,1)) assert self._repo.cond1(3,4) == False assert self._repo.cond1(5,5) == True
def test_validate_move(self): assert self._repo.validate_move(airplane(2,3,1),'player') == True assert self._repo.validate_move(airplane(1,3,2),'player') == False assert self._repo.validate_move(airplane(6,7,3),'player') == False assert self._repo.validate_move(airplane(3,2,4),'player') == True assert self._repo.validate_move(airplane(1,3,5),'player') == False
def test_cond4(self): self._repo.make_move(airplane(4, 5, 4)) assert self._repo.cond1(4, 3) == False assert self._repo.cond1(3, 4) == True
def test_cond2(self): self._repo.make_move(airplane(3,4,2)) assert self._repo.cond1(3,4) == False assert self._repo.cond1(5,4) == True