.
This commit is contained in:
parent
b8d8a2a1ec
commit
ea6043e7ac
Binary file not shown.
6
main.py
6
main.py
@ -1,14 +1,14 @@
|
||||
from game import Game
|
||||
#import time
|
||||
import time
|
||||
game = Game()
|
||||
game2 = Game()
|
||||
game.printBoard()
|
||||
game2.printBoard()
|
||||
ruch = None
|
||||
while True:
|
||||
#time.sleep(1)
|
||||
time.sleep(1)
|
||||
ruch = game.nextMove(ruch)
|
||||
game.printBoard()
|
||||
#time.sleep(1)
|
||||
time.sleep(1)
|
||||
ruch = game2.nextMove(ruch)
|
||||
game2.printBoard()
|
14
move.py
14
move.py
@ -7,17 +7,19 @@ from rook import Rook
|
||||
from queen import Queen
|
||||
from king import King
|
||||
import random
|
||||
|
||||
class Move:
|
||||
def move_rival(self, ruch):
|
||||
self.from_column = Move.letters_to__numbers(ruch[0])
|
||||
self.from_row = int(ruch[1])
|
||||
|
||||
self.to_column = Move.letters_to__numbers(ruch[3])
|
||||
self.to_row = int(ruch[4])
|
||||
|
||||
#update board
|
||||
self.x = self.board.boardlist[self.from_row][self.from_column].piece
|
||||
self.board.boardlist[self.from_row][self.from_column].piece = None
|
||||
self.board.boardlist[self.to_row][self.to_column].piece = self.x
|
||||
|
||||
Move.pawn_promotion(self, self.x, self.to_row)
|
||||
self.board.boardlist[self.to_row][self.to_column].piece.moved = True
|
||||
return self.board.boardlist[self.to_row][self.to_column].piece.color
|
||||
@ -40,18 +42,18 @@ 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
|
||||
self.amount_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
|
||||
self.amount_of_pieces = self.amount_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:
|
||||
self.board.boardlist[r][c].piece.valid_moves = self.kopia
|
||||
if self.amount_of_pieces == 2:
|
||||
exit(0)
|
||||
#spis pól z figurami, które mają możliwość ruchu
|
||||
for r in range(8):
|
||||
@ -72,7 +74,7 @@ class Move:
|
||||
self.move_final_square = self.initial_square.piece.valid_moves[self.value]
|
||||
self.move_final_row = self.move_final_square[0]
|
||||
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
|
||||
return self.move_initial_row, self.move_initial_column, self. move_final_row, self.move_final_column
|
||||
def calc_moves(self, piece, row, column):
|
||||
piece.delete_moves()
|
||||
if piece.name == 'rook':
|
||||
|
Loading…
Reference in New Issue
Block a user