Commit ce4911d2 authored by DUFAIX Clement's avatar DUFAIX Clement
Browse files

improve emptyPlaceToMove

parent c0314326
......@@ -6,22 +6,23 @@ import PyQt5
class Game:
boardGame = [1, 1, 1, 1, 2, 2, 2, 2,
0] # boardGame[0-7] : kewai, boardGame[8] : putahi, 1 : pion joueur 1, 2 : pion joueur 2, 0 : vide
actualPlayer = 1 # 1 for player 1, 2 for player 2
# def __init__(self):
@staticmethod
def movePawn(positionToMove):
if not Game.isMoveLegit(positionToMove):
return False
return not Game.emptyPlaceToMove(positionToMove)
return True
@staticmethod
def isMoveLegit(positionToMove):
if positionToMove == 9:
if Game.boardGame[8] != 0: return False
def emptyPlaceToMove(positionToMove): #-1 if impossible
if Game.boardGame[8] == 0:
if Game.boardGame[(positionToMove+1)%8] == Game.actualPlayer and Game.boardGame[(positionToMove-1)%8] == Game.actualPlayer: return False
return True
if __name__ == "__main__":
print(Game.movePawn(4))
print(8%8)
\ No newline at end of file
print(Game.movePawn(0))
#print(Game.boardGame[(8 + 1) % 8] == Game.actualPlayer)
#print(8%8)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment