Skip to content

Instantly share code, notes, and snippets.

@NicolaM94
Last active February 5, 2023 01:29
Show Gist options
  • Save NicolaM94/ae4e0e850250a6974042b0ac72be7585 to your computer and use it in GitHub Desktop.
Save NicolaM94/ae4e0e850250a6974042b0ac72be7585 to your computer and use it in GitHub Desktop.
Pawn class in python
MAX_X = 8
MAX_Y = 8
class Pawn:
def __init__(self,x,y):
self.x = x
self.y = y
def possibleMoves(self):
moves = []
if self.x+1 <= MAX_X and self.y <= MAX_Y:
moves.append((self.x+1,self.y+1))
if self.x-1 > 0 and self.y <= MAX_Y:
moves.append((self.x-1,self.y+1))
return moves
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment