Arimaa Forum (http://arimaa.com/arimaa/forum/cgi/YaBB.cgi)
Arimaa >> General Discussion >> Standalone gameroom client -- what, why, how?
(Message started by: leo on Dec 31st, 2007, 2:28am)

Title: Standalone gameroom client -- what, why, how?
Post by leo on Dec 31st, 2007, 2:28am
Lost in the dark depths of the bot developer section of the forum there are a few discussions about making a standalone client application for playing in the gameroom of the arimaa.com server. I think this should be discussed here in the general section because it concerns mostly human players, not bots.

What is a standalone gameroom client?

It's a program installed on your computer, through which you can play in the gameroom without you needing to run your web browser.

Why have a standalone gameroom client?

Some people have problems running the web applets to play in the gameroom. A standalone client would stay away from the compatibility struggles that rage on the web.

Loading the web applets can take time on slow connections. I'm not sure whether the web browsers are allowed to conserve them in their cache. A standalone client would start instantly on your computer.

All these downloads are a big load on the server. A standalone client would only need to exchange move updates and a few other data about the state of the gameroom - who logged in and out, are there new games open to sit at or ongoing to watch, etc.

The standalone client would allow you to save your games directly onto your local drive, and watch them even if you are offline.

How to make this standalone client?

There seems to be many software developers among the Arimaa community, starting with Omar Syed himself.

One obvious choice is to compile the currently existing Flash client as a standalone application, but I'm not sure this is possible for all platforms. It would require adding some more functionalities that are currently taken care of by the web page, not the Flash applet.

Some people have started several projects mentioned here and there in the bot developer section. All use different cross-platform frameworks and languages and it will be hard to get everybody to work together, but I started this thread in the hope this is possible. :P

This thread is also for everybody to share their opinions about what functionalities the standalone client should offer, or whether it would be a huge time waster that would never be up and running. ;)

And I wish a happy new year to everybody and a lot of fun for the participants of the World Championship.

Title: Re: Standalone gameroom client -- what, why, how?
Post by leo on Dec 31st, 2007, 3:17am
Pheeew, here I finally digged up all the links I could find to the forum threads:

