Spier 2005 Pinotage
A ruby red Shiraz. Jammy, but not overly sweet. More to the herbal / woodsy end of red wines.
Squaring Circles one Side at a Time. A hobby blog on game programming and other interests.
2007-06-23
2007-05-24
ToDo list
What I need to do ...
1) I had to re-create my Poggle game program, so I should do a write-up of what I changed.
2) A study of my Concentration game program, with respect to unit and regression tests.
3) Re-create my Kono game program.
4) Go over game position evaluation, a la Conway.
1) I had to re-create my Poggle game program, so I should do a write-up of what I changed.
2) A study of my Concentration game program, with respect to unit and regression tests.
3) Re-create my Kono game program.
4) Go over game position evaluation, a la Conway.
2007-05-22
Wine Blogging: The Pretty Miss, Creed of Barossa
2007-05-21
Programming Mephistopheles' Computer
In terms of paranoia, there are three ways to look at computers;
Naive - Once a program compiles and is debugged successfully, there will be no problems with the program. Apart from the user of course.
Murphy's Computer - Programs will fail fail at random. Usually at the worst moment for the user.
Mephistopheles' Computer - Programs will not just fail, they will fail in a manner to cause the most pain for the user.
While it is a good idea to lock down the program's input so that a "clueless user" (translation: some one who can find an undocumented feature) cannot break a program, there are are other ways that inputs can mess up a system. For instance between threads, between processes, or between function calls. In many cases, the programmer must add reality checks to any input from any source, "trusted" or not, in order to keep problem at a minimum.
For instance, reading and writing to the Windows registry. The cases a program will access the registry can be summed into three; when the program starts, when the program stops, and when the program's parameters change.
When the program starts, either the registry entries are there or they are not, as in starting the program for the first time. Plus, just because the root entry is there for the program, does not mean that the sub-entries are there as well.
All a quitting program wants is to write what ever values it has into the registry. If the entry is not there the entry can be created for the value to be stored..
When the program changes parameters, all that it needs is to store the old value and read the new value. While if the entry for the old value does not exist and can be created, a non-existent new value means that the program must recreated this new value with the programmed defaults.
Note that with multiple choices, the program does not have to check those choices not wanted. When done properly, this can be done on-the-fly.
Just remember, "The devil is in the detail."
Naive - Once a program compiles and is debugged successfully, there will be no problems with the program. Apart from the user of course.
Murphy's Computer - Programs will fail fail at random. Usually at the worst moment for the user.
Mephistopheles' Computer - Programs will not just fail, they will fail in a manner to cause the most pain for the user.
While it is a good idea to lock down the program's input so that a "clueless user" (translation: some one who can find an undocumented feature) cannot break a program, there are are other ways that inputs can mess up a system. For instance between threads, between processes, or between function calls. In many cases, the programmer must add reality checks to any input from any source, "trusted" or not, in order to keep problem at a minimum.
For instance, reading and writing to the Windows registry. The cases a program will access the registry can be summed into three; when the program starts, when the program stops, and when the program's parameters change.
When the program starts, either the registry entries are there or they are not, as in starting the program for the first time. Plus, just because the root entry is there for the program, does not mean that the sub-entries are there as well.
All a quitting program wants is to write what ever values it has into the registry. If the entry is not there the entry can be created for the value to be stored..
When the program changes parameters, all that it needs is to store the old value and read the new value. While if the entry for the old value does not exist and can be created, a non-existent new value means that the program must recreated this new value with the programmed defaults.
Note that with multiple choices, the program does not have to check those choices not wanted. When done properly, this can be done on-the-fly.
Just remember, "The devil is in the detail."
2007-05-20
Today's Wine Domaine du Loou, Espirit de Blancs

Domaine du Loou, Espirit de Blancs is a nice crisp wine from Provence. Its taste of green apple will complement curries and satay dishes. The residual sugars will go nicely with any spicy dish, but don't serve this wine with intense tomato based chilies.
Recommended meal: Fine Cooking's Best of issue, Spring/Summer 2007's Thai Marinated Roast Chicken with Lemongrass-Peanut Pan Sauce with Bon Appetit's June 2007 issue's Strawberry-Blueberry Summer Pudding for dessert. In order to get more sauce for the chicken recipe, I would recommend that a quarter cup of chicken broth be added to the roasting pan, either for the basting for just for scrapping up the drippings.
Today's Wine, Joel Gott Cabernet Sauvignon 2005

