outAtime wrote:Hi, I have been struggling to add mobility to an otherwise simple evaluation, and everything I've tried makes the program weaker. I thought a good mobility function should add elo, although I'm not sure how much. Unfortunately I cant figure out a simple way to subtract attacked squares from the mobility score, so I'm at a bit of a disadvantage there already. I'm just using the piece offsets to calculate the mobility and then trying some sort of idea to make a score using sqrt(). After I have the sqrt() of the mobility I subtract the sqrt of the "centered" or middle mobility of the piece. I think one of the komodo guys had mentioned doing somthing similar. I have to say though, I cant tune the amount this final score is mutiplied by at all. Nothing is working after weeks of effort, no improvement. Any ideas would be appreciated, thanks. B.T.W. I apologize in advance if any code snippets look messy
Code: Select all
/* use piece offsets to get mobility score */
int knight_mobility(int squaren)
{
register int n;
register int g = 0;
for (n = squaren+10; board[n] == npiece; n+=10)
g++;
for (n = squaren-10; board[n] == npiece; n-=10)
g++;
for (n = squaren+14; board[n] == npiece; n+=14)
g++;
for (n = squaren-14; board[n] == npiece; n-=14)
g++;
for (n = squaren+23; board[n] == npiece; n+=23)
g++;
for (n = squaren-23; board[n] == npiece; n-=23)
g++;
for (n = squaren+25; board[n] == npiece; n+=25)
g++;
for (n = squaren-25; board[n] == npiece; n-=25)
g++;
return g;
}
then...
Code: Select all
score -= (sqrt (knight_mobility(i)) - 2) * nme;
or similarly for a bishop...
Code: Select all
score -= (sqrt (bishop_mobility(i)) - 2.65) * bme;
and then #define bme. I cant find any good numbers for bme, or nme, Ive tried alot of different combinations and values here. Getting a good result on a test position doesn't help, lol. Any ideas? I would really appreciate any help.
-outAtime
p.s. I also have rooks counted, but not queens. Im surprised how expensive this method seems, and is costing nodes and maybe a ply or a half ply on average. Im not sure even a great mobility can account for losing a ply in search(), but Id like to think there can be improvements made.
Probably just counting by offsets will not do, try the following:
1. if it attacks opp piece increment by 2
2. if it attacks empty sq increment by 1
3. if it attacks own piece decrement by 1 (defending is a sign of weakness)
Add-on / Improvements:
1a. if the attacked opp piece is protected by opp pawn decrement by 2
1b. apply 3a
2a. if the empty sq is a central sq increment by 2
2b. if the empty sq is close to opp king increment by 1
2c. if the empty sq is attacked by opp pawn decrement by 2
3a. if location of a piece (not the sq it has attacked) is already at the center (4-center sq) increment by 1
3b. if it attacks own king decrement by 1
then just use:
score += piece_type_mobility[net_mobility_counts]; or something
where:
static int piece_type_mobility[] = { -6, -4, -2, 0, 2, 4, 6, 9, 12, 17, 20, 24...}
the challenge is tuning the tablulated values and tuning your increments and decrements.
You may try also to use 2 tables, 1 for opening/middle and 1 for ending then just interpolate to get 1 final score.
Observe how the program plays
, your goals are, opponent is restricted to have access to central squares, opponents' pieces are attacking against each other, and your pieces are somewhat interested in attacking opp king location.
It does not matter if you loss 20 elo on this as long as you get your goals
, You may tune/add other features and search algorithms later. Have fun with the tuning, seeing the tabulated values (first) is way better than using sqrt() thing
.