2023-06-08 16:02:55 +02:00
|
|
|
from square import Square
|
2023-06-13 00:08:24 +02:00
|
|
|
from piece import Piece
|
2023-06-08 16:02:55 +02:00
|
|
|
import random
|
|
|
|
|
|
|
|
class Board:
|
|
|
|
def __init__(self):
|
|
|
|
self.boardlist = [[0, 0, 0, 0, 0, 0, 0, 0] for x in range(8)]
|
|
|
|
#creating board
|
|
|
|
for row in range(8):
|
|
|
|
for column in range(8):
|
|
|
|
self.boardlist[row][column] = Square(row, column)
|
|
|
|
self._add_pieces('white')
|
|
|
|
self._add_pieces('black')
|
|
|
|
|
|
|
|
def _add_pieces(self, color):
|
|
|
|
if color == 'white':
|
|
|
|
self.pawn_row = 6
|
|
|
|
self.other_row = 7
|
|
|
|
else:
|
|
|
|
self.pawn_row = 1
|
|
|
|
self.other_row = 0
|
2023-06-15 16:22:32 +02:00
|
|
|
|
|
|
|
self.boardlist[0][0] = Square(0, 0, Piece("king", 'black'))
|
|
|
|
self.boardlist[2][2] = Square(2, 2, Piece("queen", 'white'))
|
|
|
|
self.boardlist[2][2] = Square(2, 2, Piece("king", 'white'))
|
|
|
|
"""
|
2023-06-08 16:02:55 +02:00
|
|
|
#pawns
|
|
|
|
for column in range(8):
|
2023-06-13 16:17:23 +02:00
|
|
|
self.boardlist[self.pawn_row][column] = Square(self.pawn_row, column, Piece("pawn", color))
|
2023-06-08 16:02:55 +02:00
|
|
|
#rooks
|
2023-06-13 00:08:24 +02:00
|
|
|
self.boardlist[self.other_row][0] = Square(self.other_row, 0, Piece("rook", color))
|
|
|
|
self.boardlist[self.other_row][7] = Square(self.other_row, 7, Piece("rook", color))
|
2023-06-08 16:02:55 +02:00
|
|
|
#knigths
|
2023-06-13 00:08:24 +02:00
|
|
|
self.boardlist[self.other_row][1] = Square(self.other_row, 1, Piece("knight", color))
|
|
|
|
self.boardlist[self.other_row][6] = Square(self.other_row, 6, Piece("knight", color))
|
2023-06-08 16:02:55 +02:00
|
|
|
#bishops
|
2023-06-13 00:08:24 +02:00
|
|
|
self.boardlist[self.other_row][2] = Square(self.other_row, 2, Piece("bishop",color))
|
|
|
|
self.boardlist[self.other_row][5] = Square(self.other_row, 5, Piece("bishop",color))
|
2023-06-08 16:02:55 +02:00
|
|
|
#queen
|
2023-06-13 00:08:24 +02:00
|
|
|
self.boardlist[self.other_row][3] = Square(self.other_row, 3, Piece("queen", color))
|
2023-06-08 16:02:55 +02:00
|
|
|
#king
|
2023-06-13 00:08:24 +02:00
|
|
|
self.boardlist[self.other_row][4] = Square(self.other_row, 4, Piece("king", color))
|
2023-06-15 16:22:32 +02:00
|
|
|
"""
|