~ubuntu-branches/ubuntu/natty/gtkboard/natty

« back to all changes in this revision

Viewing changes to .pc/debian-changes-0.11pre0+cvs.2003.11.02-2/src/cpento.c

  • Committer: Bazaar Package Importer
  • Author(s): Barak A. Pearlmutter
  • Date: 2011-02-28 11:25:02 UTC
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20110228112502-e9aah248wxelm7ao
Tags: 0.11pre0+cvs.2003.11.02-2
autotools tweaks, most notably -lSDL to supplement -lSDL_mixer

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  This file is a part of gtkboard, a board games system.
 
2
    Copyright (C) 2003, Arthur J. O'Dwyer <ajo@andrew.cmu.edu>
 
3
 
 
4
    This program is free software; you can redistribute it and/or modify
 
5
    it under the terms of the GNU General Public License as published by
 
6
    the Free Software Foundation; either version 2 of the License, or
 
7
    (at your option) any later version.
 
8
 
 
9
    This program is distributed in the hope that it will be useful,
 
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
    GNU General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU General Public License
 
15
    along with this program; if not, write to the Free Software
 
16
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
 
17
 
 
18
*/
 
19
 
 
20
#include <stdio.h>
 
21
#include <stdlib.h>
 
22
 
 
23
#include "game.h"
 
24
#include "../pixmaps/alpha.xpm"
 
25
#include "../pixmaps/cpento.xpm"
 
26
 
 
27
#define CPENTO_CELL_SIZE  36
 
28
#define CPENTO_BOARD_WID  15
 
29
#define CPENTO_BOARD_HEIT 9
 
30
 
 
31
#define CPENTO_NUM_PIECES 32
 
32
#define CPENTO_EMPTY 0
 
33
#define CPENTO_TILE_F 1
 
34
#define CPENTO_TILE_I 2
 
35
#define CPENTO_TILE_L 3
 
36
#define CPENTO_TILE_N 4
 
37
#define CPENTO_TILE_P 5
 
38
#define CPENTO_TILE_T 6
 
39
#define CPENTO_TILE_U 7
 
40
#define CPENTO_TILE_V 8
 
41
#define CPENTO_TILE_W 9
 
42
#define CPENTO_TILE_X 10
 
43
#define CPENTO_TILE_Y 11
 
44
#define CPENTO_TILE_Z 12
 
45
#define CPENTO_TILE_SIMPLE 13
 
46
#define CPENTO_TILE_RARROW 14
 
47
#define CPENTO_TILE_LARROW 15
 
48
#define CPENTO_TILE_FLIPLR 16
 
49
#define CPENTO_PIECE_BALL 17
 
50
#define CPENTO_PIECE_LEG_UP 18
 
51
#define CPENTO_PIECE_LEG_DOWN 19
 
52
#define CPENTO_PIECE_PIPE_VERT 20
 
53
#define CPENTO_PIECE_LEG_RIGHT 21
 
54
#define CPENTO_PIECE_BEND_UR 22
 
55
#define CPENTO_PIECE_BEND_DR 23
 
56
#define CPENTO_PIECE_T_LEFT 24
 
57
#define CPENTO_PIECE_LEG_LEFT 25
 
58
#define CPENTO_PIECE_BEND_UL 26
 
59
#define CPENTO_PIECE_BEND_DL 27
 
60
#define CPENTO_PIECE_T_RIGHT 28
 
61
#define CPENTO_PIECE_PIPE_HORIZ 29
 
62
#define CPENTO_PIECE_T_DOWN 30
 
63
#define CPENTO_PIECE_T_UP 31
 
64
#define CPENTO_PIECE_FOURWAY 32
 
65
 
 
66
 
 
67
static char cpento_colors[6];
 
68
static int cpento_initpos[CPENTO_BOARD_WID*CPENTO_BOARD_HEIT];
 
69
static char **cpento_pixmaps[CPENTO_NUM_PIECES];
 
70
static void cpento_init();
 
71
 
 
72
static int cpento_getmove(Pos *, int, int,
 
73
                   GtkboardEventType,
 
74
                   Player, byte **, int **);
 
75
 
 
76
Game CapturePento = {
 
77
    CPENTO_CELL_SIZE,
 
78
    CPENTO_BOARD_WID, CPENTO_BOARD_HEIT,
 
79
    CPENTO_NUM_PIECES,
 
80
    cpento_colors, cpento_initpos,
 
81
    cpento_pixmaps,
 
82
    "Capture Pentominoes",
 
83
        "Nimlike games",
 
84
    cpento_init
 
85
};
 
