Page 1 of 1

Natwarlal v0.10

PostPosted: 28 Feb 2005, 10:45
by Pallav Nawani
New version of Natwarlal is available. Thanks to Dann and all the people who offered advice on how to speed up the engine.

Linux & Windows executables:
http://www.ironcode.com/data/Natwarlal010-bin.zip

Source Code:
http://www.ironcode.com/data/Natwarlal010-src.zip

Major Changes:
* New, faster move generator :wink:
* Increased NPS: about 10%
* Modified Piece Square tables.

Best regards,
Pallav

Slight problem

PostPosted: 28 Feb 2005, 12:43
by Pallav Nawani
Hi,

I just realised that this version has problems with the single reply extension. This was the only thing I did not test before releasing the new version. : (

Anyway, here is a temp workaround. In the natwarlal.ini change

; Singular reply extension
single_reply_extension = 10

to

; Singular reply extension
single_reply_extension = 7

Sorry for the bother.
Best regards,
Pallav

Re: Natwarlal v0.10

PostPosted: 28 Feb 2005, 14:13
by Pallav Nawani
New version with the proper natwarlal.ini file uploaded. If you download now, all should be well.

Pallav

Re: Natwarlal v0.10

PostPosted: 28 Feb 2005, 14:59
by David Weller
Pallav,

What sort of 'speed-ups' did our 'friendly neighborhood gurus' give?

GES needs as many of those as it can get - :)

Or, maybe they were very specific to your code ...

Re: Natwarlal v0.10

PostPosted: 28 Feb 2005, 15:43
by Charles Roberson
David,

We gave him two simple pieces of advice.
1) Don't do anything until you profile your code.
2) Do algorithmic improvements before simple code opts.

He had troubles profiling his code, so I did it for him.

Charles

Re: Natwarlal v0.10

PostPosted: 28 Feb 2005, 17:28
by Pallav Nawani
David Weller wrote:Pallav,
What sort of 'speed-ups' did our 'friendly neighborhood gurus' give?
GES needs as many of those as it can get - :)
Or, maybe they were very specific to your code ...


Not at all. The speed ups were gained by implementing some things. They were common things every engine uses, but Natwarlal didn't.

(a) Fast legality check
Before, whenever I was checking that a move was legal, I did a simple isattacked(). Now I have implemented a faster function to check move legality, which just looks at the previous move. I have not seen this in any other (open source) program, but it is a safe bet that engines which do 1 Million+ NPS are using it.

See the function
Code: Select all
int quick_illegal_check(Game_info &gi)

in attacks.cc

I also have a similar fast check counting function (also in attacks.cc)

(b) Generate check evasions
I now generate check evasions, which I didn't do before. As a result, I don't have to call isattacked() to check move legality at all, since when in check, I generate only legal moves, and only time quick_illegal_check() can fail is when the king is already in check. I took a lot of 'inspiration' from Tord's code here :mrgreen:

(c) New move generator.
Although its not a lot faster than the previous one (maybe 10%) when generating normal moves, it still contributed to NPS increase, because the most of the move generation time is taken in generating captures, and here the new one was much faster.

(d) New compiler flags.
I got about 3K NPS increase by messing around with compiler flags :D

I also move instructions here and there, up and down, but in the end it scarcely resulted in more NPS :( One thing though, if you have something that is frequently accessed, make it a local variable - much faster than globals. Of course, if it requires a lot of initialization you cant make it local as it will consume too much time to initialize it every time.

Hope these things speed up you engine as well.
Best regards,
Pallav