Thanks Ed Schröder and Sleeping while you work

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

CRoberson
Posts: 2055
Joined: Mon Mar 13, 2006 2:31 am
Location: North Carolina, USA

Thanks Ed Schröder and Sleeping while you work

Post by CRoberson »

In my experience, working while you sleep works, but sleeping while you work doesn't. I've solved lots of problems in my sleep, but I just found some dumb code that I must have coded on a late night binge.

Thanks to go to Ed Schröder for accidentally pointing me in the right direction. Telepath's improvement has been challenged for a while. All my ideas made little change. I decided there must be a dominating error, but where could it be in 700+ pages of code (paperback form at 30 lines per page). Well, Ed published some research on what is and isn't important in a SPE. So, I started with the most important stuff and found this ringer.

Some how I typed Mobility = mask & ~WhiteBoard instead of Mobility = mask & ~WholeBoard. As you can see there are only 2 characters different and I did this is several places.

Testing the fixes today, but it should make for an Elo improvement after a long drought. OTH, what else did I do on that long night.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Thanks Ed Schröder and Sleeping while you work

Post by lucasart »

Rather than relying on sleep-induced premonitions, put bug-traps in your code: this bug should have fired an assert!
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
jswaff
Posts: 105
Joined: Mon Jun 09, 2014 12:22 am
Full name: James Swafford

Re: Thanks Ed Schröder and Sleeping while you work

Post by jswaff »

I'm glad you found your bug and hope fixing it yields some nice improvement (any results yet?).

I abandoned Prophet for pretty much exactly that reason. I felt there must be some well hidden bugs, and over time I just lost confidence in the code. The eyeball algorithm only goes so far.

I agree with Lucas's sentiment, but even better than an assert would be a unit test. It takes longer to program this way but instead of working in your sleep you'll actually sleep. :)

--
James
User avatar
Graham Banks
Posts: 41423
Joined: Sun Feb 26, 2006 10:52 am
Location: Auckland, NZ

Re: Thanks Ed Schröder and Sleeping while you work

Post by Graham Banks »

jswaff wrote:I'm glad you found your bug and hope fixing it yields some nice improvement (any results yet?).

I abandoned Prophet for pretty much exactly that reason. I felt there must be some well hidden bugs, and over time I just lost confidence in the code. The eyeball algorithm only goes so far.

I agree with Lucas's sentiment, but even better than an assert would be a unit test. It takes longer to program this way but instead of working in your sleep you'll actually sleep. :)

--
James
Hi James,

I liked Prophet.
Any chance of you programming your new engine in a language other than Java, so that it's easier for hobbyists to use in GUIs?

Graham.
gbanksnz at gmail.com
jswaff
Posts: 105
Joined: Mon Jun 09, 2014 12:22 am
Full name: James Swafford

Re: Thanks Ed Schröder and Sleeping while you work

Post by jswaff »

Hi Graham,

No, there's no chance of that for chess4j. That was sort of the point of the program- to play around with JVM based languages. Norbert Leisner (hope I got his name right) just sent me some Win32 binaries the other day though, so I'll post them after I check them out.

--
James
User avatar
Graham Banks
Posts: 41423
Joined: Sun Feb 26, 2006 10:52 am
Location: Auckland, NZ

Re: Thanks Ed Schröder and Sleeping while you work

Post by Graham Banks »

jswaff wrote:Hi Graham,

No, there's no chance of that for chess4j. That was sort of the point of the program- to play around with JVM based languages. Norbert Leisner (hope I got his name right) just sent me some Win32 binaries the other day though, so I'll post them after I check them out.

--
James
Thanks James.

ChessGUI allows the use of Java engines, so once Chess4J gets a little stronger, I'll give it a go. :)

Cheers,
Graham.
gbanksnz at gmail.com
CRoberson
Posts: 2055
Joined: Mon Mar 13, 2006 2:31 am
Location: North Carolina, USA

Re: Thanks Ed Schröder and Sleeping while you work

Post by CRoberson »

Hi James,

Good to hear from you. We need to take another road trip, where to this time?

It picked up 65 ELo. Yes, I would never rely on asserts. Assert usefulness is far from enough. It is impossible to catch all bugs by only using asserts and anything you can catch with asserts can be caught other ways, but they are useful for some things.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Thanks Ed Schröder and Sleeping while you work

Post by lucasart »

CRoberson wrote:Yes, I would never rely on asserts. Assert usefulness is far from enough. It is impossible to catch all bugs by only using asserts and anything you can catch with asserts can be caught other ways, but they are useful for some things.
Asserts are not enough, but they go a long way. When I wrote that this bug should have been caught by an assert, I meant that your eval would fail the rank symmetry test. Apply rankwise symmetry and invert side to move, then your eval should be unchanged (modulo sign). I bet you will discover more bugs once you put in place that test…

Another very important safety net, is to use a bench test like stockfish. Any patch expected to be non functional should leave bench unchanged.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
CRoberson
Posts: 2055
Joined: Mon Mar 13, 2006 2:31 am
Location: North Carolina, USA

Re: Thanks Ed Schröder and Sleeping while you work

Post by CRoberson »

I've been using bench testing since the 1980's on various software projects and on Chess programs since the 1990's. The symmetry assert wouldn't have worked, because it passed symmetry testing. I did the same thing for black as for white. A mistake on both parts thus symmetrical.