letters to numbers
This commit is contained in:
parent
157aa82794
commit
73bef9f806
Binary file not shown.
12
board.py
12
board.py
@ -182,32 +182,20 @@ class Board:
|
|||||||
if self.board.boardlist[r][c].piece != None:
|
if self.board.boardlist[r][c].piece != None:
|
||||||
if self.board.boardlist[r][c].piece.color != color:
|
if self.board.boardlist[r][c].piece.color != color:
|
||||||
self.boot_piece.append(self.board.boardlist[r][c])
|
self.boot_piece.append(self.board.boardlist[r][c])
|
||||||
#random piece
|
|
||||||
|
|
||||||
self.value = random.randrange(0, len(self.boot_piece))
|
self.value = random.randrange(0, len(self.boot_piece))
|
||||||
self.initial = self.boot_piece[self.value]
|
self.initial = self.boot_piece[self.value]
|
||||||
while len(self.initial.piece.valid_moves) == 0:
|
while len(self.initial.piece.valid_moves) == 0:
|
||||||
#print('xddd')
|
|
||||||
#print(self.initial.piece)
|
|
||||||
#print(self.initial.piece.valid_moves)
|
|
||||||
self.value = random.randrange(0, len(self.boot_piece))
|
self.value = random.randrange(0, len(self.boot_piece))
|
||||||
self.initial = self.boot_piece[self.value]
|
self.initial = self.boot_piece[self.value]
|
||||||
self.initial_row=self.initial.row
|
self.initial_row=self.initial.row
|
||||||
self.initial_column = self.initial.column
|
self.initial_column = self.initial.column
|
||||||
#print(self.initial)
|
|
||||||
#random move
|
|
||||||
self.value = random.randrange(0, len(self.initial.piece.valid_moves))
|
self.value = random.randrange(0, len(self.initial.piece.valid_moves))
|
||||||
self.final = self.initial.piece.valid_moves[self.value]
|
self.final = self.initial.piece.valid_moves[self.value]
|
||||||
self.final_row = self.final[0]
|
self.final_row = self.final[0]
|
||||||
self.final_column = self.final[1]
|
self.final_column = self.final[1]
|
||||||
#print(self.final)
|
|
||||||
#print(self.final_row)
|
|
||||||
#update
|
|
||||||
self.x = self.board.boardlist[self.initial_row][self.initial_column].piece
|
self.x = self.board.boardlist[self.initial_row][self.initial_column].piece
|
||||||
#print(self.board.boardlist[self.initial_row][self.initial_column].piece.name)
|
|
||||||
#print(self.initial_row, self.initial_column)
|
|
||||||
self.board.boardlist[self.initial_row][self.initial_column].piece = None
|
self.board.boardlist[self.initial_row][self.initial_column].piece = None
|
||||||
#print(self.final_row, self.final_column)
|
|
||||||
if (self.board.boardlist[self.final_row][self.final_column].has_piece()):
|
if (self.board.boardlist[self.final_row][self.final_column].has_piece()):
|
||||||
if (self.board.boardlist[self.final_row][self.final_column].piece.name== 'king'):
|
if (self.board.boardlist[self.final_row][self.final_column].piece.name== 'king'):
|
||||||
self.board.boardlist[self.final_row][self.final_column].piece = self.x
|
self.board.boardlist[self.final_row][self.final_column].piece = self.x
|
||||||
|
2
main.py
2
main.py
@ -5,9 +5,7 @@ game.printBoard()
|
|||||||
game2.printBoard()
|
game2.printBoard()
|
||||||
ruch=None
|
ruch=None
|
||||||
while True:
|
while True:
|
||||||
print (ruch)
|
|
||||||
ruch = game.nextMove(ruch)
|
ruch = game.nextMove(ruch)
|
||||||
game.printBoard()
|
game.printBoard()
|
||||||
print(ruch)
|
|
||||||
ruch = game2.nextMove(ruch)
|
ruch = game2.nextMove(ruch)
|
||||||
game2.printBoard()
|
game2.printBoard()
|
||||||
|
Loading…
Reference in New Issue
Block a user