Upgrade to Chess.com Premium!

Python Code for Daniel Rensch's "Achieving Full Board Awareness" Lecture

For those of us whose friends include command terminals, I wrote a quick little python code to do the first exercise in Daniel Rensch's 'Achieving Full Board Awareness' lectures.  Save the following lines of codes to a .py file and run it at a terminal.  A square name will pop up, enter lower case 'b' if the square is black and 'w' if the square is white.  After 15 squares are completed succesfully the time the exercise took will be posted. 

  Enjoy,

     Bogoliubon

 

from random import choice
from time import time

files = ['a','b','c','d','e','f','g','h']
rank = [str(i+1) for i in range(8)]
coordinates = {}

for i in range(8):
    for j in range(8):
        if (i+j)%2 == 0:
            exec('coordinates.update('+files[i]+rank[j]+'=\'b\')')
        else:
            exec('coordinates.update('+files[i]+rank[j]+'=\'w\')')

print 'enter b if the square is black or w if square is white'

start_time = time()

for i in range(15):
    tmp = choice(coordinates.keys())
    ans = coordinates[tmp]
    Bogoliubon = 0
    while Bogoliubon != ans:
        Bogoliubon = raw_input(tmp+" ")

end_time = time()

print 'exercise finished in ', end_time-start_time, ' seconds.'

Comments


  • 8 months ago

    sapientdust

    Thanks for sharing.

  • 15 months ago

    Psilocybin-DMT-

    I think some of us could use some help running python in windows command prompt.

    Thank you for taking the time to create this program.

Back to Top

Post your reply: