The wrong way

Discussion of chess software programming and technical issues.

Moderator: Ras

flok

Re: The wrong way

Post by flok »

Henk wrote:Can't post the whole method. For it is too long. Speed is comparable.
Just post your code on github.
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: The wrong way

Post by Henk »

ZirconiumX wrote:
Henk wrote:ok, last optimization did not work. So I will copy (if I have time) the code given with the straight and diagonal pieces. I assume it is allowed.

See if that makes it faster.
I hate to pull a Lucas Braesch on you, Henk, but I think you're missing something obvious.

Your code is written in C#. This is the fundamental reason why your code is slow.

If you want to continue writing your slow program in C#, fine, but remember than C# is the bottleneck here.

Matthew:out
The reason why I chose C# is because I wanted to create a web application and then you can't use pointers. So I chose C#.NET. Maybe there are tricks in C# to make it faster. Actually I miss something like macros when function or method calls are too expensive. When I learned C# there was only version 2.0 and now they already have 6.0.
flok

Re: The wrong way

Post by flok »

Henk wrote:The reason why I chose C# is because I wanted to create a web application and then you can't use pointers.
Of course you can.
Maybe not in c# but there are alternatives.

But personally I would focus first on how you write programs.
Read a book on how to structure code. How to write code that is more easily maintainable and understable also for others.

Your functions/methods are too long. And there's to much code repeated time and time again.
You say that it is faster but I think then maybe your methods of testing that are incorrect. Unrolling loops may seem faster in a out-of-context situation, but included in a larger piece of code also things like cache-misses are starting to count.
User avatar
hgm
Posts: 28387
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: The wrong way

Post by hgm »

Henk wrote:
hgm wrote:Some people would be very happy if you wrote an engine for playing Maka Dai Dai Shogi, even if it was only as strong as Skipper is with Chess.
Just saw it has 96 different pieces types. That will be long switch statements. (You know my code)
Doesn't matter, speed would be no issue. It would still make them happy, no matter how slow.
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: The wrong way

Post by Henk »

flok wrote:
Henk wrote:The reason why I chose C# is because I wanted to create a web application and then you can't use pointers.
Of course you can.
Maybe not in c# but there are alternatives.

But personally I would focus first on how you write programs.
Read a book on how to structure code. How to write code that is more easily maintainable and understable also for others.

Your functions/methods are too long. And there's to much code repeated time and time again.
You say that it is faster but I think then maybe your methods of testing that are incorrect. Unrolling loops may seem faster in a out-of-context situation, but included in a larger piece of code also things like cache-misses are starting to count.
If you go for micro optimizations and want to pass the speed limit code gets more and more ugly. It actually started with de Bruyn. If you would see my last written code you probably would get into a shock. Breaking all the rules.
mar
Posts: 2665
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: The wrong way

Post by mar »

flok wrote:Just post your code on github.
Good advice. Funny that none of your engines are on github :wink:
ZirconiumX
Posts: 1359
Joined: Sun Jul 17, 2011 11:14 am
Full name: Hannah Ravensloft

Re: The wrong way

Post by ZirconiumX »

Henk wrote:
flok wrote:
Henk wrote:The reason why I chose C# is because I wanted to create a web application and then you can't use pointers.
Of course you can.
Maybe not in c# but there are alternatives.

But personally I would focus first on how you write programs.
Read a book on how to structure code. How to write code that is more easily maintainable and understable also for others.

Your functions/methods are too long. And there's to much code repeated time and time again.
You say that it is faster but I think then maybe your methods of testing that are incorrect. Unrolling loops may seem faster in a out-of-context situation, but included in a larger piece of code also things like cache-misses are starting to count.
If you go for micro optimizations and want to pass the speed limit code gets more and more ugly. It actually started with de Bruyn. If you would see my last written code you probably would get into a shock. Breaking all the rules.
Read this.
tu ne cede malis, sed contra audentior ito
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: The wrong way

Post by Sven »

Henk wrote:
flok wrote:
Henk wrote:The reason why I chose C# is because I wanted to create a web application and then you can't use pointers.
Of course you can.
Maybe not in c# but there are alternatives.

