Pentago AI

230 views
Skip to first unread message

Fobax

unread,
Dec 9, 2008, 3:35:05 PM12/9/08
to Pentagoo
I've been working on a pentago AI, written in C++ for the past couple
months. As far as I know, it's the worlds strongest pentago player at
the moment, mainly because the others aren't terribly strong. For the
moment, it's purely command line, but I've been considering doing a
web front end for it so it's actually playable. I noticed you guys
have a great web front end already, and are using a php script to do
the AI. Can you give me some hints on the interface you're using to
access the php backend, so I can implement the same api?

I'm considering posting my code as open source, though I haven't done
so yet.

Timo

cheeaun

unread,
Dec 9, 2008, 9:29:58 PM12/9/08
to Pentagoo
On Dec 10, 4:35 am, Fobax <t...@ewalds.ca> wrote:
> I've been working on a pentago AI, written in C++ for the past couple
> months. As far as I know, it's the worlds strongest pentago player at
> the moment, mainly because the others aren't terribly strong. For the
> moment, it's purely command line, but I've been considering doing a
> web front end for it so it's actually playable. I noticed you guys
> have a great web front end already, and are using a php script to do
> the AI. Can you give me some hints on the interface you're using to
> access the php backend, so I can implement the same api?

Cool. The current Pentagoo game is open-sourced so that you can
actually read the code from http://code.google.com/p/pentagoo/

But anyway, the basic interfacing is the frontend game sends few
parameters, which two of the most important is:
m 001000000000000000000000000000000000
p 2

'm' is the flat matrix of the pentago board. 0 is empty, 1 is player
1, 2 is player 2.
'p' is the player making the last move.

> I'm considering posting my code as open source, though I haven't done
> so yet.

Great :D

Fobax

unread,
Dec 9, 2008, 9:40:26 PM12/9/08
to Pentagoo


On Dec 9, 7:29 pm, cheeaun <chee...@gmail.com> wrote:
> On Dec 10, 4:35 am, Fobax <t...@ewalds.ca> wrote:
>
> > I've been working on a pentago AI, written in C++ for the past couple
> > months. As far as I know, it's the worlds strongest pentago player at
> > the moment, mainly because the others aren't terribly strong. For the
> > moment, it's purely command line, but I've been considering doing a
> > web front end for it so it's actually playable. I noticed you guys
> > have a great web front end already, and are using a php script to do
> > the AI. Can you give me some hints on the interface you're using to
> > access the php backend, so I can implement the same api?
>
> Cool. The current Pentagoo game is open-sourced so that you can
> actually read the code fromhttp://code.google.com/p/pentagoo/
>
> But anyway, the basic interfacing is the frontend game sends few
> parameters, which two of the most important is:
> m       001000000000000000000000000000000000
> p       2
>
> 'm' is the flat matrix of the pentago board. 0 is empty, 1 is player
> 1, 2 is player 2.
> 'p' is the player making the last move.
>
> > I'm considering posting my code as open source, though I haven't done
> > so yet.
>
> Great :D

Ok, so after about 5 hours of work, I've now got a working webserver
that implements the api you're expecting. I just run my server
pointing at a checkout of pentagoo, and it all just works perfectly,
no changes needed. It intercepts calls to pentago_ai.php and replies
instead, using its much stronger AI. You can try it out for the moment
at http://pentago.ewalds.ca/ . The only change I made is to not
disable the computer difficulty. It implements all 5 levels, going
from fairly trivial to beat to VERY VERY hard to beat.

Timo

Lim Chee Aun

unread,
Dec 9, 2008, 9:56:02 PM12/9/08
to pent...@googlegroups.com

Wow! That is so, so, so cool. Would you like to join the project? :)

I'll probably re-code the frontend to be a little better and snappier as well.

--
Lim Chee Aun - http://cheeaun.com/

Fobax

unread,
Dec 10, 2008, 12:23:42 AM12/10/08
to Pentagoo


On Dec 9, 7:56 pm, "Lim Chee Aun" <chee...@gmail.com> wrote:
> > athttp://pentago.ewalds.ca/. The only change I made is to not
> > disable the computer difficulty. It implements all 5 levels, going
> > from fairly trivial to beat to VERY VERY hard to beat.
>
> Wow! That is so, so, so cool. Would you like to join the project? :)
>
> I'll probably re-code the frontend to be a little better and snappier as well.
>
> --
> Lim Chee Aun -http://cheeaun.com/

