/* Pieces and colors of initial board setup */
+#ifndef MINISHOGI
const small_short Stboard[NO_SQUARES] =
{
lance, knight, silver, gold, king, gold, silver, knight, lance,
white, white, white, white,
white, white, white, white, white
};
+#else
+const small_short Stboard[NO_SQUARES] =
+{
+ king, gold, silver, bishop, rook,
+ pawn, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, pawn,
+ rook, bishop, silver, gold, king,
+};
+const small_short Stcolor[NO_SQUARES] =
+{
+ black, black, black, black, black,
+ black, neutral, neutral, neutral, neutral,
+ neutral, neutral, neutral, neutral, neutral,
+ neutral, neutral, neutral, neutral, white,
+ white, white, white, white, white
+};
+#endif
+
/* Actual pieces and colors */
small_short board[NO_SQUARES], color[NO_SQUARES];
{ 0, 35, 70, 99 }, /* main stage borders */
/* ------------------------------------------ */
{ 7, 7, 8, 10 }, /* Pawn */
+#ifndef MINISHOGI
{ 20, 35, 45, 60 }, /* Lance */
{ 20, 35, 45, 60 }, /* Knight */
+#endif
{ 35, 40, 60, 80 }, /* Silver */
{ 35, 50, 65, 80 }, /* Gold */
{ 90, 90, 90, 90 }, /* Bishop */
{ 95, 95, 95, 95 }, /* Rook */
{ 15, 25, 40, 65 }, /* promoted Pawn */
+#ifndef MINISHOGI
{ 25, 45, 55, 65 }, /* promoted Lance */
{ 25, 45, 55, 65 }, /* promoted Knight */
+#endif
{ 35, 55, 75, 75 }, /* promoted Silver */
{ 99, 99, 99, 99 }, /* promoted Bishop */
{ 97, 97, 99, 99 }, /* promoted Rook */
{ 0, 5, 2, 1, 0, -1, -2, -3, -4, -5 };
/* distance to promotion zone */
+#ifndef MINISHOGI
static const int PromotionZoneDistanceBonus[NO_ROWS] =
{ 0, 0, 0, 0, 2, 6, 6, 8, 8 };
+#else
+static const int PromotionZoneDistanceBonus[NO_ROWS] =
+{ 0, 0, 2, 6, 8 }; /* FIXME ? */
+#endif
#define MAX_BMBLTY 20
#define MAX_RMBLTY 20
static const short RMBLTY[MAX_RMBLTY] =
{ 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, 14, 16, 16, 16, 16 };
+#ifndef MINISHOGI
/* Lance mobility bonus indexed by # reachable squares */
static const short LMBLTY[MAX_LMBLTY] =
{ 0, 0, 0, 0, 4, 6, 8, 10 };
+#endif
static const short MBLTY[NO_PIECES] =
-{ 0, 2, 1, 10, 5, 5, 1, 1, 5, 5, 5, 5, 1, 1, 4 };
+{ 0, 2,
+#ifndef MINISHOGI
+ 1, 10,
+#endif
+ 5, 5, 1, 1, 5,
+#ifndef MINISHOGI
+ 5, 5,
+#endif
+ 5, 1, 1, 4 };
static const short KTHRT[36] =
{ 0, -8, -20, -36, -52, -68, -80, -80, -80, -80, -80, -80,
static small_short Msilver[2][NO_SQUARES];
static small_short Mgold [2][NO_SQUARES];
static small_short Mking [2][NO_SQUARES];
+#ifndef MINISHOGI
static small_short Mlance [2][NO_SQUARES];
static small_short Mknight[2][NO_SQUARES];
+#endif
static small_short Mbishop[2][NO_SQUARES];
static small_short Mrook [2][NO_SQUARES];
-static Mpiece_array Mpawn, Mlance, Mknight, Msilver, Mgold,
- Mbishop, Mrook, Mking;
+static Mpiece_array Mpawn,
+#ifndef MINISHOGI
+ Mlance, Mknight,
+#endif
+ Msilver, Mgold, Mbishop, Mrook, Mking;
Mpiece_array *Mpiece[NO_PIECES] =
-{ NULL, &Mpawn, &Mlance, &Mknight, &Msilver, &Mgold, &Mbishop, &Mrook,
- &Mgold, &Mgold, &Mgold, &Mgold, &Mbishop, &Mrook, &Mking };
+{ NULL, &Mpawn,
+#ifndef MINISHOGI
+ &Mlance, &Mknight,
+#endif
+ &Msilver, &Mgold, &Mbishop, &Mrook,
+ &Mgold,
+#ifndef MINISHOGI
+ &Mgold, &Mgold,
+#endif
+ &Mgold, &Mbishop, &Mrook, &Mking };
static short c1, c2;
add_target(sq, side, 11);
break;
+#ifndef MINISHOGI
case knight: /* vertically ahead if advanced */
/* FIXME: gotta love them magic numbers... */
if ((sq != 1) && (sq != 7) && (sq != 73) && (sq != 79))
add_target(sq, side, 11);
break;
+#endif
}
}
/* it's the first piece in the current direction */
if (color[u] == c1)
{
+#ifndef MINISHOGI
/* own intercepting piece in x-ray attack */
if (upiece == lance)
{
}
}
else
+#endif
{
/* bishop or rook x-ray */
if ((upiece == bishop) && (board[u] == pawn)
{
s += (ds = -2*fv1[HCLSD]);
}
+#ifndef MINISHOGI
else if ((upiece == rook) && (board[u] == lance)
&& (GameType[c1] == STATIC_ROOK)
&& (column(u) == csq))
{
s += (ds = fv1[XRAY]);
}
+#endif
}
}
else
{
/* enemy's intercepting piece in pin attack */
+#ifndef MINISHOGI
if (upiece == lance)
{
/* lance pin attack */
}
}
else
+#endif
{
/* bishop or rook pin attack */
if (board[u] == pawn)
}
else
{
+#ifndef MINISHOGI
if (upiece == lance)
{
s += (ds = fv1[XRAY] / 2);
}
else
+#endif
{
s += (ds = fv1[XRAY]);
}
if (in_opening_stage)
{
+#ifndef MINISHOGI
+/* FIXME: [HGM] The 3rd-rank Pawn section is meaningless in mini-Shogi,
+ * (which does not have opposing Pawns), and can do out-of-bound access,
+ * as the promotion zone is only 1 rank, so Pawns can be closer than 3 ranks
+ * to the board edge.
+ */
if (crow(c1, sq) == 2) /* pawn on 3d rank */
{
if (board[(c1 == black) ?
}
}
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9
+ * board - and anyway we don't know the stage really :)
+ */
if ((GameType[c1] == STATIC_ROOK) && (sq == csquare(c1, 43)))
{
if ((atk2[csquare(c1, 52)] & CNT_MASK) < 2)
s += (ds = -2 * fv1[ATTACKED]);
}
}
+#endif
}
return s;
}
-
+#ifndef MINISHOGI
/*
* Calculate the positional value for a lance on 'sq'.
*/
return s;
}
+#endif
if (in_opening_stage)
{
+#ifndef MINISHOGI
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9
+ * board - and anyway we don't know the stage really :)
+ */
if (GameType[c1] == STATIC_ROOK)
{
if (csquare(c1, sq) == 12)
}
}
}
+#endif
}
else
{
if (in_opening_stage)
{
+#ifndef MINISHOGI
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9
+ * board - and anyway we don't know the stage really :)
+ */
if ((GameType[c1] == STATIC_ROOK) && (GameType[c2] != STATIC_ROOK))
{
if (Mvboard[csquare(c1, 3)])
s += (ds = -2 * fv1[OPENWRONG]);
}
}
+#endif
}
else
{
if (in_opening_stage)
{
+#ifndef MINISHOGI
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9
+ * board - and anyway we don't know the stage really :)
+ */
if (GameType[c1] == RANGING_ROOK)
{
/* Bishops diagonal should not be open */
s += (ds = -fv1[OPENWRONG]);
}
}
+#endif
}
else
{
if (in_opening_stage)
{
+#ifndef MINISHOGI
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9
+ * board - and anyway we don't know the stage really :)
+ */
short WRONG = fv1[OPENWRONG], OPOK = WRONG / 3;
if (GameType[c1] == STATIC_ROOK)
}
}
}
+#endif
}
else
{
+#ifndef MINISHOGI
/*
* Calculate the positional value for a promoted lance on 'sq'.
*/
return s;
}
+#endif
if (fv1[KSFTY] != 0)
s += KingScan(sq);
+#ifndef MINISHOGI
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9
+ * board - and anyway we don't know the stage really :)
+ */
if (in_opening_stage)
{
if ((GameType[c1] != UNKNOWN) && (ccolumn(c1, sq) == 4))
s += (ds = -fv1[OPENWRONG] / 2);
}
}
+#endif
/* CHECKME: is this correct? */
if ((ds = fv1[HOPN]))
s += (ds = BMBLTY[mob] * fv1[MOBILITY] / 100);
else if ((piece == rook) || (piece == prook))
s += (ds = RMBLTY[mob] * fv1[MOBILITY] / 100);
+#ifndef MINISHOGI
else
s += (ds = LMBLTY[mob] * fv1[MOBILITY] / 100);
+#endif
}
else
{
s += PawnValue(sq, side);
break;
+#ifndef MINISHOGI
case lance:
s += LanceValue(sq, side);
break;
case knight:
s += KnightValue(sq, side);
break;
+#endif
case silver:
s += SilverValue(sq, side);
s += PPawnValue(sq, side);
break;
+#ifndef MINISHOGI
case plance:
s += PLanceValue(sq, side);
break;
case pknight:
s += PKnightValue(sq, side);
break;
+#endif
case psilver:
s += PSilverValue(sq, side);
if ((m = seed[c1]))
{
- for (piece = lance, n = 0; piece <= rook; piece++)
+ for (piece = pawn+1, n = 0; piece <= rook; piece++)
{
if (Captured[c1][piece])
n++;
ds = RMBLTY[MAX_RMBLTY - 1];
break;
+#ifndef MINISHOGI
case lance:
ds = LMBLTY[MAX_LMBLTY - 1];
break;
+#endif
default:
ds = MBLTY[piece];
ScoreCaptures();
}
+#ifndef MINISHOGI
+# define BLACKHOME_START 0
+# define BLACKHOME_END 26
+# define MIDDLEROW_START 36
+# define MIDDLEROW_END 44
+# define WHITEHOME_START 54
+# define WHITEHOME_END 80
+#else
+# define BLACKHOME_START 0
+# define BLACKHOME_END 4
+# define MIDDLEROW_START 10
+# define MIDDLEROW_END 14
+# define WHITEHOME_START 19
+# define WHITEHOME_END 24
+#endif
for (c1 = black, c2 = white; c1 <= white; c1++, c2--)
{
short n;
fv1 = fvalue[c1];
/* Score fifth rank */
- for (sq = 36, n = 0; sq <= 44; sq++)
+ for (sq = MIDDLEROW_START, n = 0; sq <= MIDDLEROW_END; sq++)
{
if ((color[sq] == c1) || (attack[c1][sq] != 0))
n++;
}
/* Score holes */
- for (sq = ((c1 == black) ? 0 : 54), n = 0;
- sq <= ((c1 == black) ? 26 : 80);
+ for (sq = ((c1 == black) ? BLACKHOME_START : WHITEHOME_START), n = 0;
+ sq <= ((c1 == black) ? BLACKHOME_END : WHITEHOME_END);
sq++)
{
if (board[sq] == no_piece && attack[c1][sq] == 0)
* Try to determine the game type of "side".
*/
+#ifndef MINISHOGI
inline static void
GuessGameType(short side_to_move)
{
}
}
}
+#endif
{
short side;
+#ifndef MINISHOGI
+ /* FIXME: calculations below are wrong for minishogi, all done for 9x9 */
GuessGameType(side_to_move);
+#else
+ GameType[black] = UNKNOWN;
+ GameType[white] = UNKNOWN;
+#endif
array_zero(Mpawn, sizeof(Mpawn));
+#ifndef MINISHOGI
array_zero(Mlance, sizeof(Mlance));
array_zero(Mknight, sizeof(Mknight));
+#endif
array_zero(Msilver, sizeof(Msilver));
array_zero(Mgold, sizeof(Mgold));
array_zero(Mbishop, sizeof(Mbishop));
+/* FIXME: calculations below are wrong for minishogi, all done for 9x9 */
void
DetermineStage(short side)
{
stage = 30;
}
+#ifndef MINISHOGI
/* Update stage depending on board features and attack balance value */
if (abs(ds = (mtl[side] - mtl[xside]))
stage += (ds = db1);
}
+#endif
for (c1 = black, c2 = white; c1 <= white; c1++, c2--)
{
/* Determine stage dependant weights */
ADVNCM[pawn] = 1; /* advanced pawn bonus increment */
+#ifndef MINISHOGI
ADVNCM[lance] = 1;
ADVNCM[knight] = 1;
+#endif
ADVNCM[silver] = 1; /* advanced silver bonus increment */
ADVNCM[gold] = 1; /* advanced gold bonus increment */
ADVNCM[bishop] = 1;