pat
This commit is contained in:
parent
c4b4c7392f
commit
b8d8a2a1ec
Binary file not shown.
Binary file not shown.
12
main.py
12
main.py
@ -1,14 +1,14 @@
|
||||
from game import Game
|
||||
import time
|
||||
#import time
|
||||
game = Game()
|
||||
game2 = Game()
|
||||
game.printBoard()
|
||||
game2.printBoard()
|
||||
ruch=None
|
||||
ruch = None
|
||||
while True:
|
||||
time.sleep(1)
|
||||
ruch=game.nextMove(ruch)
|
||||
#time.sleep(1)
|
||||
ruch = game.nextMove(ruch)
|
||||
game.printBoard()
|
||||
time.sleep(1)
|
||||
ruch=game2.nextMove(ruch)
|
||||
#time.sleep(1)
|
||||
ruch = game2.nextMove(ruch)
|
||||
game2.printBoard()
|
33
move.py
33
move.py
@ -40,23 +40,27 @@ class Move:
|
||||
#usuwanie ruchów z valid_moves, które mogłyby doprowadzić do szachowania króla
|
||||
self.boot_piece = []
|
||||
self.piece_row_column = []
|
||||
self.number_of_pieces = 0
|
||||
for r in range(0, 8):
|
||||
for c in range(0, 8):
|
||||
if self.board.boardlist[r][c].has_piece():
|
||||
self.number_of_pieces = self.number_of_pieces +1
|
||||
if self.board.boardlist[r][c].piece.color != color:
|
||||
self.kopia = []
|
||||
for move in self.board.boardlist[r][c].piece.valid_moves:
|
||||
if Move.check_szach(self, color, r, c, move[0], move[1]) is False:
|
||||
self.kopia.append(move)
|
||||
self.board.boardlist[r][c].piece.valid_moves=self.kopia
|
||||
if self.number_of_pieces == 2:
|
||||
exit(0)
|
||||
#spis pól z figurami, które mają możliwość ruchu
|
||||
for r in range(8):
|
||||
for c in range(8):
|
||||
if self.board.boardlist[r][c].has_piece() and self.board.boardlist[r][c].piece.color != color:
|
||||
if (len(self.board.boardlist[r][c].piece.valid_moves)>0):
|
||||
if len(self.board.boardlist[r][c].piece.valid_moves) > 0:
|
||||
self.boot_piece.append(self.board.boardlist[r][c])
|
||||
if (len(self.boot_piece)==0):
|
||||
print("MAT")
|
||||
#pat
|
||||
if len(self.boot_piece) == 0:
|
||||
exit(0)
|
||||
#losowanie figury
|
||||
self.value = random.randrange(0, len(self.boot_piece))
|
||||
@ -70,8 +74,7 @@ class Move:
|
||||
self.move_final_column = self.move_final_square[1]
|
||||
return self.move_initial_row, self.move_initial_column, self. move_final_row, self.move_final_column #, self.x
|
||||
def calc_moves(self, piece, row, column):
|
||||
#piece.delete_moves()
|
||||
piece.valid_moves=[]
|
||||
piece.delete_moves()
|
||||
if piece.name == 'rook':
|
||||
Rook.rook_moves(self, piece, row, column)
|
||||
pass
|
||||
@ -110,29 +113,29 @@ class Move:
|
||||
if self.board.boardlist[r][c].has_piece():
|
||||
if self.board.boardlist[r][c].piece.color == color:
|
||||
Move.calc_moves(self, self.board.boardlist[r][c].piece, r, c)
|
||||
elif self.board.boardlist[r][c].piece.name=='king':
|
||||
elif self.board.boardlist[r][c].piece.name == 'king':
|
||||
self.king_position = (r, c)
|
||||
for r2 in range(8):
|
||||
for c2 in range(8):
|
||||
if self.board.boardlist[r2][c2].has_piece():
|
||||
if self.board.boardlist[r2][c2].piece.color == color:
|
||||
if self.king_position in self.board.boardlist[r2][c2].piece.valid_moves:
|
||||
self.board.boardlist[final_row][final_column].piece=self.previous_piece
|
||||
self.board.boardlist[initial_row][initial_column].piece= self.piece
|
||||
self.board.boardlist[final_row][final_column].piece = self.previous_piece
|
||||
self.board.boardlist[initial_row][initial_column].piece = self.piece
|
||||
for rowxd2 in range(8):
|
||||
for columnxd2 in range(8):
|
||||
if self.board.boardlist[rowxd2][columnxd2].has_piece():
|
||||
if self.board.boardlist[rowxd2][columnxd2].piece.color == color:
|
||||
Move.calc_moves(self, self.board.boardlist[rowxd2][columnxd2].piece, rowxd2,columnxd2)
|
||||
Move.calc_moves(self, self.board.boardlist[rowxd2][columnxd2].piece, rowxd2, columnxd2)
|
||||
return True
|
||||
self.board.boardlist[final_row][final_column].piece = self.previous_piece
|
||||
self.board.boardlist[initial_row][initial_column].piece = self.piece
|
||||
for rowxd in range(8):
|
||||
for columnxd in range(8):
|
||||
if self.board.boardlist[rowxd][columnxd].has_piece():
|
||||
if self.board.boardlist[rowxd][columnxd].has_piece():
|
||||
if self.board.boardlist[rowxd][columnxd].piece.color == color:
|
||||
Move.calc_moves(self, self.board.boardlist[rowxd][columnxd].piece, rowxd, columnxd)
|
||||
for r3 in range(8):
|
||||
for c3 in range(8):
|
||||
if self.board.boardlist[r3][c3].has_piece():
|
||||
if self.board.boardlist[r3][c3].has_piece():
|
||||
if self.board.boardlist[r3][c3].piece.color == color:
|
||||
Move.calc_moves(self, self.board.boardlist[r3][c3].piece, r3, c3)
|
||||
return False
|
||||
@staticmethod
|
||||
def numbers_to_letters(number):
|
||||
|
Loading…
Reference in New Issue
Block a user