RE: Python Toy chess engine

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

 

If you want to make this work under linux change the argument to 

 

["python","test.py"]

 

Linux wants the command in the first string and you have told it the command
is "python test.py" so it looks for that.  Linux allows you to make the
executable and the command be different so you could have

 

 (executable='python',["MyProgram","test.py"],.

 

This way if you do ps in linux it will show up as MyProgram instead of
python.  Anyway either of those should work.

 

If you want this to work in python3.1 you just need to change the print to
have the parenthesis around the "" string and then fix the Popen statement
as I said above and it will work there as well.   

 

Enjoy.

 

Ken

 

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: