 |
BoardSpace.net a place for board games
|
| View previous topic :: View next topic |
| Author |
Message |
nausher
Joined: 29 Mar 2008 Posts: 13
|
Posted: Mon Nov 16, 2009 2:54 am Post subject: Help with MovesSpec |
|
|
Hi All/Dave,
I am having some difficulty with MoveSpec & the OpCodes.
Firstly some Basic Questions,
If I understand correctly, PICKB & PICK differentiate "picking from the board" & "picking from the chip pool". Are DROPB & DROP similarly
Drop on Board & drop (back) into chip pool?
Also a High Level Question, would be What is the Sequence of events, as the MoveSpec is passed from the Client to the Server & back to the Opponents Client.
E.g. When I start dragging, I notice a PICK event, why should this be transmitted by PerformAndTransmit(). When I stop Dragging, the OpCode created is
DROP. What should I do with the first PICK OpCode if it doesn't make a difference to the Gameplay? |
|
| Back to top |
|
 |
nausher
Joined: 29 Mar 2008 Posts: 13
|
Posted: Mon Nov 16, 2009 2:57 am Post subject: |
|
|
PS: Does p0 indicate the player making the move?
If so why do I see it initially and also twice in the move
e.g. - edit: P0[pick n p0 p0] |
|
| Back to top |
|
 |
nausher
Joined: 29 Mar 2008 Posts: 13
|
Posted: Mon Nov 16, 2009 2:58 am Post subject: |
|
|
PPS: My really error seems to be the "Replay Digest
do not match".
The sample code for verifyGameRecord in the comment and Dave's comments indicate something is wrong with something else (and I believe its the MoveSpec), but any quick idea on what could be the cause?
== Exception ==
in game main loop java.lang.Error: Replay digest matches{LastParsed: dropb E D 6 C 6}
java.lang.Error: Replay digest matches |
|
| Back to top |
|
 |
nausher
Joined: 29 Mar 2008 Posts: 13
|
Posted: Mon Nov 16, 2009 3:04 am Post subject: |
|
|
PPS: (last of these)
Why the following -
case MOVE_PICK:
if((state!=PUZZLE_STATE) && (m.op==MOVE_DROPB))
{ UndoHistoryElement(idx); idx=-1; }
i.e. Why remove history when we are dropping a piece onto the board,
we picked it from the chip pool, so it is legit right? |
|
| Back to top |
|
 |
nausher
Joined: 29 Mar 2008 Posts: 13
|
Posted: Mon Nov 16, 2009 3:18 am Post subject: |
|
|
Looking at the Stack Trace found out, the Sequence that is modifying the
History -
TaijiGameViewer.EditHistory(commonMove) line: 846
TaijiGameViewer(commonCanvas).AddToHistory(commonMove) line: not available
TaijiGameViewer(commonCanvas).PerformAndTransmit(commonMove, boolean, boolean) line: not available
TaijiGameViewer(commonCanvas).PerformAndTransmit(String, boolean, boolean) line: not available
TaijiGameViewer(commonCanvas).PerformAndTransmit(String) line: not available
TaijiGameViewer.doDropChip(char, int) line: 975
TaijiGameViewer.StopDragging(HitPoint) line: 1030 |
|
| Back to top |
|
 |
nausher
Joined: 29 Mar 2008 Posts: 13
|
Posted: Mon Nov 16, 2009 3:21 am Post subject: |
|
|
On hindsight, looks like this is because DONE operation is considered.
I do not have a "DONE" button in the Play mode.
Any idea where I have gone wrong? |
|
| Back to top |
|
 |
nausher
Joined: 29 Mar 2008 Posts: 13
|
Posted: Mon Nov 16, 2009 4:40 am Post subject: |
|
|
"Start" is not getting processed in the parse method into the MOVE_START OpCode.
Even though I add the set of standard moves into the Dictionary D-
static
{
// these int values must be unique in the dictionary
addStandardMoves(D);
D.putInt("Pick", MOVE_PICK);
D.putInt("Pickb", MOVE_PICKB);
D.putInt("Drop", MOVE_DROP);
D.putInt("Dropb", MOVE_DROPB);
D.putInt("L", White_Chip_Pool); // L - Light/White Chip Pool
D.putInt("D", Black_Chip_Pool); // D - Dark/Black Chip Pool
D.putInt("N", North_Chip_Pool);
D.putInt("E", East_Chip_Pool);
D.putInt("W", West_Chip_Pool);
D.putInt("S", South_Chip_Pool);
} |
|
| Back to top |
|
 |