86
 
 
87
static char cpento_colors[6] = { 0,120,0, 10,130,10 };
 
88
 
 
89
 
 
90
static int cpento_initpos[CPENTO_BOARD_WID*CPENTO_BOARD_HEIT] =
 
91
{
 
92
    1, 2, 3, 4, 5, 6,13,13,13,13,13,13,13,13,13,
 
93
    7, 8, 9,10,11,12,13, 0, 0, 0, 0, 0, 0, 0,13,
 
94
   13,13,13,13,13,13,13, 0, 0, 0, 0, 0, 0, 0,13,
 
95
   13, 0, 0, 0, 0, 0,13, 0, 0, 0, 0, 0, 0, 0,13,
 
96
   13, 0, 0, 0, 0, 0,13, 0, 0, 0, 0, 0, 0, 0,13,
 
97
   15, 0, 0, 0, 0, 0,14, 0, 0, 0, 0, 0, 0, 0,13,
 
98
   13, 0, 0, 0, 0, 0,13, 0, 0, 0, 0, 0, 0, 0,13,
 
99
   13, 0, 0, 0, 0, 0,13, 0, 0, 0, 0, 0, 0, 0,13,
 
100
   13,13,13,16,13,13,13,13,13,13,13,13,13,13,13,
 
101
};
 
102
 
 
103
static char *ball_grey_36_36_xpm[] = {
 
104
"36 36 2 1",
 
105
"  c #000000",
 
106
"X c #FF00FF",
 
107
"....................................",
 
108
"....................................",
 
109
".................X..................",
 
110
"............XXXXXXXXXXX.............",
 
111
"..........XXXXXXXXXXXXXXX...........",
 
112
"........XXXXXXXXXXXXXXXXXXX.........",
 
113
".......XXXXXXXXXXXXXXXXXXXXX........",
 
114
"......XXXXXXXXXXXXXXXXXXXXXXX.......",
 
115
".....XXXXXXXXXXXXXXXXXXXXXXXXX......",
 
116
".....XXXXXXXXXXXXXXXXXXXXXXXXX......",
 
117
"....XXXXXXXXXXXXXXXXXXXXXXXXXXX.....",
 
118
"....XXXXXXXXXXXXXXXXXXXXXXXXXXX.....",
 
119
"...XXXXXXXXXXXXXXXXXXXXXXXXXXXXX....",
 
120
"...XXXXXXXXXXXXXXXXXXXXXXXXXXXXX....",
 
121
"...XXXXXXXXXXXXXXXXXXXXXXXXXXXXX....",
 
122
"...XXXXXXXXXXXXXXXXXXXXXXXXXXXXX....",
 
123
"...XXXXXXXXXXXXXXXXXXXXXXXXXXXXX....",
 
124
"..XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...",
 
125
"...XXXXXXXXXXXXXXXXXXXXXXXXXXXXX....",
 
126
"...XXXXXXXXXXXXXXXXXXXXXXXXXXXXX....",
 
127
"...XXXXXXXXXXXXXXXXXXXXXXXXXXXXX....",
 
128
"...XXXXXXXXXXXXXXXXXXXXXXXXXXXXX....",
 
129
"...XXXXXXXXXXXXXXXXXXXXXXXXXXXXX....",
 
130
"....XXXXXXXXXXXXXXXXXXXXXXXXXXX.....",
 
131
"....XXXXXXXXXXXXXXXXXXXXXXXXXXX.....",
 
132
".....XXXXXXXXXXXXXXXXXXXXXXXXX......",
 
133
".....XXXXXXXXXXXXXXXXXXXXXXXXX......",
 
134
"......XXXXXXXXXXXXXXXXXXXXXXX.......",
 
135
".......XXXXXXXXXXXXXXXXXXXXX........",
 
136
"........XXXXXXXXXXXXXXXXXXX.........",
 
137
"..........XXXXXXXXXXXXXXX...........",
 
138
"............XXXXXXXXXXX.............",
 
139
".................X..................",
 
140
"....................................",
 
141
"....................................",
 
142
"....................................",
 
143
};
 
144
 
 
145
 
 
146
static char **cpento_pixmaps[CPENTO_NUM_PIECES] =
 
147
{
 
148
    char_F_grey_36_36_xpm,
 
149
    char_I_grey_36_36_xpm,
 
150
    char_L_grey_36_36_xpm,
 
151
    char_N_grey_36_36_xpm,
 
152
    char_P_grey_36_36_xpm,
 
153
    char_T_grey_36_36_xpm,
 
154
    char_U_grey_36_36_xpm,
 
155
    char_V_grey_36_36_xpm,
 
156
    char_W_grey_36_36_xpm,
 
157
    char_X_grey_36_36_xpm,
 
158
    char_Y_grey_36_36_xpm,
 
159
    char_Z_grey_36_36_xpm,
 
160
    cpento_fourway_36_36_xpm,
 
161
    char_R_grey_36_36_xpm,
 
162
    char_L_grey_36_36_xpm,
 
163
    char_F_grey_36_36_xpm,
 
164
    ball_grey_36_36_xpm,
 
165
    cpento_leg_u_36_36_xpm,
 
166
    cpento_leg_d_36_36_xpm,
 
167
    cpento_pipe_ud_36_36_xpm,
 
168
    cpento_leg_r_36_36_xpm,
 
169
    cpento_bend_ur_36_36_xpm,
 
170
    cpento_bend_dr_36_36_xpm,
 
171
    cpento_t_closed_l_36_36_xpm,
 
172
    cpento_leg_l_36_36_xpm,
 
173
    cpento_bend_ul_36_36_xpm,
 
174
    cpento_bend_dl_36_36_xpm,
 
175
    cpento_t_closed_r_36_36_xpm,
 
176
    cpento_pipe_lr_36_36_xpm,
 
177
    cpento_t_closed_d_36_36_xpm,
 
178
    cpento_t_closed_u_36_36_xpm,
 
179
    cpento_fourway_36_36_xpm,
 
180
};
 
181
 
 
182
 
 
183
static void cpento_init()
 
184
{
 
185
    game_single_player = 1;
 
186
    game_getmove = cpento_getmove;
 
187
    game_who_won = NULL;
 
188
    game_get_pixmap = NULL;
 
189
    game_scorecmp = game_scorecmp_def_iscore;
 
190
        game_doc_about_status = STATUS_UNPLAYABLE;
 
191
    game_doc_about =
 
192
    "Capture Pentominoes\n"
 
193
    "Two player game\n"
 
194
    "Status: Not implemented\n"
 
195
    "URL: " GAME_DEFAULT_URL("cpento")
 
196
    ;
 
197
    game_doc_rules =
 
198
    "The objective is to be the last player able to move.\n"
 
199
    "\n"
 
200
    "Each move consists of selecting a piece from the pool"
 
201
    " and placing it on some empty region of the board."
 
202
    " If the newly placed piece touches a second piece on"
 
203
    " three or more sides, that second piece is captured."
 
204
    " A captured piece may be removed from the board by"
 
205
    " its captor at any time.\n"
 
206
    "\n"
 
207
    "At the moment, this is just an interface demo.  There's"
 
208
    " no actual game implemented.\n"
 
209
    ;
 
210
    game_doc_strategy =
 
211
    "No strategy yet."
 
212
    ;
 
213
}
 
214
 
 
215
 
 
216
static char *cpento_piece_list[][5] = {
 
217
  {
 
218
    ".....",
 
219
    "..XX.",
 
220
    ".XX..",
 
221
    "..X..",
 
222
    ".....",
 
223
  },
 
224
  {
 
225
    "..X..",
 
226
    "..X..",
 
227
    "..X..",
 
228
    "..X..",
 
229
    "..X..",
 
230
  },
 
231
  {
 
232
    "..X..",
 
233
    "..X..",
 
234
    "..X..",
 
235
    "..XX.",
 
236
    ".....",
 
237
  },
 
238
  {
 
239
    ".....",
 
240
    ".X...",
 
241
    ".XX..",
 
242
    "..X..",
 
243
    "..X..",
 
244
  },
 
245
  {
 
246
    ".....",
 
247
    "..XX.",
 
248
    "..XX.",
 
249
    "..X..",
 
250
    ".....",
 
251
  },
 
252
  {
 
253
    ".....",
 
254
    ".XXX.",
 
255
    "..X..",
 
256
    "..X..",
 
257
    ".....",
 
258
  },
 
259
  {
 
260
    ".....",
 
261
    ".X.X.",
 
262
    ".XXX.",
 
263
    ".....",
 
264
    ".....",
 
265
  },
 
266
  {
 
267
    ".....",
 
268
    ".X...",
 
269
    ".X...",
 
270
    ".XXX.",
 
271
    ".....",
 
272
  },
 
273
  {
 
274
    ".....",
 
275
    ".X...",
 
276
    ".XX..",
 
277
    "..XX.",
 
278
    ".....",
 
279
  },
 
280
  {
 
281
    ".....",
 
282
    "..X..",
 
283
    ".XXX.",
 
284
    "..X..",
 
285
    ".....",
 
286
  },
 
287
  {
 
288
    ".....",
 
289
    "..X..",
 
290
    ".XX..",
 
291
    "..X..",
 
292
    "..X..",
 
293
  },
 
294
  {
 
295
    ".....",
 
296
    ".XX..",
 
297
    "..X..",
 
298
    "..XX.",
 
299
    ".....",
 
300
  },
 
301
};
 
