RE: Python Toy chess engine

  • From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 11 Dec 2009 00:37:28 -0500

 

 

I tried running this on three different Linux boxes.  All of them fail.  I
tried using python2.4, 2.5, 2.6, and 3.1

 

3.1 fails because of the print statement as most know 3.1 has changed the
syntax so I supposed you wrote it for one of the lower ones.  On all other
versions of python the following is the error.

 

Traceback (most recent call last):

  File "main.py", line 4, in <module>

    engine = subprocess.Popen("python
/home/kperry/test.py",universal_newlines=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE)

  File "/usr/lib/python2.6/subprocess.py", line 621, in __init__

    errread, errwrite)

  File "/usr/lib/python2.6/subprocess.py", line 1126, in _execute_child

    raise child_exception

OSError: [Errno 2] No such file or directory

 

 

 

From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of R Dinger
Sent: Thursday, December 10, 2009 11:47 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: Python Toy chess engine

 

Hi Jim,

 

Sorry I forgot to indicate how to run it.

 

If the two files are saved as runTest.py and test.py in the same directory,
then starting runTest.py will launch the other and run the text interface
until exit is typed.

 

Richard

----- Original Message ----- 

From: Homme, James <mailto:james.homme@xxxxxxxxxxxx>  

To: 'programmingblind@xxxxxxxxxxxxx' 

Sent: Thursday, December 10, 2009 3:58 AM

Subject: RE: Python Toy chess engine

 

Hi Richard,

Thanks very much for the sample code.

 

Jim

 

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

 

"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: