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.

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 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.

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 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".

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.

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-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.