[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Customizable score weights
From: |
Xan Gregg |
Subject: |
Customizable score weights |
Date: |
Tue, 11 Feb 2003 21:30:25 -0500 |
Developers,
I can't find it now, but I remember something customizable weighting
being on a GNU Chess to-do list. I've made a first step in that
direction using the 5.05 distribution, which I am happy to share with
you if you like.
Basic summary:
--- OLD eval.h ---
#define TRADEPIECE 4
#define TRADEPAWNS 8
#define HUNGPENALTY -20
#define ROOKMOVED -20
#define KINGMOVED -20
...
--- NEW eval.h ---
typedef struct
{ /* all values in centipawns from perspective of current side */
int tradePieces; /* reward for piece trade when ahead in material */
int tradePawns; /* reward for pawn trade when behind in material */
int hungPenalty; /* penalty for hung pieces */
int rookMoved; /* penalty for rook having been moved */
int kingMoved; /* penalty for king having been moved */
...
} Profile;
extern Profile profile; /* the current profile in use */
#define TRADEPIECE profile.tradePieces
#define TRADEPAWNS profile.tradePawns
#define HUNGPENALTY profile.hungPenalty
#define ROOKMOVED profile.rookMoved
#define KINGMOVED profile.kingMoved
--- NEW eval.c ---
Profile defaultProfile; /* profile used unless overridden */
Profile profile; /* the current profile in use */
void InitDefaultProfile()
{ /* defaults from 5.05 eval.h */
defaultProfile.tradePieces = 4;
defaultProfile.tradePawns = 8;
defaultProfile.hungPenalty = -20;
defaultProfile.rookMoved = -20;
defaultProfile.kingMoved = -20;
...
profile = defaultProfile;
}
---
Having #defines that expand to struct members creates minimal impact on
the rest of the code. (The only other changes were to declare and call
the InitDefaultProfile() function.) The idea is that other profiles
can be read from files, or that the current profile could be changed at
run-time via commands, but I haven't pursued those possibilities.
Let me know if you would like the whole files.
xan
- Customizable score weights,
Xan Gregg <=