Slag - command line games

2 views
Skip to first unread message

Paul

unread,
Feb 11, 2009, 9:09:50 PM2/11/09
to Plasmacore
I have a GNU chess program that you can play over the command line. I
also have my own chess program, written in Slag. Would it be possible
to use System.execute() commands and some sort of reader to have the
two programs play against each other automatically?

I tried messing around a little with StdInReader, but whenever I call
read() the program crashes with an unsupported native method error.
Also I'm not sure the if the command I'm using to run the program,

System.execute( "cmd /C C:\\Program Files\\WinBoard-4.2.7\
\GNUChess.exe", false)

is actually working, since the program isn't showing up in my
processes list.

Thanks!

Abe

unread,
Feb 11, 2009, 9:49:44 PM2/11/09
to Plasmacore
The I/O would be hard to hook up for what you're wanting to do. Like
even getting a Plasmacore game that was launched from the command line
to print anything out to the command line is non-trivial. For similar
reasons StdInReader (used by Global.read_line) is only hooked up in
the command line version of Slag. All in all, I'd say hooking up the
I/O directly just isn't possible right now.

Two alternatives include writing moves to files and using network
sockets to communicate. If the GNU chess program doesn't already
include some sort of network support than that option is probably out.

What would be ideal is if the GNU program could read in a chess game
state from a file, make a move, and then write the state back out -
you could then add some parsing support for that file format to your
chess game.

Murphy

unread,
Feb 11, 2009, 11:17:43 PM2/11/09
to Plasmacore
Would "editbin /subsystem:console plasmacoreapp.exe" fix the problem
of being able to print back to the console from Plasmacore apps?

.. though I'm not sure how much that actually pertains to the question
at hand. Paul, your app is a plain slag program, right? No GUI?

I don't imagine you can do this from inside Slag itself, but you
should be able to write a pretty trivial Windows C program to do
this. I think you just have to create two pipes with CreatePipe()
(one is stdin on progA and stdout on progB, the other is the
reverse). Then you use CreateProcess() to launch the GNU program and
your program, specifying the pipes you just created for stdin and
stdout in the STARTUPINFO structure that you pass to it. This is
assuming that standard IO works fine from a plain Slag program (which
I assume it must!).

Also, if you don't see the process in the process list, it's probably
because it doesn't exist. In your case, this is probably because it's
trying to launch "C:\Program" as an executable. System.execute( "cmd /
C \"C:\\Program Files\\WinBoard-4.2.7\\GNUChess.exe\"", false) might
work better.

Abe

unread,
Feb 12, 2009, 8:26:10 AM2/12/09
to Plasmacore
Interesting trick with the editbin - I'll have to try that. The
problem though is that any Plasmacore output to stdout is currently
routed to be trace messages on the screen instead (e.g., they never
actually make it to system stdout). Paul's program IS gui-based, I
believe.

The alternate string literal form would make the quoting a little
easier:

System.execute( //cmd /C "C:\\Program Files\\WinBoard-4.2.7\
\GNUChess.exe"//, false)

Paul

unread,
Feb 12, 2009, 3:20:49 PM2/12/09
to Plasmacore
That's right, mine is GUI based. I'll have to look into what the GNU
program is set up to do (like networking, or read in a board from a
file). I was hoping that it would be more like an API where you can
have it return it's next move with a simple function call, but that
doesn't look to be the case.

It does seem like it would be possible to modify both programs a bit
to write their moves to a file, and have them read the moves of the
other program. I suppose on the Slag side, I could just have it try
to read the "opponent's move" file once every few seconds to see if
the move has change, and do the same for the GNU program.
> > > > Thanks!- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages