Hey! I'm building a chess engine and now I'm stuck. I haven't been using c++ alot, so I don't know what I'm doing wrong. The engine works, but runs too slow. Could you guys take a quick look at my code and point out the most obvious errors in my code?
Hell veclock
Welcome to the chess engine programming world. A group of smart chess programmers are ready to help you in developing your engine after I informed them of your question here. I hope you don't mind me posting your question on your behalf there. You can ask questions and find valuable suggestions about bit-boards and other stuff here. http://www.talkchess.com/forum/viewt...448728&t=42374
I built it in MSVC 2005 and didn't find it to be painfully slow, even though it was a debug build (you should attend to the warnings by the way).
You do have some integer pow functions and some translation number <-> bit position so this page http://graphics.stanford.edu/~seander/bithacks.html might be useful. Also check your loops, it might be possible to do those operations more efficient.
You also have a thread that consumes every CPU cycle it gets. That thread isn't really needed since it doesn't do anything (but burn cycles) when it's the opponents turn. When it's the AI's turn the opponent shouldn't get any attention so you might just as well run what's in the thread at that point.
Finally, please don't post this kind of issues in this thread. This thread is solely for Visual Studio bugs. Use C++ (Non Visual C++ Issues) instead.
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
Hell veclock
Welcome to the chess engine programming world. A group of smart chess programmers are ready to help you in developing your engine after I informed them of your question here. I hope you don't mind me posting your question on your behalf there. You can ask questions and find valuable suggestions about bit-boards and other stuff here. http://www.talkchess.com/forum/viewt...448728&t=42374
regards,
Daniel
Very kind of you!
Many parts of the code is temporary, like those huge switches. I just wanted something that worked until I found out the best way.
Many parts of the code is temporary, like those huge switches. I just wanted something that worked until I found out the best way.
I think you did really well. And I agree that first thing is to get it working.
I sensed the amount of effort you put into your project which is why I "volunteered" to introduce you there. ]If you are really interested about chess programming that place is good to ask questions. Another useful website is the chess programming wiki. For example you can read about many fast bitscan routines here http://chessprogramming.wikispaces.com/BitScan .
Your alpha beta search is also a bit unconventional as explained by Sven from the link I gave in my previous post. Please register there so we can communicate better and exchange ideas. You might need to put on a brave face for some of the posts but i hope you find it worth your while
cheers.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.