I'll be happy to join.

I just posted my code under the pentagod project: http://code.google.com/p/pentagod/
. Try it out!

Timo

Lim Chee Aun

unread,
Dec 10, 2008, 2:25:54 AM12/10/08
to pent...@googlegroups.com

Cool. I'm wondering how did you run all the code on a server? C++?

Fobax

unread,
Dec 10, 2008, 2:54:46 AM12/10/08
to Pentagoo
On Dec 10, 12:25 am, "Lim Chee Aun" <chee...@gmail.com> wrote:
> On Wed, Dec 10, 2008 at 1:23 PM, Fobax <t...@ewalds.ca> wrote:
>
> > I just posted my code under the pentagod project:http://code.google.com/p/pentagod/
> > . Try it out!
>
> Cool. I'm wondering how did you run all the code on a server? C++?

Yes, it is C/C++. I built my own webserver based on libevent. For the
one url it does a call to my pentago ai code. For any other url it
just serves static files (ie pentagoo). It should be reasonably easy
to download, compile run and even read. Just check it out, make sure
you have libevent (and libevent-dev) installed, and compile it. The
file pentagohttpd.cpp is the all the code I wrote to implement the
webserver part. Once you've got it compiled, run pentagohttpd --help
to see the options, and try it out on your dev machine (assuming
you're running linux of course...). It wouldn't be hard to write a CGI
or FCGI version if that'd be better...

Timo

Lim Chee Aun

unread,
Dec 10, 2008, 10:08:25 AM12/10/08
to pent...@googlegroups.com

Wow, i totally have no idea how to run all that :D

Anyway, do you run the server on your own machine?

Fobax

unread,
Dec 10, 2008, 3:04:04 PM12/10/08
to Pentagoo


On Dec 10, 8:08 am, "Lim Chee Aun" <chee...@gmail.com> wrote:
I put some better instructions on the pentagod project homepage. If
you've got a linux machine, they shouldn't be too hard to follow.

The url I posted above is running on my server in a data center, but
when testing it I just ran it on my home linux machine.
I run it with the command: ./pentagohttpd -p 8000 -l ../pentagoo/ ,
which makes it listen on port 8000 and I have the pentagoo source next
to my pentagod source.

cheeaun

unread,
Dec 11, 2008, 7:13:25 AM12/11/08
to Pentagoo
Cool, but I was thinking how am I going to link to your AI, since I'm
not going to run it on my own server.

Fobax

unread,
Dec 12, 2008, 3:57:04 PM12/12/08
to Pentagoo
Why can't you run it as your own server?

The reason I ended up writing a static file server into it is because
of domain issues. The javascript didn't like accessing it from a
different domain. I don't know much about javascript's ajax security
model though, so if you can figure out how to make direct requests, go
for it. You could write a simple php script which proxies the request
for you I guess.

Would it be easier for you if I made it work as a CGI or FCGI process
instead of as a standalone server?

Lim Chee Aun

unread,
Dec 13, 2008, 9:16:54 AM12/13/08
to pent...@googlegroups.com
On Sat, Dec 13, 2008 at 4:57 AM, Fobax <ti...@ewalds.ca> wrote:
>
> On Dec 11, 5:13 am, cheeaun <chee...@gmail.com> wrote:
>> On Dec 11, 4:04 am, Fobax <t...@ewalds.ca> wrote:
>> Cool, but I was thinking how am I going to link to your AI, since I'm
>> not going to run it on my own server.
>
> Why can't you run it as your own server?

Because I have no idea how to. LOL.

> The reason I ended up writing a static file server into it is because
> of domain issues. The javascript didn't like accessing it from a
> different domain. I don't know much about javascript's ajax security
> model though, so if you can figure out how to make direct requests, go
> for it. You could write a simple php script which proxies the request
> for you I guess.

Ya, I'll probably write that.

> Would it be easier for you if I made it work as a CGI or FCGI process
> instead of as a standalone server?

Ya, i think so, but what are the difference?

Reply all
Reply to author
Forward
0 new messages