Exemple #1
0
				 int turn, int list0[52], int list1[52],
				 int * restrict pscore );
static int CONV make_list( const tree_t * restrict ptree,
			   int * restrict pscore,
			   int list0[52], int list1[52] );

#if defined(INANIWA_SHIFT)
static int inaniwa_score( const tree_t * restrict ptree );
#endif

int CONV
eval_material( const tree_t * restrict ptree )
{
  int material, itemp;

  itemp     = PopuCount( BB_BPAWN )   + (int)I2HandPawn( HAND_B );
  itemp    -= PopuCount( BB_WPAWN )   + (int)I2HandPawn( HAND_W );
  material  = itemp * p_value[15+pawn];

  itemp     = PopuCount( BB_BLANCE )  + (int)I2HandLance( HAND_B );
  itemp    -= PopuCount( BB_WLANCE )  + (int)I2HandLance( HAND_W );
  material += itemp * p_value[15+lance];

  itemp     = PopuCount( BB_BKNIGHT ) + (int)I2HandKnight( HAND_B );
  itemp    -= PopuCount( BB_WKNIGHT ) + (int)I2HandKnight( HAND_W );
  material += itemp * p_value[15+knight];

  itemp     = PopuCount( BB_BSILVER ) + (int)I2HandSilver( HAND_B );
  itemp    -= PopuCount( BB_WSILVER ) + (int)I2HandSilver( HAND_W );
  material += itemp * p_value[15+silver];
Exemple #2
0
int Position::make_list_correct(int list0[PIECENUMBER_MAX + 1],
                                int list1[PIECENUMBER_MAX + 1]) const
{
    int nlist = 0;
    int Hand[14];
    Hand[0] = I2HandPawn(HAND_B);
    Hand[1] = I2HandPawn(HAND_W);
    Hand[2] = I2HandLance(HAND_B);
    Hand[3] = I2HandLance(HAND_W);
    Hand[4] = I2HandKnight(HAND_B);
    Hand[5] = I2HandKnight(HAND_W);
    Hand[6] = I2HandSilver(HAND_B);
    Hand[7] = I2HandSilver(HAND_W);
    Hand[8] = I2HandGold(HAND_B);
    Hand[9] = I2HandGold(HAND_W);
    Hand[10] = I2HandBishop(HAND_B);
    Hand[11] = I2HandBishop(HAND_W);
    Hand[12] = I2HandRook(HAND_B);
    Hand[13] = I2HandRook(HAND_W);

    for (int i = 0; i < 14; i++){
        const int j = Hand[i];
        for (int k = 1; k <= j; k++){
            list0[nlist] = handB[i] + k;
            list1[nlist++] = handW[i] + k;
        }
    }

    for (int y = RANK_1; y <= RANK_9; y++) {
        for (int x = FILE_1; x <= FILE_9; x++) {
            const int z = (x << 4) + y;
            const int sq = NanohaTbl::z2sq[z];
            switch (ban[z]) {
            case SFU:
                list0[nlist] = f_pawn + sq;
                list1[nlist++] = e_pawn + Inv(sq);
                break;
            case GFU:
                list0[nlist] = e_pawn + sq;
                list1[nlist++] = f_pawn + Inv(sq);
                break;
            case SKY:
                list0[nlist] = f_lance + sq;
                list1[nlist++] = e_lance + Inv(sq);
                break;
            case GKY:
                list0[nlist] = e_lance + sq;
                list1[nlist++] = f_lance + Inv(sq);
                break;
            case SKE:
                list0[nlist] = f_knight + sq;
                list1[nlist++] = e_knight + Inv(sq);
                break;
            case GKE:
                list0[nlist] = e_knight + sq;
                list1[nlist++] = f_knight + Inv(sq);
                break;
            case SGI:
                list0[nlist] = f_silver + sq;
                list1[nlist++] = e_silver + Inv(sq);
                break;
            case GGI:
                list0[nlist] = e_silver + sq;
                list1[nlist++] = f_silver + Inv(sq);
                break;
            case SKI:
            case STO:
            case SNY:
            case SNK:
            case SNG:
                list0[nlist] = f_gold + sq;
                list1[nlist++] = e_gold + Inv(sq);
                break;
            case GKI:
            case GTO:
            case GNY:
            case GNK:
            case GNG:
                list0[nlist] = e_gold + sq;
                list1[nlist++] = f_gold + Inv(sq);
                break;
            case SKA:
                list0[nlist] = f_bishop + sq;
                list1[nlist++] = e_bishop + Inv(sq);
                break;
            case GKA:
                list0[nlist] = e_bishop + sq;
                list1[nlist++] = f_bishop + Inv(sq);
                break;
            case SUM:
                list0[nlist] = f_horse + sq;
                list1[nlist++] = e_horse + Inv(sq);
                break;
            case GUM:
                list0[nlist] = e_horse + sq;
                list1[nlist++] = f_horse + Inv(sq);
                break;
            case SHI:
                list0[nlist] = f_rook + sq;
                list1[nlist++] = e_rook + Inv(sq);
                break;
            case GHI:
                list0[nlist] = e_rook + sq;
                list1[nlist++] = f_rook + Inv(sq);
                break;
            case SRY:
                list0[nlist] = f_dragon + sq;
                list1[nlist++] = e_dragon + Inv(sq);
                break;
            case GRY:
                list0[nlist] = e_dragon + sq;
                list1[nlist++] = f_dragon + Inv(sq);
                break;
            case EMP:
            case WALL:
            case SOU:
            case GOU:
            case PIECE_NONE:
            default:
                ;
            }
        }
    }

    return nlist;
}