But personally I would focus first on how you write programs.
Read a book on how to structure code. How to write code that is more easily maintainable and understable also for others.

Your functions/methods are too long. And there's to much code repeated time and time again.
You say that it is faster but I think then maybe your methods of testing that are incorrect. Unrolling loops may seem faster in a out-of-context situation, but included in a larger piece of code also things like cache-misses are starting to count.
If you go for micro optimizations and want to pass the speed limit code gets more and more ugly. It actually started with de Bruyn. If you would see my last written code you probably would get into a shock. Breaking all the rules.
What is the reason why you "go for micro optimizations" in the current stage of development of your chess engine? What is your goal, then?

Authors of ELO 3000+ engines sometimes try to squeeze the last bit of performance out of their engine in order to achieve a few more ELO points (but actually I think they do different things most of the time to improve playing strength, including massive testing, parameter tuning or improving their search algorithms).

According to recent results of HGM's online blitz tournament (the only tourney I am aware of where Skipper has been participating) Skipper is still slightly behind MicroMax and Barbarossa (CCRL 40/4 ELO 1948 resp. 2203) and clearly behind Joker (2307). That is actually not bad but it is ages away from a playing strength where people start to "micro-optimize".
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: The wrong way

Post by Henk »

Sven Schüle wrote:
Henk wrote:
flok wrote:
Henk wrote:The reason why I chose C# is because I wanted to create a web application and then you can't use pointers.
Of course you can.
Maybe not in c# but there are alternatives.

But personally I would focus first on how you write programs.
Read a book on how to structure code. How to write code that is more easily maintainable and understable also for others.

Your functions/methods are too long. And there's to much code repeated time and time again.
You say that it is faster but I think then maybe your methods of testing that are incorrect. Unrolling loops may seem faster in a out-of-context situation, but included in a larger piece of code also things like cache-misses are starting to count.
If you go for micro optimizations and want to pass the speed limit code gets more and more ugly. It actually started with de Bruyn. If you would see my last written code you probably would get into a shock. Breaking all the rules.
What is the reason why you "go for micro optimizations" in the current stage of development of your chess engine? What is your goal, then?

Authors of ELO 3000+ engines sometimes try to squeeze the last bit of performance out of their engine in order to achieve a few more ELO points (but actually I think they do different things most of the time to improve playing strength, including massive testing, parameter tuning or improving their search algorithms).

According to recent results of HGM's online blitz tournament (the only tourney I am aware of where Skipper has been participating) Skipper is still slightly behind MicroMax and Barbarossa (CCRL 40/4 ELO 1948 resp. 2203) and clearly behind Joker (2307). That is actually not bad but it is ages away from a playing strength where people start to "micro-optimize".
I agree it is totally useless. But actually developing a chess engine is totally useless for there are hundreds or thousands of them. Also because lack of good ideas. Just killing time and do some really stupid programming. Always wanted to develop a chess program maybe that's why I studied computer science.
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: The wrong way

Post by Henk »

ZirconiumX wrote:
Henk wrote:
flok wrote:
Henk wrote:The reason why I chose C# is because I wanted to create a web application and then you can't use pointers.
Of course you can.
Maybe not in c# but there are alternatives.

But personally I would focus first on how you write programs.
Read a book on how to structure code. How to write code that is more easily maintainable and understable also for others.

Your functions/methods are too long. And there's to much code repeated time and time again.
You say that it is faster but I think then maybe your methods of testing that are incorrect. Unrolling loops may seem faster in a out-of-context situation, but included in a larger piece of code also things like cache-misses are starting to count.
If you go for micro optimizations and want to pass the speed limit code gets more and more ugly. It actually started with de Bruyn. If you would see my last written code you probably would get into a shock. Breaking all the rules.
Read this.
I have Dijkstra's book at home. Only read it partly some time ago.
What's it called "A discipline of programming". It's that you mention Dijkstra for I thought about it few hours ago when I mentioned the world 'discipline'