RE: Python Toy chess engine

  • From: "Homme, James" <james.homme@xxxxxxxxxxxx>
  • To: "'programmingblind@xxxxxxxxxxxxx'" <programmingblind@xxxxxxxxxxxxx>
  • Date: Thu, 10 Dec 2009 06:58:18 -0500

Hi Richard,
Thanks very much for the sample code.

Jim

Highmark recipients,  Read my accessibility 
blog<http://mysites.highmark.com/personal/lidikki/Blog/default.aspx>

"If a green on green tree falls in the forest and you're there, can you see it?"
"Not unless you have a screen reader." :)

From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of R Dinger
Sent: Wednesday, December 09, 2009 7:27 PM
To: programming
Subject: Python Toy chess engine

Code follows:
--------
# test.py a simulated chess engine

import sys

# chess engine main processing loop:
while True:
  # get player's move from GUI:
  playerMove = sys.stdin.readline().strip('\n')

  # process command:
  if playerMove == 'e4':
    engineMove = 'e5'
  elif playerMove == 'd4':
    engineMove = 'd5'
  else:
    engineMove = 'Unknown move!'

  # send the engine response move back:
  sys.stdout.write("%s\n" % engineMove)
  # the following seems required:
  sys.stdout.flush()

________________________________
This e-mail and any attachments to it are confidential and are intended solely 
for use of the individual or entity to whom they are addressed. If you have 
received this e-mail in error, please notify the sender immediately and then 
delete it. If you are not the intended recipient, you must not keep, use, 
disclose, copy or distribute this e-mail without the author's prior permission. 
The views expressed in this e-mail message do not necessarily represent the 
views of Highmark Inc., its subsidiaries, or affiliates.

Other related posts: