Re: Ways to maintain state in a CGI based card game
by tachyon (Chancellor) on Aug 31, 2001 at 17:24 UTC
|
All the usual suspects - hidden fields, hidden frames, cookies, session ID and serverside files or even store the data in the query string of the form action (like link parsing on a tiny scale)....
In my opinion games are better handled in JavaScript or as a Java applet than using CGI because of the time delay and ugly refresh inherent in the CGI process.
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
| [reply] |
|
Agreed. JavaScript or Java would be better suited for handling the game more quickly and in a more graphically pleasing fashion. I guess the stats I want to collect and my preference for Perl led me to a CGI solution. I could store information the game history in a JavaScript array or variable and then pass that along on game completion to a server side script for permanent storage and later analysis.
vroom | Tim Vroom | vroom@blockstackers.com
| [reply] |
|
Yes the question is often not "Could I do this in Perl?" but "Should I do this in Perl?" You can always do it in Perl! And you know once it is done you don't have hours of cross browser testing, tweaking, more testing, more tweaking, more testing..... to go :-)
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
| [reply] |
|
Re: Ways to maintain state in a CGI based card game
by dragonchild (Archbishop) on Aug 31, 2001 at 17:21 UTC
|
A really easy way would be to assign 2 bits to each attribute, giving you an 8-bit number for each card. Just like you do right now for PM, you could just pass around 16 numbers back and forth in the URL. That would maintain the state of the board.
Having not played the game (heard about it, though!), I don't know what else you would need to maintain knowledge of ....
------ We are the carpenters and bricklayers of the Information Age. Vote paco for President! | [reply] |
Re (tilly) 1: Ways to maintain state in a CGI based card game
by tilly (Archbishop) on Aug 31, 2001 at 19:00 UTC
|
You might want to take a look at japhy's Set, online. (He did it client-side though, not server-side.) | [reply] |
|
As tachyon was saying, about the perils of client side programming, this client side version of Set does not work in my copy IE 5.0. Javascript error
-Lee
"To be civilized is to deny one's nature."
| [reply] |
Re: Ways to maintain state in a CGI based card game
by princepawn (Parson) on Aug 31, 2001 at 18:34 UTC
|
well, the title says "CGI-base", but the post says "eventually Tk as well"... and this bringsup an fascinating point.
How to make portable sessioning code? because if you were in mod_perl, I'd say Apache::Session, but then outside of mod_perl, well I dont really know. The Stein/maceachern book on mod_perl lists a total of 6 ways of doing this, but I can't imagine any of them appplying to Tk... as state is usually resident within the single process that a Tk program runs in. | [reply] |
Re: Ways to maintain state in a CGI based card game
by perrin (Chancellor) on Aug 31, 2001 at 18:49 UTC
|
Storable/DB_Files are not only obvious - they're a good solution! However, you might want to try using MLDBM::Sync, which will take care of locking issues for you. You could also use one of the Cache::Cache modules. The one that uses a tree of files for storage is especially good for applications with many simultaneous users since it does separate locks for each entry. (Row-level locking!)
If this were a big commercial site, you would naturally want to use a RDBMS for reliability and scaling, but these simpler methods are easier and faster for a personal project site. | [reply] |
Re: Ways to maintain state in a CGI based card game
by suaveant (Parson) on Aug 31, 2001 at 18:16 UTC
|
Hehe, yeah, that is a cool game.
But you should make it PerlSet... and use
Camels, Llamas and Penguins for your shapes... :)
- Ant
- Some of my best work - Fish Dinner
| [reply] |
Re: Ways to maintain state in a CGI based card game
by synapse0 (Pilgrim) on Sep 01, 2001 at 02:58 UTC
|
Just another suggestion..
One thing you could possibly try is make the game itself in Java (and TK for a non-web based version) and have the game connect to a Perl server somewhere that does all the stats gathering/analysis. That way you can have both an online and offline version. The offline version could store the stats until it can connect and hand them over to the analysis server.
Anyways..
-Syn0 | [reply] |
Re: Ways to maintain state in a CGI based card game
by a (Friar) on Sep 02, 2001 at 08:37 UTC
|
Just to give a link:
http://dev.scriptics.com/software/plugin/match.html
is the tcl version (I believe) from long ago. Don't go there
unless you've got time, it is a maddeningly addictive game
and the tcl version is a thing of beautiful simplicity. Oh,
you'll need the tcl plugin for your browser though. ;->
a | [reply] |