summaryrefslogtreecommitdiff
path: root/pexpect/examples/chess2.py
diff options
context:
space:
mode:
authornoah <noah@656d521f-e311-0410-88e0-e7920216d269>2012-10-20 02:19:33 +0000
committernoah <noah@656d521f-e311-0410-88e0-e7920216d269>2012-10-20 02:19:33 +0000
commit0b428eb5d5ceefdb178843db3e12072457fb7aec (patch)
treeaabe4b5fc998cabfbb0946b4d356f6265720ccdf /pexpect/examples/chess2.py
parent74ace3303f22848674bd638d061a54c9dcc7d77d (diff)
downloadpexpect-0b428eb5d5ceefdb178843db3e12072457fb7aec.tar.gz
Mostly a massive license update. Added a license per file.HEADmaster
git-svn-id: http://pexpect.svn.sourceforge.net/svnroot/pexpect/trunk@533 656d521f-e311-0410-88e0-e7920216d269
Diffstat (limited to 'pexpect/examples/chess2.py')
-rwxr-xr-xpexpect/examples/chess2.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/pexpect/examples/chess2.py b/pexpect/examples/chess2.py
index c62d5ce..7fe959a 100755
--- a/pexpect/examples/chess2.py
+++ b/pexpect/examples/chess2.py
@@ -2,6 +2,24 @@
'''This demonstrates controlling a screen oriented application (curses).
It starts two instances of gnuchess and then pits them against each other.
+
+PEXPECT LICENSE
+
+ This license is approved by the OSI and FSF as GPL-compatible.
+ http://opensource.org/licenses/isc-license.txt
+
+ Copyright (c) 2012, Noah Spurrier <noah@noah.org>
+ PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY
+ PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE
+ COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES.
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
'''
import pexpect
@@ -14,7 +32,7 @@ class Chess:
def __init__(self, engine = "/usr/local/bin/gnuchess -a -h 1"):
self.child = pexpect.spawn (engine)
self.term = ANSI.ANSI ()
-
+
#self.child.expect ('Chess')
#if self.child.after != 'Chess':
# raise IOError, 'incompatible chess program'
@@ -77,7 +95,7 @@ class Chess:
def parse_computer_move (self, s):
i = s.find ('is: ')
- cm = s[i+3:i+9]
+ cm = s[i+3:i+9]
return cm
def get_computer_move (self, e = 0):
time.sleep(1)
@@ -123,7 +141,7 @@ while not done:
black.wait ('White')
move_black = black.get_computer_move()
LOG ( 'move black:'+ move_black )
-
+
white.do_move (move_black, 1)
g.quit()