Code journal #2 - Random moves

in #coding7 years ago (edited)

Hello Steemit!

Today I had a little more time to focus on the actual methods of the library and its behaviour, and this is the result:

ann4.jpg

For the moment, the program selects a random move from the list of allowed moves and both sides keep playing until the game is over. As shown in the image, the end of the game doesn't come from a checkmate, but because of insufficient material, and only after 559 moves. The moves are legal, but stupid.

ann5.jpg

Now I'm trying to figure out how to print several instances of the class chess.Board, since it seems that only one (the last invocation to the method) gets printed to the screen. I know that sooner or later I will quit IPython notebooks, which do not seem the tool for me, but I haven't found a library to print the SVG graphics generated by python-chess yet.

However, I learned today that SVG (Scalable Vector Graphics) are actually defined in XML, so I think this representation will allow me to print those graphic outside IPython notebooks. For instance, this is the representation of the chess.Board in my program:

ann6.jpg

And with this nasty image I finish today's coding. In the next days I will start implementing the first steps towards learning, or at least towards more intelligent decisions: I want to create a function to calculate the value of a given board depending on the value of the pieces alive. That is, if a white movement produces a capture, that would be evaluated as more positive for white, and vice versa. But that's for another day!

Coin Marketplace

STEEM 0.28
TRX 0.21
JST 0.039
BTC 96371.79
ETH 3682.82
SBD 3.84