nausher
Joined: 29 Mar 2008 Posts: 13
|
Posted: Mon Nov 16, 2009 4:53 am Post subject: |
|
|
Thought the cause was the UpperCase "Start" changing it to "start"
doesn't seem to help either -
Even after clicking "Start player", keep seeing Ops being picked up as
edit
key 0.0.0.0 x true
adding key "Show Raw Text"
adding key "create two largest contiguous areas of your color"
Remove P0[0 edit]
edit: P0[pick n p0 p0] deleted
in game main loop java.util.NoSuchElementException{LastParsed: Drop N}
Remove P0[1 dropb N G 4 G 3]
edit: P0[reset] deleted
in game main loop java.lang.Error: Replay digest matches{LastParsed: Reset} |
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Mar 2005 Posts: 689
|
Posted: Mon Nov 16, 2009 7:00 am Post subject: Re: Help with MovesSpec |
|
|
| nausher wrote: |
Hi All/Dave,
I am having some difficulty with MoveSpec & the OpCodes.
Firstly some Basic Questions,
If I understand correctly, PICKB & PICK differentiate "picking from the board" & "picking from the chip pool". Are DROPB & DROP similarly
Drop on Board & drop (back) into chip pool?
|
Yes, but keep in mind that this is purely a matter of convention and convenience - you're free to designate your moves and gestures any way you see fit.
| nausher wrote: |
Also a High Level Question, would be What is the Sequence of events, as the MoveSpec is passed from the Client to the Server & back to the Opponents Client.
E.g. When I start dragging, I notice a PICK event, why should this be transmitted by PerformAndTransmit(). When I stop Dragging, the OpCode created is
DROP. What should I do with the first PICK OpCode if it doesn't make a difference to the Gameplay? |
The general rule is that all the events you feed to your local board are also transmitted to remote clients, so their view of the world remains the same as yours. If pick events are completely redundant, you could skip them entirely. The main point at which this becomes important is handling the piece that is being moved. If you are picking from an inexhaustible supply (bowl of stones) then it may be easy to dispense with the pick events. OTOH, if it's a specific object being picked up, (so it should disappear from it's resting place) the simplest way to inform the other clients is via a pick event.
This is somewhat obfuscated because the transmission of mouse position among clients, which is done by the game framework, also includes the identity of "the moving object", whatever that means, but usually it means the object that was picked up but not yet dropped.
My usual practice for simple games is that the board space includes "pickedObject" and "pickedSource", as well as eventually "droppedDest".
These are handy for the viewer to use to annotate the game board, and also handy for resetting the board state back to the start of the move. Games with more complicated, multipart moves have a stack of sources and destinations. |
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Mar 2005 Posts: 689
|
Posted: Mon Nov 16, 2009 7:13 am Post subject: |
|
|
| nausher wrote: |
PPS: (last of these)
Why the following -
case MOVE_PICK:
if((state!=PUZZLE_STATE) && (m.op==MOVE_DROPB))
{ UndoHistoryElement(idx); idx=-1; }
i.e. Why remove history when we are dropping a piece onto the board,
we picked it from the chip pool, so it is legit right? |
This is quite specific to the gestures you can make the boardspace
Hex board, where you don't have to "pick" at all, just click on the
board. But you're allowed to pick if it makes you feel good.
This clause handles the case where you click on the board during
a game, which places a stone, then go back to the bowl and pick
up another stone. The way the board handles this is to remove
the stone you placed on the board, leaving the stone "in your hand"
so the history has to be edited accordingly.
This could also have been handled by not allowing the "pick" action when you've already placed a stone on the board.
The main thing is to allow only legal moves to be made, and secondarily, I prefer not to dictate the sequence of gestures unnecessarily. For hex, picking and dropping stones from the bowl is optional and can be mixed in unusual ways with placing stones by simply clicking on the board. For more complex games with multiple objects that can be picked up and moved around, the "pickup" gesture would probably not be optional. |
|
| Back to top |
|
 |