302
 
 
303
 
 
304
static void cpento_add_move(byte *move, int x, int y, int m)
 
305
{
 
306
    int i;
 
307
    for (i=0; move[i] != -1; i += 3)
 
308
    {
 
309
        if (move[i] == x && move[i+1] == y) {
 
310
            move[i+2] = m;
 
311
            return;
 
312
        }
 
313
    }
 
314
    move[i] = x;
 
315
    move[i+1] = y;
 
316
    move[i+2] = m;
 
317
    move[i+3] = -1;
 
318
    return;
 
319
}
 
320
 
 
321
 
 
322
static void cpento_clear_left(byte *move)
 
323
{
 
324
    int i, j, m;
 
325
 
 
326
    /* Clear the left side of the board */
 
327
    for (i=1; i < 6; ++i)
 
328
    for (j=1; j < 6; ++j)
 
329
    {
 
330
        cpento_add_move(move, i, j, 0);
 
331
    }
 
332
}
 
333
 
 
334
/* From picture coords to display coords */
 
335
static void cpento_orient(int x, int y, int *nx, int *ny, int orient)
 
336
{
 
337
    switch (orient)
 
338
    {
 
339
        case 0:  *nx =   x; *ny =   y; return;
 
340
        case 1:  *nx = 4-y; *ny =   x; return;
 
341
        case 2:  *nx = 4-x; *ny = 4-y; return;
 
342
        case 3:  *nx =   y; *ny = 4-x; return;
 
343
        case 4:  *nx = 4-x; *ny =   y; return;
 
344
        case 5:  *nx =   y; *ny =   x; return;
 
345
        case 6:  *nx =   x; *ny = 4-y; return;
 
346
        case 7:  *nx = 4-y; *ny = 4-x; return;
 
347
    }
 
348
}
 
349
 
 
350
/* From display coords to picture coords */
 
351
static void cpento_rev_orient(int x, int y, int *nx, int *ny, int orient)
 
352
{
 
353
    switch (orient)
 
354
    {
 
355
        case 0:  *nx =   x; *ny =   y; return;
 
356
        case 1:  *nx =   y; *ny = 4-x; return;
 
357
        case 2:  *nx = 4-x; *ny = 4-y; return;
 
358
        case 3:  *nx = 4-y; *ny =   x; return;
 
359
        case 4:  *nx = 4-x; *ny =   y; return;
 
360
        case 5:  *nx =   y; *ny =   x; return;
 
361
        case 6:  *nx =   x; *ny = 4-y; return;
 
362
        case 7:  *nx = 4-y; *ny = 4-x; return;
 
363
    }
 
364
}
 
365
 
 
366
static int cpento_tile_orient(int x, int y, int orient, char **pento)
 
