mainsworthy source code released

Discussion of chess software programming and technical issues.

Moderator: Ras

mainsworthy

mainsworthy source code released

Post by mainsworthy »

Mainsworthy source code released, hope someone will take it further?


http://wbec-ridderkerk.nl/html/details1 ... orthy.html
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: mainsworthy source code released

Post by Sven »

Many thanks for releasing your source to the public! I quickly went through the code and saw that you've put a really huge amount of work into it.

Do you plan to start over from scratch with a new engine project?

Sven
mainsworthy

Re: mainsworthy source code released

Post by mainsworthy »

Hi Sven, It was a lot of work:) Im starting over completely on a new engine, Ive learned so much from mainsworthy, and its been so enjoyable :) I can never give-up trying to make an engine.

PS: I didnt know how to make an engine when I started, so it was all trial and error
User avatar
ilari
Posts: 750
Joined: Mon Mar 27, 2006 7:45 pm
Location: Finland

Re: mainsworthy source code released

Post by ilari »

Hi Mark, and thanks a lot for releasing the source code. It's always a useful thing for beginners to do if they want to improve as programmers.

I looked at the code, and I have to say that starting over would definitely be the best and easiest choice. Mainsworthy looks like it was programmed too quickly without giving much thought for abstractions or code reuse. It has thousands of lines of copy-paste code for the simplest of things, which makes the code base pretty much unmaintainable. Always try to think of a generic solution to a bunch of similar problems before tackling each of them separately.

The coding style is also typical for a self-taught beginner, and it's quite tedious for other people to read the code. I strongly suggest reading following a style guide, something like this: http://google-styleguide.googlecode.com ... pguide.xml
The first things I would change in your code:
- Specify a return type for each function, even though int is the default type. It's better to be explicit, compilers like it better too.
- Use custom data structures instead of passing huge numbers of integer arrays between functions. Mainsworthy has functions that take over 20 parameters. That kind of code is very error prone and difficult to maintain.
- Use header files to declare public data structures and functions.
- Don't do any low-level optimization before making sure that your code functions as expected.
micron
Posts: 155
Joined: Mon Feb 15, 2010 9:33 am
Location: New Zealand

Re: mainsworthy source code released

Post by micron »

mainsworthy wrote:Im starting over completely on a new engine
Fred Brooks' famous advice on big software projects: "...plan to throw one away; you will, anyhow."

Robert P.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: mainsworthy source code released

Post by mcostalba »

ilari wrote:Hi Mark, and thanks a lot for releasing the source code. It's always a useful thing for beginners to do if they want to improve as programmers.

I looked at the code, and I have to say that starting over would definitely be the best and easiest choice. Mainsworthy looks like it was programmed too quickly without giving much thought for abstractions or code reuse. It has thousands of lines of copy-paste code for the simplest of things, which makes the code base pretty much unmaintainable. Always try to think of a generic solution to a bunch of similar problems before tackling each of them separately.

The coding style is also typical for a self-taught beginner, and it's quite tedious for other people to read the code. I strongly suggest reading following a style guide, something like this: http://google-styleguide.googlecode.com ... pguide.xml
The first things I would change in your code:
- Specify a return type for each function, even though int is the default type. It's better to be explicit, compilers like it better too.
- Use custom data structures instead of passing huge numbers of integer arrays between functions. Mainsworthy has functions that take over 20 parameters. That kind of code is very error prone and difficult to maintain.
- Use header files to declare public data structures and functions.
- Don't do any low-level optimization before making sure that your code functions as expected.
When and if you have nothing better to do I would really appreciate if you could give a look at SF coding style and highlight me some weak points and possible improvments.

As I have already stated in other posts your code is the best around I have looked so far, so I really evaluate your opinion.

Thanks
mainsworthy

Re: mainsworthy source code released

Post by mainsworthy »

Thanks all for your comments! I didnt have a clue before hand how to program chess but Im not a biginer Ive programing been since 1980, and I have studied at poly and have a C&G in cobol programming, I have plenty of programs around the net for Mac Linux and windows like wargames etc.. BUT I KNOW the code is badly set out, the code went well untill I didnt know how to program a chess engine, it was all trial and error after that(shoving variable and arrays around around etc...), if you look at the include files there a bit clearer than the main program. My programing style is my own and I dont expect you to understand it easy, I do things in my prgrams this way because Im not getting paid, and I can reuse code in my own programs better than object programming. Im not defending my style I do know its mess, but , the proof is in the eating, it plays chess !+ and it has given me an understanding I would not of had about programing a chess engine.


My chess GUI is an example that comes with mainsworty source,
some examples of other wargame project(that also work)
for the Mac Xp Vista maybe W7 http://www.thewargamer.com/grognard/godofwars.zip
http://www.thewargamer.com/grognard/avalompro.zip for winXP vista
http://www.thewargamer.com/grognard/hexover.zip
mainsworthy

Re: mainsworthy source code released

Post by mainsworthy »

good advice robert fred is so right
mainsworthy

Re: mainsworthy source code released

Post by mainsworthy »

Ilari I do appreciate your input, Im glad you took the time to look at the code thanks
mainsworthy

Re: mainsworthy source code released

Post by mainsworthy »

Hey and if you look at the code you will see me trying to hand code a negamax, untill i found the proper algo :)

I am a beginer at chess programming :)