Forums: Volity programming with Perl
Discussion about creating Volity game parlors and bots with Perl.
Dealing with the "four sadnesses" in a Bot
Back to topics list
|
[post:54#97]
|
I'm going to detail the steps I had to undertake to make my bots and referee for hearts deal with the four sadnesses (http://www.volity.or Observation: Make sure that whenever you access some information that only a seated player would have (like $self->seat_id) you enclose it in an <code>if ($self->am_seated)</code> or equivalent block. Having a bot join an already started game:
Sharing a seat: Not really an issue for a bot, more of a UI thing. Suspend and resume will be tackled in another post, yet to come. |
|
[post:54#100]
|
The bot wants to have a couple of functions defined for the state-recovery burst. I'm pretty sure they contain data that's uninteresting at the high level of "how to play the game," but that's required in the lower levels of the bot machinery.
|
|
[post:54#101]
|
*sigh* I screwed the names of the first two of those functions up. They should be: volity_rpc_seat_list |
|
[post:54#103]
|
A side note, somewhat unrelated to this topic (though it was causing ref crashes in my suspend/resume code) is that attempting to send a seat object as opposed to a seat id in an RPC is a very bad idea. Faked-up example follows:
You'll find that your ref absolutely baloons with memory, brings your machine to its knees by eating all available swap, and then gets killed by the OS. Seat is apparently a recursive data structure... |
|
[post:54#104]
|
It is worth filing this as a feature request -- the ability to include seat objects, player objects, and (perhaps) game-specific objects in call_ui_function(). I threw it into the Python referee framework, and it's been handy. |
|
[post:54#105]
|
Suspend and resume turn out to be easy, as long as the ref has a properly implemented send_game_state_to_p The function below does it (unless I'm forgetting something else I've done). This was shamelessly ripped from a piece of example code.
Incidentally, something very similar can be done in the UI file too. The trick is just rpc("volity.send_sta |
| Before you can post to this forum, you must log in. | |