367
{
 
368
    int tx, ty;
 
369
    int top=0, left=0, right=0, bottom=0;
 
370
    int results[16] =
 
371
    {
 
372
       0,
 
373
       CPENTO_PIECE_LEG_UP,
 
374
       CPENTO_PIECE_LEG_DOWN,
 
375
       CPENTO_PIECE_PIPE_VERT,
 
376
       CPENTO_PIECE_LEG_RIGHT,
 
377
       CPENTO_PIECE_BEND_UR,
 
378
       CPENTO_PIECE_BEND_DR,
 
379
       CPENTO_PIECE_T_LEFT,
 
380
       CPENTO_PIECE_LEG_LEFT,
 
381
       CPENTO_PIECE_BEND_UL,
 
382
       CPENTO_PIECE_BEND_DL,
 
383
       CPENTO_PIECE_T_RIGHT,
 
384
       CPENTO_PIECE_PIPE_HORIZ,
 
385
       CPENTO_PIECE_T_DOWN,
 
386
       CPENTO_PIECE_T_UP,
 
387
       CPENTO_PIECE_FOURWAY
 
388
    };
 
389
 
 
390
    cpento_rev_orient(x, y, &tx, &ty, orient);
 
391
    if (pento[tx][ty] != 'X')
 
392
      return 0;
 
393
    cpento_rev_orient(x, y+1, &tx, &ty, orient);
 
394
    top = (y < 4 && pento[tx][ty] == 'X');
 
395
    cpento_rev_orient(x, y-1, &tx, &ty, orient);
 
396
    bottom = (y > 0 && pento[tx][ty] == 'X');
 
397
    cpento_rev_orient(x+1, y, &tx, &ty, orient);
 
398
    right = (x < 4 && pento[tx][ty] == 'X');
 
399
    cpento_rev_orient(x-1, y, &tx, &ty, orient);
 
400
    left = (x > 0 && pento[tx][ty] == 'X');
 
401
    return results[top | bottom<<1 | right<<2 | left<<3];
 
402
}
 
403
 
 
404
static void cpento_place_left(byte *move, char *pento[5],
 
405
                              int piece_letter, int orient)
 
406
{
 
407
    int i, j;
 
408
    cpento_clear_left(move);
 
409
    for (i=0; i < 5; ++i) {
 
410
        for (j=0; j < 5; ++j) {
 
411
            int X, Y;
 
412
            cpento_orient(i, j, &X, &Y, orient);
 
413
            if (pento[i][j] == 'X')
 
414
              cpento_add_move(move, X+1, Y+1, 
 
415
                  cpento_tile_orient(X, Y, orient, pento));
 
416
        }
 
417
    }
 
418
}
 
419
 
 
420
 
 
421
static void cpento_place_right(byte *move, char *pento[5],
 
422
                               int piece_letter, int orient,
 
423
                               int x, int y)
 
424
{
 
425
    int i, j;
 
426
    for (i=0; i < 5; ++i) {
 
427
        for (j=0; j < 5; ++j) {
 
428
            int X, Y;
 
429
            cpento_orient(i, j, &X, &Y, orient);
 
430
            if (pento[i][j] == 'X')
 
431
              cpento_add_move(move, X+x-2, Y+y-2,
 
432
                  cpento_tile_orient(X, Y, orient, pento));
 
433
        }
 
434
    }
 
435
}
 
436
 
 
437
 
 
438
static int cpento_fits_right(byte *move, char *pento[5],
 
439
                             int orient, int x, int y, Pos *pos)
 
440
{
 
441
    int i, j;
 
442
    for (i=0; i < 5; ++i) {
 
443
        for (j=0; j < 5; ++j) {
 
444
            int X, Y;
 
445
            cpento_orient(i, j, &X, &Y, orient);
 
446
            if (pento[i][j] == 'X') {
 
447
                if (X+x-2 < 1 || X+x-2 > CPENTO_BOARD_WID-2)
 
448
                  return 0;
 
449
                if (Y+y-2 < 1 || Y+y-2 > CPENTO_BOARD_HEIT-2)
 
450
                  return 0;
 
451
                if (pos->board[(Y+y-2)*board_wid + (X+x-2)] != CPENTO_EMPTY)
 
452
                  return 0;
 
453
            }
 
454
        }
 
455
    }
 
456
    return 1;
 
457
}
 
458
 
 
459
 
 
460
static int cpento_getmove(Pos *pos, int x, int y,
 
461
                          GtkboardEventType type,
 
462
                          Player to_play, byte **movp,
 
463
                          int **renderp)
 