nausher
Joined: 29 Mar 2008 Posts: 13
|
Posted: Mon Nov 16, 2009 7:14 am Post subject: |
|
|
Thanks Dave,
I don't see the DONE button on my board.
I Checked that the DoneState() method returns true.
I am wondering, what could possibly be the reason.
Any tips on where to try debugging this? |
|
| Back to top |
|
 |
nausher
Joined: 29 Mar 2008 Posts: 13
|
Posted: Mon Nov 16, 2009 7:19 am Post subject: |
|
|
Got it, the Done button was hidden behind the Chat controls.
Silly me! |
|
| Back to top |
|
 |
nausher
Joined: 29 Mar 2008 Posts: 13
|
Posted: Mon Nov 16, 2009 7:22 am Post subject: |
|
|
OTOH I still keep seeing the "Replay Digests matches" error.
This sounds very mathematical. What should I be looking at?
== Exception Log ==
Error: in game main loop java.lang.Error: Replay digest matches{LastParsed: dropb N E 5 E 4}java.lang.Error: Replay digest matches
Error: in game main loop java.lang.Error: Replay digest matches{LastParsed: Done}java.lang.Error: Replay digest matches
Error: in game main loop java.lang.Error: not expected{LastParsed: Pick W}java.lang.Error: not expected
Error: in game main loop java.lang.Error: Replay digest matches{LastParsed: dropb W C 5 D 5}java.lang.Error: Replay digest matches
Error: in game main loop java.lang.Error: Replay digest matches{LastParsed: Done}java.lang.Error: Replay digest matches
Error: in game main loop java.lang.Error: not expected{LastParsed: Pick N}java.lang.Error: not expected
Error: in game main loop java.lang.Error: Replay digest matches{LastParsed: Drop N}java.lang.Error: Replay digest matches
Error: in game main loop java.lang.Error: Replay digest matches{LastParsed: Pick E}java.lang.Error: Replay digest matches
Error: in game main loop java.lang.Error: Replay digest matches{LastParsed: dropb E E 6 D 6}java.lang.Error: Replay digest matches |
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Mar 2005 Posts: 689
|
Posted: Mon Nov 16, 2009 7:25 am Post subject: general notes. |
|
|
The general concept is that moves passed to the board cause it to change state, and all clients need to see the same sequence of events. The discipline of using only PerformAndTransmit to change the state of your board helps.
The purpose of "edithistory" is to keep a tidy, minimal view of the events in the game. Real players are allowed to pick up and move pieces, then pick the same pieces up and move them back, or (in most of the current games) click off the board to effect a "reset" back to the start of the move. To a first order approximation, if your "edithistory" method did nothing, it would be correct, but would leave a messy history.
The errors detected by the "verifyGameRecord" process are where replaying the history doesn't result in the same state of the board, which could be either an error in editing the history, or an inconsistency in the board's state caused by other bugs. Generally speaking, it should always be possible to hit the << and then the >> button, and continue. verifyGameRecord tries to test continuously that it's true. |
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Mar 2005 Posts: 689
|
Posted: Mon Nov 16, 2009 7:37 am Post subject: |
|
|
| nausher wrote: |
"Start" is not getting processed in the parse method into the MOVE_START OpCode.
Even though I add the set of standard moves into the Dictionary D-
static
{
// these int values must be unique in the dictionary
addStandardMoves(D);
D.putInt("Pick", MOVE_PICK);
D.putInt("Pickb", MOVE_PICKB);
D.putInt("Drop", MOVE_DROP);
D.putInt("Dropb", MOVE_DROPB);
D.putInt("L", White_Chip_Pool); // L - Light/White Chip Pool
D.putInt("D", Black_Chip_Pool); // D - Dark/Black Chip Pool
D.putInt("N", North_Chip_Pool);
D.putInt("E", East_Chip_Pool);
D.putInt("W", West_Chip_Pool);
D.putInt("S", South_Chip_Pool);
} |
This is just loading the dictionary with words in your game's move language, you still have to parse everything yourself. For simplicity, the customary parsing method uses StringTokenizer and nextToken as the primary engines. The parsing process is generally not very strict or especially robust, since it will only have to parse strings produced by it's own printer and your friendly viewer. As a check on the parsing/printing process, it's repeated, so what really gets used is parse(print(parse(foo"))
In the hex sample, "start" is handled by this
case MOVE_START:
op = opcode;
player = D.getInt(msg.nextToken());
which assumes that the next token after "start" will be something from the dictionary that corresponds to a player number. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|