| Author |
Message |
Greg Schmidt (Gschmidt)
| | Posted on Friday, April 15, 2005 - 11:09 am: | |
According to Jens Markmann's page at http://home.t-online.de/home/j_markmann/zrf.html "Flags (set-flag ...) are global. Be sure to use unique flag names in your script so you won't mix them up." Yet according to the Zillions help file: "Flags are intended to be used only within a move generation block, rather than across them." I'm confused by this apparent contradiction. To me "global" means they retain their state throughout the game, not just within a move block. I suppose I could experiment, but if the flags appear to be global, I still could not safely make that assumption since the language reference does not strictly define it as such. If they are truly global, why does Zillions discourage using them that way? Thanks -- Greg |
L. Lynn Smith (Interrupt27)
| | Posted on Wednesday, April 20, 2005 - 1:03 am: | |
Let me know the results of your experiments. I know that if you don't set the value of a flag within the declaration that it can often be a 'random' state, but this might have been carry-overs from other move generations. |
David J Bush (Twixter)
| | Posted on Thursday, April 21, 2005 - 5:02 pm: | |
I don't really know why "global" variables are not guaranteed to retain their values, but here's a workaround which is supported: Define a dummy position named "info" (or whatever you want) which you will give position attributes based on the values of whatever global variables you want to save. I use two macros, getinfo and storeinfo, which look like this: (define getinfo mark info (set-flag global_1 global_1_set?) (set-flag global_2 global_2_set?) ... ; and so on back ) (define storeinfo mark info (set-attribute global_1_set? global_1) (set-attribute global_2_set? global_2) ... back ) Each move or drop block will have a call to (getinfo) at the beginning, and a call to (storeinfo) at the end. I recommend you try to minimize the number of global variables you have to keep track of this way, but it's there if you need it. An example of these macros in use, is in my "Loop game" code. |
L. Lynn Smith (Interrupt27)
| | Posted on Monday, April 25, 2005 - 3:19 am: | |
David, the question is whether flags are actually global values, or not. There are many ways to create global values, using dummy pieces and dummy positions. Although piece attributes can be carried over from one move generation to another, I believe that position attributes are not. And neither allow the transfer of a value between individual move declarations during a move generation. What would be interesting if there is some way to manipulate a value during the move generation which could be accessed by each and every move declaration. And would remain constant, unless specifically changed by a move declaration. This would be a way to pass a value from one declaration to another, possible allowing some form of move evaluation which would influence the potential moves generated. |
|