}
static int c2n(char c) { /* XXX cloned from singles.c */
- if (isdigit(c))
+ if (isdigit((unsigned char)c))
return (int)(c - '0');
else if (c >= 'a' && c <= 'z')
return (int)(c - 'a' + 10);
static int solve_force(game_state *state)
{
- int x, y, i, which, didsth = 0;
+ int i, which, didsth = 0;
unsigned long f;
for (i = 0; i < state->wh; i++) {
if (f == (GS_NOTNEGATIVE|GS_NOTNEUTRAL))
which = POSITIVE;
if (which != -1) {
- x = i%state->w; y = i/state->w;
if (solve_set(state, i, which, "forced by flags", NULL) < 0)
return -1;
didsth = 1;
static int solve_neither(game_state *state)
{
- int x, y, i, j, didsth = 0;
+ int i, j, didsth = 0;
for (i = 0; i < state->wh; i++) {
if (state->flags[i] & GS_SET) continue;
(state->flags[j] & GS_NOTPOSITIVE)) ||
((state->flags[i] & GS_NOTNEGATIVE) &&
(state->flags[j] & GS_NOTNEGATIVE))) {
- x = i%state->w; y = i/state->w;
if (solve_set(state, i, NEUTRAL, "neither tile magnet", NULL) < 0)
return -1;
didsth = 1;
static int lay_dominoes(game_state *state, random_state *rs, int *scratch)
{
- int n, i, ret = 0, x, y, nlaid = 0, n_initial_neutral;
+ int n, i, ret = 0, nlaid = 0, n_initial_neutral;
for (i = 0; i < state->wh; i++) {
scratch[i] = i;
/* ...and lay a domino if we can. */
- x = i%state->w; y = i/state->w;
- debug(("Laying domino at i:%d, (%d,%d)\n", i, x, y));
+ debug(("Laying domino at i:%d, (%d,%d)\n", i, i%state->w, i/state->w));
/* The choice of which type of domino to lay here leads to subtle differences
* in the sorts of boards that get produced. Too much bias towards magnets
ret = solve_set(state, i, NEUTRAL, "layout", NULL);
}
if (!ret) {
- debug(("Unable to lay anything at (%d,%d), giving up.", x, y));
+ debug(("Unable to lay anything at (%d,%d), giving up.",
+ i%state->w, i/state->w));
ret = -1;
break;
}
movech = ' ';
else
movech = '.';
- } else
+ } else {
assert(!"unknown action");
+ movech = 0; /* placate optimiser */
+ }
sprintf(buf, "%c%d,%d", movech, gx, gy);
return 0.0F;
}
+static int game_status(game_state *state)
+{
+ return state->completed ? +1 : 0;
+}
+
static int game_timing_state(game_state *state, game_ui *ui)
{
return TRUE;
int w = state->w, h = state->h;
int ink = print_mono_colour(dr, 0);
int paper = print_mono_colour(dr, 1);
- int x, y, target, count, which, i, j;
+ int x, y, which, i, j;
/* Ick: fake up `ds->tilesize' for macro expansion purposes */
game_drawstate ads, *ds = &ads;
draw_sym(dr, ds, state->w, state->h, NEGATIVE, ink);
for (which = POSITIVE, j = 0; j < 2; which = OPPOSITE(which), j++) {
for (i = 0; i < w; i++) {
- target = state->common->colcount[i*3+which];
- count = count_rowcol(state, i, COLUMN, which);
draw_num_col(dr, ds, COLUMN, which, i, paper, ink,
- state->common->colcount[i*3+which]);
+ state->common->colcount[i*3+which]);
}
for (i = 0; i < h; i++) {
- target = state->common->rowcount[i*3+which];
- count = count_rowcol(state, i, ROW, which);
draw_num_col(dr, ds, ROW, which, i, paper, ink,
- state->common->rowcount[i*3+which]);
+ state->common->rowcount[i*3+which]);
}
}
game_redraw,
game_anim_length,
game_flash_length,
+ game_status,
TRUE, FALSE, game_print_size, game_print,
FALSE, /* wants_statusbar */
FALSE, game_timing_state,
err = validate_desc(p, desc);
if (err) {
fprintf(stderr, "%s: %s\nDescription: %s\n", quis, err, desc);
- free_params(p);
goto done;
}
s = new_game(NULL, p, desc);