Subversion Repositories Games.Chess Giants

Rev

Rev 33 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33 Rev 108
Line 13... Line 13...
13
 *   Hopefully, only one move will remain after the elimination and legality   *
13
 *   Hopefully, only one move will remain after the elimination and legality   *
14
 *   checks.                                                                   *
14
 *   checks.                                                                   *
15
 *                                                                             *
15
 *                                                                             *
16
 *******************************************************************************
16
 *******************************************************************************
17
 */
17
 */
18
int InputMove(TREE * RESTRICT tree, char *text, int ply, int wtm, int silent,
18
int InputMove(TREE * RESTRICT tree, int ply, int wtm, int silent,
19
    int ponder_list) {
19
    int ponder_list, char *text) {
20
  int moves[220], *mv, *mvp, *goodmove = 0;
20
  unsigned moves[220], *mv, *mvp, *goodmove = 0;
21
  int piece = -1, capture, promote, give_check;
21
  int piece = -1, capture, promote, give_check;
22
  int ffile, frank, tfile, trank;
22
  int ffile, frank, tfile, trank;
23
  int current, i, nleft;
23
  int current, i, nleft;
24
  char *goodchar, *tc;
24
  char *goodchar, *tc;
25
  char movetext[128];
25
  char movetext[128];
Line 55... Line 55...
55
  if (strlen(text) == 0)
55
  if (strlen(text) == 0)
56
    return 0;
56
    return 0;
57
  if ((text[0] >= 'a') && (text[0] <= 'h') && (text[1] >= '1')
57
  if ((text[0] >= 'a') && (text[0] <= 'h') && (text[1] >= '1')
58
      && (text[1] <= '8') && (text[2] >= 'a') && (text[2] <= 'h')
58
      && (text[1] <= '8') && (text[2] >= 'a') && (text[2] <= 'h')
59
      && (text[3] >= '1') && (text[3] <= '8'))
59
      && (text[3] >= '1') && (text[3] <= '8'))
60
    return InputMoveICS(tree, text, ply, wtm, silent, ponder_list);
60
    return InputMoveICS(tree, ply, wtm, silent, ponder_list, text);
61
/*
61
/*
62
 ************************************************************
62
 ************************************************************
63
 *                                                          *
63
 *                                                          *
64
 *  Initialize move structure.  If we discover a parsing    *
64
 *  Initialize move structure.  If we discover a parsing    *
65
 *  error, this will cause us to return a move of "0" to    *
65
 *  error, this will cause us to return a move of "0" to    *
66
 *  indicate some sort of error was detected.               *
66
 *  indicate some sort of error was detected.               *
67
 *                                                          *
67
 *                                                          *
68
 ************************************************************
68
 ************************************************************
69
 */
69
 */
70
  tree->status[MAXPLY] = tree->status[ply];
70
  tree->status[MAXPLY] = tree->status[ply];
71
  strcpy_s(movetext, sizeof (movetext), text); // Pierre-Marie Baty -- use safe version
71
  strcpy(movetext, text);
72
  moves[0] = 0;
72
  moves[0] = 0;
73
  piece = 0;
73
  piece = 0;
74
  capture = 0;
74
  capture = 0;
75
  promote = 0;
75
  promote = 0;
76
  give_check = 0;
76
  give_check = 0;
Line 296... Line 296...
296
    if ((tfile >= 0) && (File(To(*mv)) != tfile))
296
    if ((tfile >= 0) && (File(To(*mv)) != tfile))
297
      *mv = 0;
297
      *mv = 0;
298
    if ((trank >= 0) && (Rank(To(*mv)) != trank))
298
    if ((trank >= 0) && (Rank(To(*mv)) != trank))
299
      *mv = 0;
299
      *mv = 0;
300
    if (!ponder_list && *mv) {
300
    if (!ponder_list && *mv) {
301
      MakeMove(tree, MAXPLY, *mv, wtm);
301
      MakeMove(tree, MAXPLY, wtm, *mv);
302
      if (Check(wtm) || (give_check && !Check(Flip(wtm)))) {
302
      if (Check(wtm) || (give_check && !Check(Flip(wtm)))) {
303
        UnmakeMove(tree, MAXPLY, *mv, wtm);
303
        UnmakeMove(tree, MAXPLY, wtm, *mv);
304
        *mv = 0;
304
        *mv = 0;
305
      } else
305
      } else
306
        UnmakeMove(tree, MAXPLY, *mv, wtm);
306
        UnmakeMove(tree, MAXPLY, wtm, *mv);
307
    }
307
    }
308
  }
308
  }
309
/*
309
/*
310
 ************************************************************
310
 ************************************************************
311
 *                                                          *
311
 *                                                          *
Line 344... Line 344...
344
 *   InputMoveICS() is responsible for converting a move from the ics format   *
344
 *   InputMoveICS() is responsible for converting a move from the ics format   *
345
 *   [from][to][promote] to the program's internal format.                     *
345
 *   [from][to][promote] to the program's internal format.                     *
346
 *                                                                             *
346
 *                                                                             *
347
 *******************************************************************************
347
 *******************************************************************************
348
 */
348
 */
349
int InputMoveICS(TREE * RESTRICT tree, char *text, int ply, int wtm,
349
int InputMoveICS(TREE * RESTRICT tree, int ply, int wtm, int silent,
350
    int silent, int ponder_list) {
350
    int ponder_list, char *text) {
351
  int moves[220], *mv, *mvp, *goodmove = 0;
351
  unsigned moves[220], *mv, *mvp, *goodmove = 0;
352
  int piece = -1, promote;
352
  int piece = -1, promote;
353
  int ffile, frank, tfile, trank;
353
  int ffile, frank, tfile, trank;
354
  int i, nleft;
354
  int i, nleft;
355
  char movetext[128];
355
  char movetext[128];
356
  static const char pieces[15] =
356
  static const char pieces[15] =
Line 367... Line 367...
367
 ************************************************************
367
 ************************************************************
368
 */
368
 */
369
  if (strlen(text) == 0)
369
  if (strlen(text) == 0)
370
    return 0;
370
    return 0;
371
  tree->status[MAXPLY] = tree->status[ply];
371
  tree->status[MAXPLY] = tree->status[ply];
372
  strcpy_s(movetext, sizeof (movetext), text); // Pierre-Marie Baty -- use safe version
372
  strcpy(movetext, text);
373
  moves[0] = 0;
373
  moves[0] = 0;
374
  promote = 0;
374
  promote = 0;
375
/*
375
/*
376
 ************************************************************
376
 ************************************************************
377
 *                                                          *
377
 *                                                          *
Line 469... Line 469...
469
    if (Rank(To(*mv)) != trank)
469
    if (Rank(To(*mv)) != trank)
470
      *mv = 0;
470
      *mv = 0;
471
    if (File(To(*mv)) != tfile)
471
    if (File(To(*mv)) != tfile)
472
      *mv = 0;
472
      *mv = 0;
473
    if (!ponder_list && *mv) {
473
    if (!ponder_list && *mv) {
474
      MakeMove(tree, MAXPLY, *mv, wtm);
474
      MakeMove(tree, MAXPLY, wtm, *mv);
475
      if (Check(wtm)) {
475
      if (Check(wtm)) {
476
        UnmakeMove(tree, MAXPLY, *mv, wtm);
476
        UnmakeMove(tree, MAXPLY, wtm, *mv);
477
        *mv = 0;
477
        *mv = 0;
478
      } else
478
      } else
479
        UnmakeMove(tree, MAXPLY, *mv, wtm);
479
        UnmakeMove(tree, MAXPLY, wtm, *mv);
480
    }
480
    }
481
  }
481
  }
482
/*
482
/*
483
 ************************************************************
483
 ************************************************************
484
 *                                                          *
484
 *                                                          *