(Actually yesterday's wine.)
Joel Gott Cabernet Sauvignon 2005, Blend 815 is a big fruity wine. About 17.00 USD. It goes well with grilled foods. Think sirloin burgers topped with roasted onions and bleu cheese.
I had this with skirt steak simmered in chili sauce (cooked ancho and jalapeno peppers pureed with garlic, salt, anise seed and tomatillos, then strained) and served with guacamole.
2006-06-28
Kono: the Board class (again)
Actually a bit more than a variable move made it necessary to refoactor every thing.
O.K., the CBoard class is purely about the playing field. The reason why earlier versions placed movement functionality here was confusion about the similarity between checking for possible movement paths and checking for neighbouring regions.
So, the minimum required for the CBoard class is (ignoring Singleton issues) drawing the board and retrieving board and region information. The functions about neighbourhoods can be skipped as there is no special or missing neighbouring cells to be concerned with.
The named constants:
Private;
drawing constants for the playing field, and
number of cells
Public:
OFF_BOARD.
Variables:
Private;
array of regions for selecting pieces, and
array of regiond for selecting playing regions.
Static Functions (no need to create or release instances to call these):
Public;
retrieve dimensions of layout (number of cells for each direction), and
check that location (x,y) is in bounds.
Functions:
Public;
retrieve the region for location (x,y),
match location (x,y) to point,
drawing,
retrieving the size of the playing field (in pixels), and
Singleton functionality.
O.K., the CBoard class is purely about the playing field. The reason why earlier versions placed movement functionality here was confusion about the similarity between checking for possible movement paths and checking for neighbouring regions.
So, the minimum required for the CBoard class is (ignoring Singleton issues) drawing the board and retrieving board and region information. The functions about neighbourhoods can be skipped as there is no special or missing neighbouring cells to be concerned with.
The named constants:
Private;
drawing constants for the playing field, and
number of cells
Public:
OFF_BOARD.
Variables:
Private;
array of regions for selecting pieces, and
array of regiond for selecting playing regions.
Static Functions (no need to create or release instances to call these):
Public;
retrieve dimensions of layout (number of cells for each direction), and
check that location (x,y) is in bounds.
Functions:
Public;
retrieve the region for location (x,y),
match location (x,y) to point,
drawing,
retrieving the size of the playing field (in pixels), and
Singleton functionality.
2006-06-17
The Scoring System, Nimbers III
Once Nimber arithmetic is explained with 3 stacks, there is no need to go any further. The value of four or more stacks can be determined as combinations of 1, 2 and/or 3 stacks.
The starting point here is to use 3 stacks containing 1, 2 and 3 counters. These 3 stacks (1* + 2* + 3*) have the combined value of 0. If the first person removes one of the stacks, the second person can then equalize the remaining stacks and leave the Game with a value of 0 again. Alternatively if the first person equalizes two of the three stacks, then the second person can remove the un-equal third stack and leave the game with 2 equal stacks again.
So the first set of equivalences in Nimber Addition are;
1* + 2* + 3* = 0
1* + 2* = 3*
1* + 3* = 2*
2* + 3* = 1*
The next triplet of Nimbers in Winning Ways, Vol. 1 that equal 0 can be played out in much the same manner. In addition to the moves mentioned before (first player: removes a stack, second player: equalizes the remaining stacks and first player: equalizes 2 stacks, second player: removes the un-equal stack), the second player also has the following strategy. If the first player reduces one of the bigger stacks to either 2* or 3*, the second player can remove counters from the other large stack to give it a value of 3* or 2* respectively. The game now has the value of 1* + 2* + 3* or, as previously determined, 0.
Evaluating any random set of 3 stacks is not terribly difficult. One just has to find the Nimber value of two smaller stacks. If this value equals the third stack, the total value of the triplet is 0 and the first person to play loses. If the combined Nimber value of the smaller stack does NOT equal the third stack, all the first player needs to do to win is to reduce the third stack to the value calculated and leave the Game with the value of 0.
Further examples of Nimber addition can be found in Berkamp, Conway and Guy's "Winning Ways, Vol. 1", pages 42 and 59 - 59.
The starting point here is to use 3 stacks containing 1, 2 and 3 counters. These 3 stacks (1* + 2* + 3*) have the combined value of 0. If the first person removes one of the stacks, the second person can then equalize the remaining stacks and leave the Game with a value of 0 again. Alternatively if the first person equalizes two of the three stacks, then the second person can remove the un-equal third stack and leave the game with 2 equal stacks again.
So the first set of equivalences in Nimber Addition are;
1* + 2* + 3* = 0
1* + 2* = 3*
1* + 3* = 2*
2* + 3* = 1*
The next triplet of Nimbers in Winning Ways, Vol. 1 that equal 0 can be played out in much the same manner. In addition to the moves mentioned before (first player: removes a stack, second player: equalizes the remaining stacks and first player: equalizes 2 stacks, second player: removes the un-equal stack), the second player also has the following strategy. If the first player reduces one of the bigger stacks to either 2* or 3*, the second player can remove counters from the other large stack to give it a value of 3* or 2* respectively. The game now has the value of 1* + 2* + 3* or, as previously determined, 0.
Evaluating any random set of 3 stacks is not terribly difficult. One just has to find the Nimber value of two smaller stacks. If this value equals the third stack, the total value of the triplet is 0 and the first person to play loses. If the combined Nimber value of the smaller stack does NOT equal the third stack, all the first player needs to do to win is to reduce the third stack to the value calculated and leave the Game with the value of 0.
Further examples of Nimber addition can be found in Berkamp, Conway and Guy's "Winning Ways, Vol. 1", pages 42 and 59 - 59.
The Scoring System, Nimbers II
Beginning with two stacks, the properties of Nimbers start appearing.
Two stacks of equal height (with equal Nimber values) turns out to have a total value of 0 (the first person to move loses). If the first person takes an entire stack, the second person take the second stack and the first person is left without a move. On the other hand if the first person takes only part of a stack, the second person takes the same amount from the other stack and leaves the total value 0 as before.
Thus the first property of Nimbers is that two Nimbers of equal value total to 0 (n* + n* = 0). In other words, a Nimber is its own negative.
Two stacks of unequal value mean that the first person wins, of course. The best strategy is for the first person to equalize the stacks leaving a Game with the value of 0 for the second player.
Two stacks of equal height (with equal Nimber values) turns out to have a total value of 0 (the first person to move loses). If the first person takes an entire stack, the second person take the second stack and the first person is left without a move. On the other hand if the first person takes only part of a stack, the second person takes the same amount from the other stack and leaves the total value 0 as before.
Thus the first property of Nimbers is that two Nimbers of equal value total to 0 (n* + n* = 0). In other words, a Nimber is its own negative.
Two stacks of unequal value mean that the first person wins, of course. The best strategy is for the first person to equalize the stacks leaving a Game with the value of 0 for the second player.
2006-06-13
The Scoring System II, Nimbers
Now consider Lucy and Robert with a single stack of cookies. They take turns eating one or more cookies from the stack. The loser in this game is the one that cannot get any more cookies to eat from the stack.
The best strategy for either player is to grab the entire stack.
Here the first person to play wins.
The best strategy for either player is to grab the entire stack.
Here the first person to play wins.
The Scoring System I
Skipping over fractional game values for the time being, let us talk whole numbers.
We will start off considering games blocking games where the first person without a move loses. By convention, the Left player (which I'll name Lucy) will win if the game's value is positive, >0, or, in other words, has move moves than the opposing side. And the right player (Robert) will win if the game's value is less than 0, more moves than Lucy.
If the game has a value of 0 (think of a game board without pieces), then the first person to move is the loser (no piece to move).
Follow along with Berlekamp, Conway, and Guy in "Winning Ways".
We will start off considering games blocking games where the first person without a move loses. By convention, the Left player (which I'll name Lucy) will win if the game's value is positive, >0, or, in other words, has move moves than the opposing side. And the right player (Robert) will win if the game's value is less than 0, more moves than Lucy.
If the game has a value of 0 (think of a game board without pieces), then the first person to move is the loser (no piece to move).
Follow along with Berlekamp, Conway, and Guy in "Winning Ways".
scheduling
One of the problems I am having is that when I built up my collection of programs I tended to skip around, going from one program to another, to avoid burning out. This tends to make for long development times.
I will try to blog on a regular basis, once I get my scheduling together. Until then, all I can do is random posts.
I will try to blog on a regular basis, once I get my scheduling together. Until then, all I can do is random posts.
2006-06-09
Kono: regarding Rules class
Applying rules of the game without specifiing who is in that location just dose not make sense. About the only way that one can apply a movement rule and not care about ownership is with non-partisan (pieces can be moved by anyone) games or games that have both partisan and non-partisan pieces.
2006-06-06
2006-06-04
Kono, re-going over the go-over
It is rather embassasing to re-do teh rules class in order to get it to check that the piece moved is actually owned, much less owned by the proper side. I.e., Pre-Condition from point is playerX.
2006-05-31
2006-05-28
An Edward Gorey Death
What horrible Edward Gorey Death will you die?
You will swallow some tacks. You are a little weird, maybe not so much in a good way. Buy a yellow tie and wear it on your head.
Take this quiz!
Quizilla |
Join
| Make A Quiz | More Quizzes | Grab Code
2006-05-26
Kono: the beginning
The two classes that are essentially remain the same (expect for the Microsoft supplied classes) are the CStone and the CBoard classes. And about the ONLY thing that changes for the CBoard class is 1) the movement functions are moved the CRule class, 2) the named constant for the size of the playing area becomes private, and 3) that a new public function is added to indicate whether or not a given point is indeed on the playing area.
PS. I will start commenting on the COwner class when I finished refactoring it. The only other bit than needs to be mentioned is that the stored piece arrays are combined within a CPoint array in order to keep the location values together. (Saves on mental sweat.)
PS. I will start commenting on the COwner class when I finished refactoring it. The only other bit than needs to be mentioned is that the stored piece arrays are combined within a CPoint array in order to keep the location values together. (Saves on mental sweat.)
Subscribe to:
Posts (Atom)