* by monste9, in Ruby (http://arimaa.com/arimaa/forum/cgi/YaBB.cgi?board=talk;action=display;num=1168437452) (I guess monste9 is Froody, from our yesterday chat about the standalone client)

* by corsix, in C++/Lua (http://arimaa.com/arimaa/forum/cgi/YaBB.cgi?board=devTalk;action=display;num=1194476232)

* by Libor, in C#/.NET (http://arimaa.com/arimaa/forum/cgi/YaBB.cgi?board=devTalk;action=display;num=1156209643)

* by borg, in Java (http://arimaa.com/arimaa/forum/cgi/YaBB.cgi?board=talk;action=display;num=1141702902)

And useful technical stuff is here:

http://arimaa.com/arimaa/protocol/

http://arimaa.com/arimaa/jsClient/specs/

http://arimaa.com/arimaa/download/

http://arimaa.com/arimaa/graphics/

Title: Re: Standalone gameroom client -- what, why, how?
Post by omar on Jan 2nd, 2008, 1:29am
Thanks for digging up these links Leo.

I like that a stand alone client would provide the ability to save/load games locally. Having to install some software is probably the biggest negative. Also getting the software to work across the major platforms would be a challenge.


Title: Re: Standalone gameroom client -- what, why, how?
Post by froody on Jan 8th, 2008, 12:53am
Yep, the client based on RubyGo is my project. I'll try to do some work on it soon. I'd like to get it displaying my postal games but I'm still not clear about the protocol. Using 'action=mygames' the server returns a list of my games that look like this:
7=opponent=arimaa_master%13timecontrol=1d/14d/100/14d/0%13createdts=1198359710%13postal=1%13role=w%13rated=1%13gid=79914%13

But how do I get the board position of that postal game?

Title: Re: Standalone gameroom client -- what, why, how?
Post by leo on Jan 8th, 2008, 8:24am
I suppose you retrieve the game ID for the game you want to display, then you feed this ID into the gamestate call (see toward the middle of the protocol page) which sends you the information you need. I think your client should take the complete move list, not just the board position, in order to check for repetitions.

Title: Re: Standalone gameroom client -- what, why, how?
Post by froody on Jan 8th, 2008, 3:53pm
How do I get the gsurl and tid of a postal game that is already in progress? The only actions that return this are creategame and reserveseat.

Title: Re: Standalone gameroom client -- what, why, how?
Post by leo on Jan 8th, 2008, 4:39pm
You are right, there is something unclear in the protocol.

I first misread that the gid was required for sitting at an ongoing game or retrieving its state, but it is not the case.

I don't understand how one can select an ongoing game.

I hope Omar can find time to clear this up for us.

Title: Re: Standalone gameroom client -- what, why, how?
Post by omar on Jan 12th, 2008, 4:44pm
Good question. Actually my documentation for 'Reserve Seat' part was not right. You can specify role='v' if you want to get the gsurl and tid for just viewing a game. I've updated the protocol documentation. Thanks for noticing this froody.

Title: Re: Standalone gameroom client -- what, why, how?e
Post by froody on Jan 18th, 2008, 10:42pm
I did some work on RubyArimaa today. It can now retrieve and view postal games.

It should work on all platforms. To run it you'll need Ruby and Tk installed.

zip:

http://phm.36bit.com/RubyArimaa_0_14_1.zip

tar.gz:

http://phm.36bit.com/RubyArimaa-0.14.1.tar.gz

screenshot:

http://phm.36bit.com/RubyArimaa.jpg

Click the horse-camel button to connect to the server. The 'list' command in the console should display all your current games. Then typing 'open [game number]' will open a window displaying the game. You can move the pieces around but that's all. The elephant-dog button allows you to open a game file and step through a game using the '>' button.

Next thing to do is checking for legal moves and animating the steps.


To answer your questions (from April 07), Camelback:

Yes, you're welcome to help. No, I haven't setup a Rubyforge project yet. I will do so if more people are working on the project. No, you don't need to know anything about go. Ruby and Tk experience is useful though. Using the go client as a base is nice because a lot of code is similar.


Leo: Ruby is a wonderful language, and very easy/fun to learn. Hope you take a look at it.

I'd also like to write some bot stuff in Ruby, too. I'll write some utility code for manipulating the board, etc, then anyone that knows a bit of ruby will be able to quickly put together their own bot and experiment with different ideas.

This book is very entertaining if you want to learn ruby:

http://poignantguide.net/ruby/




Title: Re: Standalone gameroom client -- what, why, how?
Post by leo on Jan 19th, 2008, 3:39am
I tried it and it worked although I was getting a lot of Tcl/Tk script error popups. Adapting an application can be trickier than devising one from scratch, but I'll try to understand how the Ruby source works, especially the nchess6.rb file which you modified to encode Arimaa game state.

But errr... Ruby looks as cryptic as any other programming language - I don't buy the hype. :P

For the 'learn to play better' item of the TODO list I can't help but you seem to be doing fine. ;)

Title: Re: Standalone gameroom client -- what, why, how?
Post by froody on Jan 30th, 2008, 4:16pm
http://phm.36bit.com/RubyArimaa_0_14_5.zip

New version. Quite a lot of changes. I'd really like to know which platforms it will run on. Should work on everything but I only test on ubuntu linux. Follow the install instructions from http://rubygo.rubyforge.org/

Click the elephant and dog button to play out a human vs human game. Right click flips the board. Does all the game logic work as it should? (pushing/pulling/freezing/trapping)


Press 'done' to end the turn. 'undo' will undo the step.

Title: Re: Standalone gameroom client -- what, why, how?
Post by froody on Feb 3rd, 2008, 5:28pm
Wheeee. Just sent my first move to the gameroom using RubyArimaa.

Title: Re: Standalone gameroom client -- what, why, how?
Post by camelback on Feb 3rd, 2008, 7:12pm
Congrats froody!, great job looking forward to use it.

Title: Re: Standalone gameroom client -- what, why, how?
Post by The_Jeh on Feb 3rd, 2008, 7:41pm
I'm using Windows XP, and I get the error message having to do with the method 'create' being undefined. Fritzlein, I heard you might have overcome similar difficulties. If so, please fill me in.

Title: Re: Standalone gameroom client -- what, why, how?
Post by froody on Feb 3rd, 2008, 9:07pm
I'm not sure if it was Fritzlein, but I seem to remember someone who tested it had the same error. I just realized that the way I'm making the image objects is different to how RubyGo works, so I might change it to be like RubyGo. But you tried RubyGo and that didn't work either? You can't play a human vs human go game? Does the board draw in RubyArimaa if you skip the error message? Does the board draw in RubyGo?

Title: Re: Standalone gameroom client -- what, why, how?
Post by The_Jeh on Feb 3rd, 2008, 9:25pm
The board does draw in RubyArimaa. It's just the pieces that don't appear.  RubyGo is not working any more; I have no idea why. But, I never was able to get a board to draw in it.

By the way, in the shell window that appears, it says:
user defaults not found
user entries loaded

And, the Stack Trace of the error message that always appears when I click the Elephant/Dog button is:

C:/Documents and Settings/JEH24698/Desktop/arimuby/lib/arimaa.rb:73:in `initialize': undefined method `create' for TkcImage:Class
   while executing
"rb_out c00021"
   invoked from within
".w00003.w00006.w00011 invoke"
   ("uplevel" body line 1)
   invoked from within
"uplevel #0 [list $w invoke]"
   (procedure "tkButtonUp" line 9)
   invoked from within
"tkButtonUp .w00003.w00006.w00011
"
   (command bound to event)

Title: Re: Standalone gameroom client -- what, why, how?
Post by camelback on Feb 3rd, 2008, 9:44pm
I'm using XP and its working great when playing human vs human games. I'm using ruby 1.8.6

Title: Re: Standalone gameroom client -- what, why, how?
Post by The_Jeh on Feb 3rd, 2008, 10:31pm
When I use Ruby 1.8.6 instead of 1.8.0, I can't open anything at all. I think it's just the nature of my computer.

Title: Re: Standalone gameroom client -- what, why, how?
Post by froody on Feb 3rd, 2008, 11:30pm

I changed the way the images are made, because it seemed like The Right Thing to do. As a bonus the pesky 'create' method is no longer used. See if this works:

http://phm.36bit.com/RubyArimaa_0_15_0.zip

I expect it will work for The_Jeh now, but be broken for everyone else! Oh well. It runs on my Linux machine.

Title: Re: Standalone gameroom client -- what, why, how?
Post by The_Jeh on Feb 4th, 2008, 9:42am
You're almost there! I can now set up the pieces at the beginning. (It still only opens in Ruby 1.8.0). But then, after all the pieces are set up, I get barraged with another error message, the Stack Trace of which is:

C:/Documents and Settings/JEH24698/Desktop/RubyArimaa/lib/arimaa.rb:359:in `tick': undefined method `create' for TkcImage:Class
   while executing
"rb_out c00132 2400 ?? 2118386688 0 ?? -1 0 i 2118386688 NotifyNormal 0 PlaceOnTop 8 763109 0 394 432 ?? 460 2118386688 0 ?? 0 0x0 0x0 6 .w00014.w00015..."
   (command bound to event)


Also, in the shell window that opens, this text is repeated over and over:

bgerror failed to handle background error.
    Original error: C:/Documents and Settings/JEH24698/Desktop/RubyArimaa/lib/arimaa.rb:in 'tick': undefined method 'create' for TkcImage:Class
    Error in bgerror: invoked "break" outside of a loop

Title: Re: Standalone gameroom client -- what, why, how?
Post by froody on Feb 4th, 2008, 9:58am

Ah. Good. I forgot to change the way the 'tick' image is created. This will be fixed shortly.

Thx for the feedback.

Title: Re: Standalone gameroom client -- what, why, how?
Post by froody on Feb 4th, 2008, 12:32pm

Got rid of all the 'create' calls and fixed the push/pull bug.

http://phm.36bit.com/RubyArimaa_0_15_1.zip

I'll probably post a link whenever I change something so people can try it out whenever they feel like it. All feedback/bug reports/suggestions welcome. If you're posting a bug report please include the version of RubyArimaa you've got, your OS and Ruby set-up and the traceback details for the error.

At the moment 0_15_1 can only play a local human vs human game, so if you're testing just make sure all the game logic works and nothing weird happens. Thanks.

btw, The_Jeh, what happens when you try to run with Ruby1.8.6? (It shouldn't make any difference.)

Title: Re: Standalone gameroom client -- what, why, how?
Post by The_Jeh on Feb 4th, 2008, 4:09pm
As far as game logic goes:
1. I can push or pull a piece without moving my own piece.
2. I can push a piece using a frozen piece.
3. I can move my rabbits backwards.
4. I can make a move that doesn't change the position, including taking zero steps.
5. I can set up gold pieces on the silver side, resulting in gold having more than eight rabbits, and silver having fewer.

Also, it is proper notation to place an x at the end of the step for a capture. For example, Rf6x means a gold rabbit is captured in the f6 trap. It also would be good to include the move number at the beginning.

In addition, I get an error message about an undefined method '+' when I tinker with the navigation bar. Or when I press the up arrow key, I get an undefined method 'var_prev' and when I press down, an undefined method 'var_next'.


As far as Ruby 1.8.6, when I tried it before, a shell window appears for a split second and then disappears.

I think the command prompt output would be similar to:
C:\Documents and Settings\JEH24698\Desktop\RubyArimaa_0_15_1\RubyArimaa\bin>ruby ..\lib\go.rb
'ruby' is not recognized as an internal or external command, operable probram or batch file.

I know this because on occasion, RubyArimaa won't open, and this is the command prompt output.

Title: Re: Standalone gameroom client -- what, why, how?
Post by leo on Feb 4th, 2008, 7:25pm
Hi Froody, I had another look into the file arimaa.rb but I haven't got a good grasp of it yet, partly because ruby is a foreign language for me, partly because your coding style leaves me a bit confused. For the moment I can only try to explain briefly how I do the game logic in my programs, in the hope it can help you.

First thing, I think you should separate totally the interface from the game logic. It will make the code easier to maintain, and it will make it much easier for you to export and adapt the game logic into your AI projects.

Then, here is a pseudo-code of the algorithm I use for checking legal steps. There exist many different ways to do it, so I present it only as an illustration and something to chew on.

EDIT: For just listing the legal steps of the moment you can change the first line to "for each piece of the current player". I've mixed in stuff I use for other parts of the game. END EDIT

For each piece of both players:

---- Check the neighborhood and mark the piece as free/frozen, accompanied/alone

If this is not step 1 of the move:

---- If the previous step was marked as the first of a push:

-------- Look around the now empty square for free stronger opp. pieces
-------- that can complete the push, and mark those steps.

-------- RETURN.

---- If the previous step was not the second of a push or a pull:

-------- Look around the origin square of the last step for any weaker
-------- opponent pieces that could be pulled, and mark those steps.

For each free piece of the current player:

---- Look around for empty squares and mark those steps,
---- minding that rabbits can't go backward.

If this is not step 4 of the move:

---- For each piece of the opponent player:

-------- If there is at least one free stronger neighbor of the current color:

------------ For each empty square into which the piece can be pushed:

---------------- IF THE STEP WAS NOT MARKED AS THE SECOND OF A PULL
---------------- earlier in the algorithm:

-------------------- Mark it as the first of a push.


Later on, but not in the same procedure in order not to clutter the code, there are more checks to perform: If the count of legal steps is zero and we are at step 1, the player is immobilized.

My actual code is not exactly like that because it uses bitmasks to pack data about legal steps and board states, and the marking is more intricated, but it's the general idea. I hope there are not too many errors -- it's late in the night.


If you prefer checking if a step is legal on the fly instead of surveying the board before, things are different of course. First check if a push has to be completed, in which case see if the submitted step does the job. If there is no push to be completed and the submitted step moves an opponent piece, check if it can be pulled before checking if it can be pushed, and ensure it is not pulled by a piece that just finished a push. Etc.

Title: Re: Standalone gameroom client -- what, why, how?
Post by The_Jeh on Feb 5th, 2008, 12:32am
I just want to make sure that I don't come off as harshly critical. I pointed out the problems because I know they are useful for you to know. Otherwise, it is obvious that your client is off to a great start.

Title: Re: Standalone gameroom client -- what, why, how?
Post by leo on Feb 5th, 2008, 1:48am

on 02/05/08 at 00:32:00, The_Jeh wrote:
I just want to make sure that I don't come off as harshly critical. I pointed out the problems because I know they are useful for you to know. Otherwise, it is obvious that your client is off to a great start.


I wish to say the same. The forum doesn't reflect the cheerful atmosphere of the chatroom discussions about RubyArimaa.

Froody, I edited my post to modify a point. I also want to add that surveying the board between each step to mark all legal steps can speed up the interface when it comes to pop up the arrows around a piece the mouse pointer is hovering. But it's even more useful for doing statistics about the board state.

EDIT: I've just downloaded and run RubyGo, on which you based RubyArimaa, and I get the same kind of errors as well as the console window in the way, so these bugs were already present in the project. I can't get the goban to appear inside the window, and no way to start a game.

It seems it's been a while Rubygo hasn't been updated or debugged, and maybe it's not too late to restart on a more solid base such as RubyGame: http://rubygame.sourceforge.net/ which is a library devised for multimedia on ruby. But I'm a complete noob ruby-wise, so this is just the word of someone afraid of jumping into a new language among a tentacular project that does weird things on my the screen. ;)

EDIT 2: Even weirder, when I run RubyGo and try to open a file, the dialog box behaves slowly and weirdly and instead of filtering SGF files, it wants ari files.... Does it come from the fact that Tcltk mixes the two programs? :( RubyGame uses the SDL, I dont know how it compares to tcltk. Would it be possible to program in ruby without the need of external stuff?

Title: Re: Standalone gameroom client -- what, why, how?
Post by froody on Feb 5th, 2008, 2:11pm
:)

Don't worry about sounding critical. Thorough bug reports are great.

I'll probably change the way RubyArimaa does the game logic. Thinking about it the code will be easier to understand doing it the way Leo recommends. (Thanks for the algorithm, leo.)

I didn't change the name of the user files directory. So remove .rubygo in your home directory before running RubyGo. (When you run the program from the command line it prints the path of the user files dir)


My plan is to spend a bit more time on RubyArimaa and see what happens. I'm confident that it's not that far off from being a usable Arimaa client. If people want to discuss starting another project from the ground up, I'd be happy to join in on that, too. I suppose the first question is which GUI framework to use?

"The main target platform for Rubygame is Linux". Surely many more people will want to run the arimaa client from windows than from linux, so is Rubygame a good idea? Tcl/Tk is far from perfect but it does run pretty well on both win and linux. What alternatives are there? Fox? wxwindows? What's the stuff you've written like, leo? Could it be used as the base for a full client?


Title: Re: Standalone gameroom client -- what, why, how?
Post by froody on Feb 5th, 2008, 7:25pm

on 02/05/08 at 01:48:57, leo wrote:
Would it be possible to program in ruby without the need of external stuff?


Text based client? I did think about that. You could set up a chess board on your desk and just type in the move :)

Title: Re: Standalone gameroom client -- what, why, how?
Post by leo on Feb 6th, 2008, 7:02am

on 02/05/08 at 19:25:33, froody wrote:
Text based client? I did think about that. You could set up a chess board on your desk and just type in the move :)


Like on Mindsports Arena? Or even gnaw the phone wires to send bits directly to the server. Requires training :P

Anyway a client console would be a much needed debugging tool. We could knock one in a few lines in Rebol or Javascript. Maybe it would be great to have a sandbox area in the gameroom to avoid messing with the games?


on 02/05/08 at 14:11:47, froody wrote:
"The main target platform for Rubygame is Linux". Surely many more people will want to run the arimaa client from windows than from linux, so is Rubygame a good idea? Tcl/Tk is far from perfect but it does run pretty well on both win and linux. What alternatives are there? Fox? wxwindows? What's the stuff you've written like, leo? Could it be used as the base for a full client?


The SDL can do OpenGL, but for mere 2D it uses the old GDI (not GDI+) on Windows, which is indeed bad (no PNG transparency nor good image resampling).

The first program I made was on OpenGL, to be able to rotate the board in 3D like a molecule model - to study symmetries. But the pieces were dry polygons. Then I did another on the GDI, then the latest one on the GDI+. Everything in C++ and probably a bit too much Windows dependent although I took some care to separate the parts of the latest one (AI, game, lightweight graphics wrapper, interface).

But C++ is a hassle, which I use mostly because of my industrial background, and I don't think it's a good ground for cross-platform projects - it would require a ton of duplicate source, or long braids of precompiler conditionals. The most I know of Unix/Linux programming is a bit of X11 graphics and event handling in pure C...

Ruby looks fine to me, and you are the one with most enthusiam, so it's all normal you choose the tools.

Title: Re: Standalone gameroom client -- what, why, how?
Post by omar on Feb 8th, 2008, 1:01am

on 02/05/08 at 14:11:47, froody wrote:
If people want to discuss starting another project from the ground up, I'd be happy to join in on that, too. I suppose the first question is which GUI framework to use?


If it was done using Adobe Flex, we would be able to use the code I've already developed for the new Flash client.

http://www.adobe.com/products/flex/


Title: Re: Standalone gameroom client -- what, why, how?
Post by froody on Feb 24th, 2008, 2:34pm

http://phm.36bit.com/RubyArimaa_0_15_2.zip

Any problems with the local human vs human game? (Elephant/Dog button)



Arimaa Forum » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB © 2000-2003. All Rights Reserved.