That's true but my engine always play the same moves, with the same parameters so playing more times would give me always the same games. I plan to add some randomness in the next test session (or maybe a book).jdart wrote:The results of a game match of this number of games do not give you a reliable indicator of how good a change is. The standard deviation of the result is very large.8 players (engines), for sample, plays each one 7 game with white and 7 game with black.
--Jon
Genetical tuning
Moderators: hgm, Rebel, chrisw
-
- Posts: 859
- Joined: Mon Aug 10, 2009 10:05 pm
- Location: Italy
- Full name: Stefano Gemma
Re: Genetical tuning
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
http://www.linformatica.com
-
- Posts: 793
- Joined: Sun Aug 03, 2014 4:48 am
- Location: London, UK
Re: Genetical tuning
I solved that by taking the CCRL dump, and taking all the unique positions after n moves. Here is the number of positions for each n -stegemma wrote:That's true but my engine always play the same moves, with the same parameters so playing more times would give me always the same games. I plan to add some randomness in the next test session (or maybe a book).jdart wrote:The results of a game match of this number of games do not give you a reliable indicator of how good a change is. The standard deviation of the result is very large.8 players (engines), for sample, plays each one 7 game with white and 7 game with black.
--Jon
Code: Select all
19 training/unique_starts/start1.epd
160 training/unique_starts/start2.epd
672 training/unique_starts/start3.epd
1605 training/unique_starts/start4.epd
3215 training/unique_starts/start5.epd
5726 training/unique_starts/start6.epd
10747 training/unique_starts/start7.epd
16918 training/unique_starts/start8.epd
23738 training/unique_starts/start9.epd
31365 training/unique_starts/start10.epd
39648 training/unique_starts/start11.epd
48945 training/unique_starts/start12.epd
59750 training/unique_starts/start13.epd
71216 training/unique_starts/start14.epd
86271 training/unique_starts/start15.epd
101131 training/unique_starts/start16.epd
The files are here if you are interested:
http://matthewlai.ca/download/unique_starts.zip
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.
-
- Posts: 565
- Joined: Thu Nov 13, 2014 12:03 pm
Re: Genetical tuning
Exactly what parameters are you tuning? Piece evaluation + positional factors, or something?
The fitness function is just the score vs opponent?
The fitness function is just the score vs opponent?
-
- Posts: 859
- Joined: Mon Aug 10, 2009 10:05 pm
- Location: Italy
- Full name: Stefano Gemma
Re: Genetical tuning
I tune only positional parameters while piece values are fixed.whereagles wrote:Exactly what parameters are you tuning? Piece evaluation + positional factors, or something?
The fitness function is just the score vs opponent?
The fitness function is only the score against opponents (same engine with different parameters).
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
http://www.linformatica.com
-
- Posts: 565
- Joined: Thu Nov 13, 2014 12:03 pm
Re: Genetical tuning
hmmm.. since the search space of your problem seems continuous (a set of parameter values), I would venture to say a particle swarm approach might work better. Genetical algorithms are more suited to combinatorial optimization stuff.
Note that I say this in isolation, without knowing much in terms of detail, so I might be a bit off.
In any case you need a lot of computer power to get meaningful results.. as someone said, the standard deviations are quite large for small sample sizes.
Note that I say this in isolation, without knowing much in terms of detail, so I might be a bit off.
In any case you need a lot of computer power to get meaningful results.. as someone said, the standard deviations are quite large for small sample sizes.
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: Genetical tuning
Very good thanks.stegemma wrote:I have a group of players, each one is an engine with its parameters. The parameters all together describe a single individual in the population (in effect, a single array, in C++). The genetic algorithm works on those sets of parameters. We can think at this sets as they were the DNA of the players, so a single array of parameters is a single DNA of a single player.Ferdy wrote:Could you describe in a layman's terms how this is done with the engine?stegemma wrote:- genetically cross N/4 players with another random player, but the last one
I start learning defining:
- the number of iterations
- the number of players (the population)
- the time per move
- the max number of moves, to stop endless games
At any iteration, I play a round-robin match (all against all), in the population; 8 players (engines), for sample, plays each one 7 game with white and 7 game with black. I collect the score of any player and I sort players at the end of the tournament (the best scores first) and now I apply the genetic algorithm:
1) I randomly choose player A out the whole population (but the last)
2) I randomly choose player B (idem)
3) I merge the parameters from player B into player A (this changes player A, not player B)
4) I repeat step 1 for N/4 times (2 times, if population is of 8 players)
5) I set the last player (the worst) with random values then I merge that player with the first and the second one (the best ones)
Of course, because the last player will be changed at any time, in step 1 I avoid choosing that player for random merging.
That's all folks
So for example I have an engine, say I will create 8 engines with different set of params out from that engine.
eng1 is default
eng2 has mobility changes
eng3 has passer changes and new pawn value other than the default
eng4 has threat changes
eng5 has piece values changes
eng6 has knight outpost changes
eng7 has rook in open file changes
eng8 has king shelter changes
Is that a possibility?
Say after the a certain tournament is done, eng1 is first, eng2 is second, eng8 is last. So in (5) eng8 will use now the values from eng1 and eng2, is that correct?
What typical TC do you use in the tournament?
-
- Posts: 859
- Joined: Mon Aug 10, 2009 10:05 pm
- Location: Italy
- Full name: Stefano Gemma
Re: Genetical tuning
Any engine has a different set of parameters, I don't change just one per engine but even this method maybe could be try. Just put all the parameters in one array, any engine has its own array. In my test, I start froma common set for half the engines and put the other with random values but you can also start with all random values. My program is in C++, so that I can do something like this (oversimplified, of course):Ferdy wrote:[...]Very good thanks.
So for example I have an engine, say I will create 8 engines with different set of params out from that engine.
eng1 is default
eng2 has mobility changes
eng3 has passer changes and new pawn value other than the default
eng4 has threat changes
eng5 has piece values changes
eng6 has knight outpost changes
eng7 has rook in open file changes
eng8 has king shelter changes
Is that a possibility?
Say after the a certain tournament is done, eng1 is first, eng2 is second, eng8 is last. So in (5) eng8 will use now the values from eng1 and eng2, is that correct?
What typical TC do you use in the tournament?
Code: Select all
class clsEngine
{
public:
int values[17];
...
void SetRandomValues();
void MergeValues(clsEngine &other_engine);
};
const int N = 8;
clsEngine engines[N];
// set random values
for(int i=0; i<N/2; i++) engines[i].SetRandomValues();
for(int iteration=0; iteration<1000; iteration++)
{
for(int a=0; a<N; a++)
for(int b=a+1; b<N; b++)
{
int score = PlayGame(a, b) - PlayGame(b, a);
a.score += score;
b.score -= score;
}
Sort(engines);
for(int i=0; i<N/4; i++)
{
int a = Rand(N);
int b = Rand(N);
if(a!=b) { a.MergeValues(b); a.score = 0; }
}
engines[N-1].SetRandomValues();
engines[N-1].MergeValues(engines[0]);
engines[N-1].MergeValues[engines[1]);
engines[N-1].score = 0;
}
Code: Select all
int PlayGame(clsEngine &white, clsEngine &black)
{
for(int m=0; m<50; m++)
{
string move = white.Search();
white.Execute(move);
black.Executemove(move);
move = black.Search();
white.Execute(move);
black.Executemove(move);
}
return white.score;
}
PS: this way I don't have different program running but only one, with multiple engine objects
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
http://www.linformatica.com
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: Genetical tuning
Here,stegemma wrote:Any engine has a different set of parameters, I don't change just one per engine but even this method maybe could be try. Just put all the parameters in one array, any engine has its own array. In my test, I start froma common set for half the engines and put the other with random values but you can also start with all random values. My program is in C++, so that I can do something like this (oversimplified, of course):Ferdy wrote: Say after the a certain tournament is done, eng1 is first, eng2 is second, eng8 is last. So in (5) eng8 will use now the values from eng1 and eng2, is that correct?
What typical TC do you use in the tournament?
As you can see, class clsEngine hold the array of parameters of a single engine. Any object of that class has the functions to do the search, of course, so that PlayGame function have only to call that functions:Code: Select all
class clsEngine { public: int values[17]; ... void SetRandomValues(); void MergeValues(clsEngine &other_engine); }; const int N = 8; clsEngine engines[N]; // set random values for(int i=0; i<N/2; i++) engines[i].SetRandomValues(); for(int iteration=0; iteration<1000; iteration++) { for(int a=0; a<N; a++) for(int b=a+1; b<N; b++) { int score = PlayGame(a, b) - PlayGame(b, a); a.score += score; b.score -= score; } Sort(engines); for(int i=0; i<N/4; i++) { int a = Rand(N); int b = Rand(N); if(a!=b) { a.MergeValues(b); a.score = 0; } } engines[N-1].SetRandomValues(); engines[N-1].MergeValues(engines[0]); engines[N-1].MergeValues[engines[1]); engines[N-1].score = 0; }
Of course even this has benne oversimplified, because clsEngine class derives froma clsThread class and could be run asynchronously, to ply multiple games at the same time (but I don't do it, for now).Code: Select all
int PlayGame(clsEngine &white, clsEngine &black) { for(int m=0; m<50; m++) { string move = white.Search(); white.Execute(move); black.Executemove(move); move = black.Search(); white.Execute(move); black.Executemove(move); } return white.score; }
PS: this way I don't have different program running but only one, with multiple engine objects
Code: Select all
class clsEngine
{
public:
int values[17];
...
void SetRandomValues();
void MergeValues(clsEngine &other_engine);
};
values[0], for passer at 7th rank
values[1], for knight mobility
values[2], for pawn value
... and so on is that so?
And when you call SetRandomValues(), values[]
will be filled with random numbers appropriate for
specific elements.
-
- Posts: 859
- Joined: Mon Aug 10, 2009 10:05 pm
- Location: Italy
- Full name: Stefano Gemma
Re: Genetical tuning
Yes!Ferdy wrote:[...]
Here,The int values[17], could be,Code: Select all
class clsEngine { public: int values[17]; ... void SetRandomValues(); void MergeValues(clsEngine &other_engine); };
values[0], for passer at 7th rank
values[1], for knight mobility
values[2], for pawn value
... and so on is that so?
And when you call SetRandomValues(), values[]
will be filled with random numbers appropriate for
specific elements.
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
http://www.linformatica.com
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: Genetical tuning
This is indeed a very interesting method to try, like creating child from good performing individuals,stegemma wrote:Yes!Ferdy wrote:[...]
Here,The int values[17], could be,Code: Select all
class clsEngine { public: int values[17]; ... void SetRandomValues(); void MergeValues(clsEngine &other_engine); };
values[0], for passer at 7th rank
values[1], for knight mobility
values[2], for pawn value
... and so on is that so?
And when you call SetRandomValues(), values[]
will be filled with random numbers appropriate for
specific elements.
and slowly remove individuals that showed decreasing performance. I thought about just giving a million or 2, good test suites instead of game playing.
Something like create individual engines by giving
setoption name passer value 120
setoption name mobility_percent 80
...
Then another individual with different or random values.
Feed the test suite, return the static eval or qsearch score,
the engine that gives the minimum eval error will be the first in the ranking.
Keep a record of all those individual, as after the test those
good performers will be put to a serious game tests.