Introducing my chess engine: GM of Logic! (w/Gui)

Discussion of chess software programming and technical issues.

Moderator: Ras

voyagerOne
Posts: 154
Joined: Tue May 17, 2011 8:12 pm

Re: Introducing my chess engine: GM of Logic! (w/Gui)

Post by voyagerOne »

Hi Colin,

I am new to JAVA...only 2 years of experience and I know my code looks like crap. I am somewhat embarrassed of my code and didn't even know that someone can view the source of an applet... :oops:

One reason why it looks so complex is because there is not one recursive function anywhere. Everything is iterative. In addition, I try to avoid creating objects and make everything static.

Again...I would never show my code to anyone...since its not really the "right" way to code.
User avatar
cms271828
Posts: 316
Joined: Wed Apr 12, 2006 10:47 pm

Re: Introducing my chess engine: GM of Logic! (w/Gui)

Post by cms271828 »

Interesting, I'm impressed that you managed to make it iterative, it seems to go against all the pseudo-code out there for alpha-beta pruning and stuff...

Well, I'll tell you how I got your code..
If I view source on your webpage, it tells me the name of the jar
So I just downloaded the jar, extracted it, then decompiled the class files into java files

Its still great stuff if you only have a couple of years experience. My first programs were badly written, but I didn't attempt chess straight away, takes a brave man/woman to go from HelloWorld to chess in one jump, lol.

I agree its not good to use objects in the engine, or at least, don't make objects every node. If you ever played a chess engine called Java Chess, it might be dutch or german, well its all done with objects, and is kinda slow, my engine beat it 4-0 when I tried it out.
I think one has to sacrifice some conventions of java when making chess engines, just so the performance is as good as possible.
Sometimes I will repeat small blocks of code, instead of putting into a method, since the method call is also an overhead for the cpu.
But I think you should leave static stuff for only when its needed, mainly utilities, and tools.
So you could create an Engine object (engine), then run do engine.search();


I'm not sure why you've done everything iteratively, I have a feeling you may struggle later on when you put in more advanced parts, but maybe not.

Good luck with it.
Colin