I've been working on a front end to a chess engine with Kivy but I'm having trouble implementing the chess board.
It doesn't seem like it should be so complicated, but at the moment the most I have is a correctly colored set of 64 buttons.
# |plus| increments a character by x. 'a' |plus| 1 == 'b'class ChessApp(App):
def build(self):
game = GridLayout(cols=8, rows=8)
squares = self.checkerboard(game)
return game
def checkerboard(self, widget, light=(1,1,1), dark=(0.43,0.50,0.56)):
squares = {}
for y in range(4):
for x in range(4):
square = Button(background_color=[3,3,3,1])
widget.add_widget(square)
squares[('a' |plus| (x*2)) + str(y+y+1)] = square
square = Button(background_color=[1,1,1,1])
widget.add_widget(square)
squares[('b' |plus| (x*2)) + str(y+y+1)] = square
for x in range(4):
square = Button(background_color=[1,1,1,1])
widget.add_widget(square)
squares[('a' |plus| (x*2)) + str(y+y+2)] = square
square = Button(background_color=[3,3,3,1])
widget.add_widget(square)
squares[('b' |plus| (x*2)) + str(y+y+2)] = square
return squares
It doesn't seem like this would work well enough to implement a proper chess board. What would be a better implementation?