New version of Sunfish

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Side note on Pypy

Post by Sven »

Maybe there is an undesired blank after the backslash at the end of the "print ..." line?
Guenther
Posts: 4718
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: Side note on Pypy

Post by Guenther »

Hi Sven, that was my first idea too, but there is no space at line end.

Here is the relevant code (which works invoking Python 2.7):

Code: Select all

class Move:
    def __init__(self,from_square,to_square,move_name="",
                 captured_piece="",promoted_piece=""):
        self.from_square = from_square
        self.to_square = to_square
        self.move_name = move_name
        self.captured_piece = captured_piece
        self.promoted_piece = promoted_piece

    def __repr__(self):
        print "Move: from square = %s  to square = %s  name = %s" % \
              (bin2alg[self.from_square],bin2alg[self.to_square],self.move_name)
        print "       captured piece = %s  promoted piece = %s" % \
              (str(self.captured_piece),str(self.promoted_piece))

        return("")
Guenther
Posts: 4718
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: Side note on Pypy

Post by Guenther »

It seems I have found an answer which explains the behaviour:

Code: Select all

print 80 * "*"

This is correct syntax for Python 2.

This is NOT correct syntax for Python 3. In Python 3, "print" is a function.
source:
https://bbs.archlinux.org/viewtopic.php ... 4#p1385734

...really hate it that Python 3 has no backward compatibility.

@Thomas (Sunfish) will Sunfish also run with a pypy based on 2.7(9)?

I just want to get ridd off too much python or pypy installations when not needed.

Guenther
User avatar
gbtami
Posts: 389
Joined: Wed Sep 26, 2012 1:29 pm
Location: Hungary

Re: Side note on Pypy

Post by gbtami »

Guenther wrote:After I successfully installed pypy on my machine I thought why not generalize my other python program installed,
which is Shatranj in a few versions. Before it was linked to a Python 2.7 installation which worked.
With pypy 3.21 I get the error below. Any idea? Or do I need an earleir pypy?

Code: Select all

0.000: - Starting server: C:/pypy321/pypy.exe -u C:/Engines/WB/Shatranj_117/Shatranj.py -xboard
0.016: - Priority class set to 16384
0.016: - Thread priority set to normal
0.250: <   File "C:/Engines/WB/Shatranj_117/Shatranj.py", line 71
0.250: <     print "Move: from square = %s  to square = %s  name = %s" % \
0.250: <          ^
0.250: < SyntaxError: invalid syntax
Seems you installed some old python3 version.
Python3 is not compatible with Python2. For example in 3 print() is a function while in 2 print is a statement.
Try to install the latest Python2 version from here:
http://pypy.org/download.html#other-versions
thomasahle
Posts: 94
Joined: Thu Feb 27, 2014 8:19 pm

Re: New version of Sunfish

Post by thomasahle »

Good idea about using the extra fields for the free text. I'll look into that.
thomasahle
Posts: 94
Joined: Thu Feb 27, 2014 8:19 pm

Re: Side note on Pypy

Post by thomasahle »

Guenther wrote:After I successfully installed pypy on my machine I thought why not generalize my other python program installed,
which is Shatranj in a few versions. Before it was linked to a Python 2.7 installation which worked.
With pypy 3.21 I get the error below. Any idea? Or do I need an earleir pypy?

Code: Select all

0.000: - Starting server: C:/pypy321/pypy.exe -u C:/Engines/WB/Shatranj_117/Shatranj.py -xboard
0.016: - Priority class set to 16384
0.016: - Thread priority set to normal
0.250: <   File "C:/Engines/WB/Shatranj_117/Shatranj.py", line 71
0.250: <     print "Move: from square = %s  to square = %s  name = %s" % \
0.250: <          ^
0.250: < SyntaxError: invalid syntax
As Tamás says, you are running python2 code with a python3 interpreter.

I test Sunfish with python2, pypy2, python3 and pypy3. I recommend pypy3.
thomasahle
Posts: 94
Joined: Thu Feb 27, 2014 8:19 pm

Re: New version of Sunfish

Post by thomasahle »

I have a new version on github now, which fixes this.
Guenther
Posts: 4718
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: Side note on Pypy

Post by Guenther »

gbtami wrote:
Seems you installed some old python3 version.
BTW you realize that the newest available pypy3 build for WIN is already
more than 2 years old (June 2014)?
No idea why they are stuck since then. I bet the info below is there since long.

Code: Select all

Windows binary (32bit) (hopefully availabe soon) 
Guenther
Posts: 4718
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: New version of Sunfish

Post by Guenther »

thomasahle wrote:I have a new version on github now, which fixes this.
I downloaded it and now all is shown! I will run some test games under WB
against PyChess.
BTW I forgot to ask if you could add a version number or a time stamp
for each release? - for now I added the date to the according print function
in the xboard.py.

Code: Select all

e.g. print('feature myname="Sunfish_20160823"')
Last edited by Guenther on Tue Aug 23, 2016 12:16 pm, edited 1 time in total.
User avatar
gbtami
Posts: 389
Joined: Wed Sep 26, 2012 1:29 pm
Location: Hungary

Re: Side note on Pypy

Post by gbtami »

Guenther wrote:
gbtami wrote:
Seems you installed some old python3 version.
BTW you realize that the newest available pypy3 build for WIN is already
more than 2 years old (June 2014)?
No idea why they are stuck since then. I bet the info below is there since long.

Code: Select all

Windows binary (32bit) (hopefully availabe soon) 
I hope this will change next year.
https://morepypy.blogspot.hu/2016/08/py ... a-for.html