-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_chessblock.py
30 lines (21 loc) · 1.13 KB
/
my_chessblock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import numpy as np
class ChessBlock:
def __init__(self, my_x, my_y):
self.state = "*" #The state variable will show if a block has been moved on by a knight
self.block_x = my_x #The x position of the chessblock
self.block_y = my_y #The y position of the chessblock
self.KnightTourNeighbours = [] # A list of all the chessblocks that are one knight movement away from our chessblock
def __repr__(self):
return self.state
def SetState(self, new_state: str): #Simply changes the state of the chessblock
self.state = new_state
def PrintState(self): # Simply prints the state
print("State = ", self.state)
def GetState(self): # Returns the state of the chessblock
return self.state
def GetPos(self): # Returns the numpy array of the position
return np.array([self.block_x, self.block_y])
def AddChessBlockToKnightTourNeighboursList(self, block): #Adds a chessblock object to the KnightTourNeighbours list
self.KnightTourNeighbours.append(block)
def GKTN(self): #Returns the KnightTourNeighbours list
return self.KnightTourNeighbours