Page 3 of 7

Re: Writing bugs

Posted: Thu Jan 10, 2019 6:20 am
by Rebel
syzygy wrote:
Sun Jan 06, 2019 10:24 pm
Funnily enough I made the same mistake today, but the compiler caught it for me. (See here.)
:lol:

Re: Writing bugs

Posted: Thu Jan 10, 2019 6:22 am
by Rebel
hgm wrote:
Sun Jan 06, 2019 7:43 pm
Nothing wring with

if((x&1) != engine) ...

If you dislike parentheses, you could also do

if(x-engine & 1) ...

I wouldn't say adding unnecessary dummy variables is "the right way to do it".
Maybe not, but I left it, it's a great reminder!

Re: Writing bugs

Posted: Thu Jan 10, 2019 5:46 pm
by chrisw
Took me a while to track this one down .....

Code: Select all

while(the cows come home)
{
	selfplay(engine_1, engine_1)
	append game to file
	engine_weights += initial_weights + random(small_variation)
}
which produces lots of varied games.
Then same thing in parallel, the equivalent of this loop:

Code: Select all

for thread in range(cores)
{
	while(the cows come home)
	{
		selfplay(engine_1, engine_1)
		append game to file(thread)
		engine_weights += initial_weights + random(small_variation)
	}		
}
concatenate(files)
What could possibly go wrong?

Re: Writing bugs

Posted: Thu Jan 10, 2019 6:06 pm
by Ras
chrisw wrote:
Thu Jan 10, 2019 5:46 pm
What could possibly go wrong?
If one thread finishes its game early and modifies the engine weights while the other threads are still playing, they might not like that? Also, it looks strange with the "+=" in both cases, but probably more serious in the parallel case.

Re: Writing bugs

Posted: Thu Jan 10, 2019 6:34 pm
by chrisw
Ras wrote:
Thu Jan 10, 2019 6:06 pm
chrisw wrote:
Thu Jan 10, 2019 5:46 pm
What could possibly go wrong?
If one thread finishes its game early and modifies the engine weights while the other threads are still playing, they might not like that? Also, it looks strange with the "+=" in both cases, but probably more serious in the parallel case.
pardon the sloppy pseudo code.

no, it's a more general problem ...

Re: Writing bugs

Posted: Thu Jan 10, 2019 7:27 pm
by Fulvio
chrisw wrote:
Thu Jan 10, 2019 6:34 pm
no, it's a more general problem ...
https://stackoverflow.com/questions/212 ... om-numbers

Re: Writing bugs

Posted: Thu Jan 10, 2019 8:11 pm
by chrisw
Fulvio wrote:
Thu Jan 10, 2019 7:27 pm
chrisw wrote:
Thu Jan 10, 2019 6:34 pm
no, it's a more general problem ...
https://stackoverflow.com/questions/212 ... om-numbers
Each parallel batch contains identical games is (was) the problem

Re: Writing bugs

Posted: Fri Jan 11, 2019 4:58 am
by mar
chrisw wrote:
Thu Jan 10, 2019 8:11 pm
Each parallel batch contains identical games is (was) the problem

Code: Select all

int random() {return 42;}
Wait - could this possibly be related to the fact that you used Python, where threads are completely useless due to GIL and you have to use multiple processes? :roll:

Then your "bug" is directly related to the language "features" you used, not at all to the pseudo-code which tells absolutely nothing.

Re: Writing bugs

Posted: Fri Jan 11, 2019 5:59 am
by mar
Ok, seriously: you forgot to reseed, no big deal.
This is suspicious as well:

Code: Select all

engine_weights += initial_weights + random(small_variation)
as it would skyrocket the weights quickly. I believe the first += should actually be =

Re: Writing bugs

Posted: Fri Jan 11, 2019 9:41 am
by mcostalba

Code: Select all

for (x = engine; x < MAX_MOVES; x += 2)
If x <= MAX_MOVES happens to be correct, then make it wrong fixing the definition somewhere else: it should really be wrong :-)