.
This commit is contained in:
parent
ea6043e7ac
commit
861fa8c9b4
Binary file not shown.
4
main.py
4
main.py
@ -6,9 +6,9 @@ game.printBoard()
|
|||||||
game2.printBoard()
|
game2.printBoard()
|
||||||
ruch = None
|
ruch = None
|
||||||
while True:
|
while True:
|
||||||
time.sleep(1)
|
#time.sleep(1)
|
||||||
ruch = game.nextMove(ruch)
|
ruch = game.nextMove(ruch)
|
||||||
game.printBoard()
|
game.printBoard()
|
||||||
time.sleep(1)
|
#time.sleep(1)
|
||||||
ruch = game2.nextMove(ruch)
|
ruch = game2.nextMove(ruch)
|
||||||
game2.printBoard()
|
game2.printBoard()
|
5
move.py
5
move.py
@ -27,7 +27,7 @@ class Move:
|
|||||||
self.initial_row, self.initial_column, self.final_row, self.final_column = Move.random_valid_move(self, color)
|
self.initial_row, self.initial_column, self.final_row, self.final_column = Move.random_valid_move(self, color)
|
||||||
self.x=self.board.boardlist[self.initial_row][self.initial_column].piece
|
self.x=self.board.boardlist[self.initial_row][self.initial_column].piece
|
||||||
self.board.boardlist[self.initial_row][self.initial_column].piece = None
|
self.board.boardlist[self.initial_row][self.initial_column].piece = None
|
||||||
Move.mat(self, self.x, self.final_row, self.final_column)
|
Move.mat(self, self.final_row, self.final_column)
|
||||||
self.board.boardlist[self.final_row][self.final_column].piece = self.x
|
self.board.boardlist[self.final_row][self.final_column].piece = self.x
|
||||||
Move.pawn_promotion(self, self.x, self.final_row)
|
Move.pawn_promotion(self, self.x, self.final_row)
|
||||||
# update piece
|
# update piece
|
||||||
@ -99,9 +99,10 @@ class Move:
|
|||||||
if x.name == "pawn":
|
if x.name == "pawn":
|
||||||
if (final_row == 0) or (final_row == 7):
|
if (final_row == 0) or (final_row == 7):
|
||||||
x.name = "queen"
|
x.name = "queen"
|
||||||
def mat(self, x, final_row, final_column):
|
def mat(self, final_row, final_column):
|
||||||
if self.board.boardlist[final_row][final_column].has_piece():
|
if self.board.boardlist[final_row][final_column].has_piece():
|
||||||
if self.board.boardlist[final_row][final_column].piece.name == 'king':
|
if self.board.boardlist[final_row][final_column].piece.name == 'king':
|
||||||
|
print("mat")
|
||||||
exit(0)
|
exit(0)
|
||||||
pass
|
pass
|
||||||
def check_szach(self, color, initial_row, initial_column, final_row, final_column):
|
def check_szach(self, color, initial_row, initial_column, final_row, final_column):
|
||||||
|
@ -20,8 +20,9 @@ class Square:
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def on_board(*args):
|
def on_board(row, column):
|
||||||
for arg in args:
|
if row < 0 or row > 7:
|
||||||
if arg < 0 or arg > 7:
|
return False
|
||||||
return False
|
if column < 0 or column > 7:
|
||||||
|
return False
|
||||||
return True
|
return True
|
Loading…
Reference in New Issue
Block a user