Thread: [Gtkboard-devel] help writing a game
Status: Beta
Brought to you by:
arvindn
|
From: nelson <gn...@ce...> - 2004-09-26 21:37:04
|
Hello :), Im writing a game for gtkboard, is an entertainment pencil and
paper game,Im firstly trying to write the Machine to Human type, but Im
a bit confused how to connect my machine-turn C code to the game_eval
and game_movegen hooks, you know, I have my own c algorithm for the
machine to choose its move from the existent board, but there is no an
easy hook where only put the position chosen by the Machine (that
position computed by a function of mine)...instead it seems gtkboard
forces me to use its functions for searching and calculating new
movements (game_eval and game_movegen), that sure are more powerful and
faster that my own but they are not well documented and I cant find out
how to use them. Questions about that:
- Is there an easy hook where to put the machine move computed by me
(avoiding game_eval and game_movegen)?
- What value Am I supposed to put on the float *eval argument?
- How Can I control the turn flow ?, because in my game a human can make
three moves in 3 clicks (3 events) and then pass the turn to the
machine,but it seems gtkboard passes the turn between human and machine
automatically after a one succesful move...
My game also will have levels of difficulty (machine thinking a bit
smarter).
Explaining of the game:
Initial Board:
X X X X X X X
X X X X X
X X X
Simple Rules:
Loose the one who removes the last piece.
In a turn, you can only remove pieces from one row, but you can remove
as many pieces as you want, for example the entire row.
PD: Thanks and sorry for the long text...
|
|
From: Arvind N. <ran...@gm...> - 2004-09-27 00:48:04
|
Hi! Well first of all its about a year since I worked on gtkboard, so I might not remember all the details right, but anyway... On 26 Sep 2004 23:37:23 +0100, nelson <gn...@ce...> wrote: > Hello :), Im writing a game for gtkboard, is an entertainment pencil and > paper game,Im firstly trying to write the Machine to Human type, but Im > a bit confused how to connect my machine-turn C code to the game_eval > and game_movegen hooks, you know, I have my own c algorithm for the > machine to choose its move from the existent board, but there is no an The game_eval and game_movegen functions assume that you want to do game tree evaluation (alpha-beta and generalizations thereof; see http://en.wikipedia.org/wiki/Alpha-beta_pruning in case you are not familiar with those algorithms). game_eval and game_movegen are hooks for the eval and movegen algorithms in minimax search. However, I think you're not using minimax, so you don't want to use those. There's a game_search function, which lets you search the position yourself and return the best move. If game_search is non-null, it will be called and minimax/alpha-beta will not be executed. > easy hook where only put the position chosen by the Machine (that > position computed by a function of mine)...instead it seems gtkboard > forces me to use its functions for searching and calculating new > movements (game_eval and game_movegen), that sure are more powerful and > faster that my own but they are not well documented and I cant find out > how to use them. Questions about that: > > - Is there an easy hook where to put the machine move computed by me > (avoiding game_eval and game_movegen)? > > - What value Am I supposed to put on the float *eval argument? > > - How Can I control the turn flow ?, because in my game a human can make > three moves in 3 clicks (3 events) and then pass the turn to the > machine,but it seems gtkboard passes the turn between human and machine > automatically after a one succesful move... Ah! As far as the program is concerned, when you complete one "move", the other player gets the turn. So you are supposed to pretend that a move has not been completed (by returning 0 in X_getmove() rather than 1) and still update the board on the screen. There's some ugly stuff like RENDER_* to do that, but not difficult. Lots of games do such things, such as mastermind. Feel free to ask me again if something was not clear. > My game also will have levels of difficulty (machine thinking a bit > smarter). > > Explaining of the game: > > Initial Board: > > X X X X X X X > X X X X X > X X X > > Simple Rules: > Loose the one who removes the last piece. > In a turn, you can only remove pieces from one row, but you can remove > as many pieces as you want, for example the entire row. In other words: Nim. Yes, you definitely don't want to use alpha-beta for that one :) Fascinating stuff though. I spent about two months reading up the Conway Berlekamp theory and I loved every bit of it. It would be nice to see some Nimlike games in gtkboard. Good luck Arvind > PD: Thanks and sorry for the long text... > > ------------------------------------------------------- > This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 > Project Admins to receive an Apple iPod Mini FREE for your judgement on > who ports your project to Linux PPC the best. Sponsored by IBM. > Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php > _______________________________________________ > Gtkboard-devel mailing list > Gtk...@li... > https://lists.sourceforge.net/lists/listinfo/gtkboard-devel > |
|
From: nelson <gn...@ce...> - 2004-09-27 17:28:01
|
El lun, 27-09-2004 a las 01:48, Arvind Narayanan escribi=F3: > Hi! >=20 > Well first of all its about a year since I worked on gtkboard, so I > might not remember all the details right, but anyway... >=20 > On 26 Sep 2004 23:37:23 +0100, nelson <gn...@ce...> wrote: > > Hello :), Im writing a game for gtkboard, is an entertainment pencil an= d > > paper game,Im firstly trying to write the Machine to Human type, but Im > > a bit confused how to connect my machine-turn C code to the game_eval > > and game_movegen hooks, you know, I have my own c algorithm for the > > machine to choose its move from the existent board, but there is no an >=20 > The game_eval and game_movegen functions assume that you want to do > game tree evaluation (alpha-beta and generalizations thereof; see > http://en.wikipedia.org/wiki/Alpha-beta_pruning in case you are not > familiar with those algorithms). game_eval and game_movegen are hooks > for the eval and movegen algorithms in minimax search. Yeah, wikipedia is great !, I could understand a bit more the game_eval and game_movegen trough the well explained concepts at wikipedia, people will find useful to begin looking at http://en.wikipedia.org/wiki/Game_tree > However, I think you're not using minimax, so you don't want to use > those. There's a game_search function, which lets you search the > position yourself and return the best move. If game_search is > non-null, it will be called and minimax/alpha-beta will not be > executed. Yes, that game_search is exactly what I wanted, I hadn't noticed it at the docs :). > > easy hook where only put the position chosen by the Machine (that > > position computed by a function of mine)...instead it seems gtkboard > > forces me to use its functions for searching and calculating new > > movements (game_eval and game_movegen), that sure are more powerful and > > faster that my own but they are not well documented and I cant find out > > how to use them. Questions about that: > >=20 > > - Is there an easy hook where to put the machine move computed by me > > (avoiding game_eval and game_movegen)? > >=20 > > - What value Am I supposed to put on the float *eval argument? > >=20 > > - How Can I control the turn flow ?, because in my game a human can mak= e > > three moves in 3 clicks (3 events) and then pass the turn to the > > machine,but it seems gtkboard passes the turn between human and machine > > automatically after a one succesful move... >=20 > Ah! As far as the program is concerned, when you complete one "move", > the other player gets the turn. So you are supposed to pretend that a > move has not been completed (by returning 0 in X_getmove() rather than > 1) and still update the board on the screen. There's some ugly stuff > like RENDER_* to do that, but not difficult. Lots of games do such > things, such as mastermind. >=20 Ok, I finally have this behaviour working with the RENDER thing, but I looked at the code of HIQ game, because I use game_event_handler and not game_getmove, and hiq has this behaviour pretty clear with the game_event_handler hook. > Feel free to ask me again if something was not clear. >=20 > > My game also will have levels of difficulty (machine thinking a bit > > smarter). > >=20 > > Explaining of the game: > >=20 > > Initial Board: > >=20 > > X X X X X X X > > X X X X X > > X X X > >=20 > > Simple Rules: > > Loose the one who removes the last piece. > > In a turn, you can only remove pieces from one row, but you can remove > > as many pieces as you want, for example the entire row. >=20 > In other words: Nim. Yes, you definitely don't want to use alpha-beta > for that one :) >=20 > Fascinating stuff though. I spent about two months reading up the > Conway Berlekamp theory and I loved every bit of it. It would be nice > to see some Nimlike games in gtkboard. >=20 Have a link to that theory, for curiosity?, what do you mean by nimlike games? you mean simple games like mine?.. > Good luck >=20 > Arvind Thank You, I think I could send you the game in next days because your answers solved my bigger problems :)... > > PD: Thanks and sorry for the long text... |