464
{
 
465
    static byte move[2000]; /* theoretical max length: 151 */
 
466
    static int state = 0;
 
467
    static int orient = 0;
 
468
    static int pento = 0;
 
469
    int tile;
 
470
 
 
471
    /* States */
 
472
    /* 0 = no pentomino selected */
 
473
    /* 1 = pentomino selected */
 
474
    /* Orientations */
 
475
    /* 0 = neutral */
 
476
    /* 1 = rot 90 right */
 
477
    /* 2 = rot 180 right */
 
478
    /* 5 = flipped, then rot 90 */
 
479
    /* 7 = flipped, then rot 270 */
 
480
    /* Pentos run 0..11 */
 
481
 
 
482
    static const int larrow_effects[] =
 
483
      { 1, 2, 3, 0, 7, 4, 5, 6 };
 
484
    static const int rarrow_effects[] =
 
485
      { 3, 0, 1, 2, 5, 6, 7, 4 };
 
486
    static const int fliplr_effects[] =
 
487
      { 4, 5, 6, 7, 0, 1, 2, 3 };
 
488
 
 
489
    if (type != GTKBOARD_BUTTON_RELEASE)
 
490
      return 0;
 
491
 
 
492
    move[0] = -1;
 
493
 
 
494
    tile = pos->board[y * board_wid + x];
 
495
 
 
496
    if (tile >= CPENTO_TILE_F && tile <= CPENTO_TILE_Z)
 
497
    {
 
498
        /* Select a new pentomino; get rid of the old one */
 
499
        pento = (tile - CPENTO_TILE_F);
 
500
        orient = 0;
 
501
        cpento_place_left(move, cpento_piece_list[pento], tile, orient);
 
502
        state = 1;
 
503
        if (movp)
 
504
          *movp = move;
 
505
        return 1;
 
506
    }
 
507
    else if ((tile == CPENTO_TILE_LARROW) && (state == 1))
 
508
    {
 
509
        orient = larrow_effects[orient];
 
510
        cpento_place_left(move, cpento_piece_list[pento], pento, orient);
 
511
        if (movp)
 
512
          *movp = move;
 
513
        return 1;
 
514
    }
 
515
    else if ((tile == CPENTO_TILE_RARROW) && (state == 1))
 
516
    {
 
517
        orient = rarrow_effects[orient];
 
518
        cpento_place_left(move, cpento_piece_list[pento], pento, orient);
 
519
        if (movp)
 
520
          *movp = move;
 
521
        return 1;
 
522
    }
 
523
    else if ((tile == CPENTO_TILE_FLIPLR) && (state == 1))
 
524
    {
 
525
        orient = fliplr_effects[orient];
 
526
        cpento_place_left(move, cpento_piece_list[pento], pento, orient);
 
527
        if (movp)
 
528
          *movp = move;
 
529
        return 1;
 
530
    }
 
531
    else if (tile != CPENTO_EMPTY)
 
532
    {
 
533
        return -1;
 
534
    }
 
535
    else if ((x > 6) && (state == 1))
 
536
    {
 
537
        cpento_clear_left(move);
 
538
        if (cpento_fits_right(move, cpento_piece_list[pento], orient, x, y, pos))
 
539
        {
 
540
            cpento_place_right(move, cpento_piece_list[pento], pento, orient, x, y);
 
541
            state = 0;
 
542
            if (movp)
 
543
              *movp = move;
 
544
            return 1;
 
545
        }
 
546
        else {
 
547
            int possibles = 0;
 
548
            int fit = 0;
 
549
            if (cpento_fits_right(move, cpento_piece_list[pento], orient, 
 
550
                x-1, y, pos))
 
551
              ++possibles, fit = 0 * 3 + 1;
 
552
            if (cpento_fits_right(move, cpento_piece_list[pento], orient, 
 
553
                x+1, y, pos))
 
554
              ++possibles, fit = 2 * 3 + 1;
 
555
            if (cpento_fits_right(move, cpento_piece_list[pento], orient, 
 
556
                x, y-1, pos))
 
557
              ++possibles, fit = 1 * 3 + 0;
 
558
            if (cpento_fits_right(move, cpento_piece_list[pento], orient, 
 
559
                x, y+1, pos))
 
560
              ++possibles, fit = 1 * 3 + 2;
 
561
 
 
562
            if (possibles != 1)
 
563
              return -1;
 
564
 
 
565
            cpento_place_right(move, cpento_piece_list[pento], pento, orient,
 
566
                x+(fit/3)-1, y+(fit%3)-1);
 
567
            state = 0;
 
568
            if (movp)
 
569
              *movp = move;
 
570
            return 1;
 
571
        }
 
572
    }
 
573
    else
 
574
    {
 
575
        return -1;
 
576
    }
 
577
}
 
578