Need help with compiler and language choices

Discussion of chess software programming and technical issues.

Moderator: Ras

mhalstern
Posts: 484
Joined: Wed Nov 18, 2009 1:09 am

Need help with compiler and language choices

Post by mhalstern »

It is time for my first chess program.

These are my goals:

1 - Have a program that plays a legal game of chess. It will take a position, generate all legal moves, and use a random number generator to choose one.

2 - Have the program work with basic uci and winboard commands, so it will work with common commercial and free GUI's.

I'll then share it with the community and ask for people to play some games to test it for bugs and report crashes.

After any issues have been fixed, I'll then add some logic with some simple minimax code and work from there.

I need help choosing a good compiler for my needs. I use Windows 7 64 bit. Are there good free compilers, or should I spend some money. If so, how much does a good commercial compiler cost.

I am decent programmer. I've written in old basic and visual basic, but never C or C++. Given my goals and aptitude, what is recommended for me.

Also, If I get better, it would be an interesting and an interesting challange to write the program in pure assembler. Has anybody done this? Are there any open source code examples? What tools are used now? In the old 16 bit days, it was fun to play with debug.exe, but windows dosen't have a 64 bit equilavent. They stopped supporting this a long time ago, as they never made a version that could workwith 32 bit registers.

I understand that object oriented C++ code will be much faster than higher level vb code that I would be more comfortable with, but working with VB would be easier for me to keep track of things and work with.

What is the best way to get started with this project?

Thanks
Dann Corbit
Posts: 12792
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Need help with compiler and language choices

Post by Dann Corbit »

mhalstern wrote:It is time for my first chess program.

These are my goals:

1 - Have a program that plays a legal game of chess. It will take a position, generate all legal moves, and use a random number generator to choose one.

2 - Have the program work with basic uci and winboard commands, so it will work with common commercial and free GUI's.

I'll then share it with the community and ask for people to play some games to test it for bugs and report crashes.

After any issues have been fixed, I'll then add some logic with some simple minimax code and work from there.

I need help choosing a good compiler for my needs. I use Windows 7 64 bit. Are there good free compilers, or should I spend some money. If so, how much does a good commercial compiler cost.

I am decent programmer. I've written in old basic and visual basic, but never C or C++. Given my goals and aptitude, what is recommended for me.

Also, If I get better, it would be an interesting and an interesting challange to write the program in pure assembler. Has anybody done this? Are there any open source code examples? What tools are used now? In the old 16 bit days, it was fun to play with debug.exe, but windows dosen't have a 64 bit equilavent. They stopped supporting this a long time ago, as they never made a version that could workwith 32 bit registers.

I understand that object oriented C++ code will be much faster than higher level vb code that I would be more comfortable with, but working with VB would be easier for me to keep track of things and work with.

What is the best way to get started with this project?

Thanks
C++ compilers:
http://www.microsoft.com/express/Downlo ... Visual-CPP

http://www.mingw.org/wiki/HOWTO_Install ... iler_Suite

http://www.cadforte.com/system64.html

VB Compilers:
http://www.microsoft.com/express/Downlo ... sual-Basic

vbnc:
http://www.mono-project.com/VisualBasic.NET_support

If you use vb, take a look at some of the vb chess projects for a leg up.

If you use vb, you will have between a 4:1 and a 2:1 speed penalty compared to C++ or perhaps 50-100 Elo.

Most .net chess engines are written in C#, but perhaps this query can help:
http://www.google.com/#hl=en&rlz=1W1GGL ... c11af51e1c
Dann Corbit
Posts: 12792
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Need help with compiler and language choices

Post by Dann Corbit »

Writing a chess engine in assembly language today is lunacy. Don't do it.
User avatar
Greg Strong
Posts: 388
Joined: Sun Dec 21, 2008 6:57 pm
Location: Washington, DC

Re: Need help with compiler and language choices

Post by Greg Strong »

This post is difficult to respond to.

What is the ultimate goal? In the short term, you know VB. So, you can go forward with that and get a reasonable chess program. But it will preclude you from making a really strong program. On the other hand, you don't know C. Do you try to cross that bridge at the same time you're trying to make your first chess program? Probably not.

I'm going to make a suggestion that I think is reasonable, although others would of course offer different advice.

Download Microsoft Visual C# Express Edition. It's a nice language with a nice, powerful development environment, and it's totally free. The down-side is that, like with VB, it builds code that runs in a just-in-time compiled VM, so it can't be a top-notch chess program. But it's a reasonable choice for a first attempt at a chess program, it's a great language to know if you're looking for a job. And, since the syntax is similar to C++, it will get you one step closer if you chose to go forward and attempt a second chess program in C++...
Dann Corbit
Posts: 12792
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Need help with compiler and language choices

Post by Dann Corbit »

Dann Corbit wrote:Writing a chess engine in assembly language today is lunacy. Don't do it.
As to your original question about engines written in assembly:
There have been several, including Rebel by Ed Schroder

I guess that eventually, everyone who chose assembly was very sorry about that choice.

The C language is more or less a portable assembly.

The big problem with assembly is that it is totally non-portable.

For instance:

MOV EAX, 0 ; Nice for 32 bit Intel CPU, but not for 64 bit registers
Dann Corbit
Posts: 12792
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Need help with compiler and language choices

Post by Dann Corbit »

Greg Strong wrote:This post is difficult to respond to.

What is the ultimate goal? In the short term, you know VB. So, you can go forward with that and get a reasonable chess program. But it will preclude you from making a really strong program. On the other hand, you don't know C. Do you try to cross that bridge at the same time you're trying to make your first chess program? Probably not.

I'm going to make a suggestion that I think is reasonable, although others would of course offer different advice.

Download Microsoft Visual C# Express Edition. It's a nice language with a nice, powerful development environment, and it's totally free. The down-side is that, like with VB, it builds code that runs in a just-in-time compiled VM, so it can't be a top-notch chess program. But it's a reasonable choice for a first attempt at a chess program, it's a great language to know if you're looking for a job. And, since the syntax is similar to C++, it will get you one step closer if you chose to go forward and attempt a second chess program in C++...
The syntax is an awful hybrid of VB, Delphi, and C++ and a very lousy way to attempt to learn C++ (IMO).

It might be a little closer than VB.NET, but if the O.P. wants to learn C++, I would suggest reading Bjarne's book (and a couple other good ones).

To learn a high level language, C will be a lot faster because it is a small language in terms of the total grammer and library. I guess it is less than 1% of the size of the C++ grammar and library (especially if you include boost as proposed).
User avatar
Greg Strong
Posts: 388
Joined: Sun Dec 21, 2008 6:57 pm
Location: Washington, DC

Re: Need help with compiler and language choices

Post by Greg Strong »

I basically agree with your points. However, in jumping to C, you enter a non-managed environment wherein you can screw yourself in an instant and spend days or weeks trying to find the problem. If you're used to high-level languages only, jumping straight into C, the world's most dangerous language (except assembly), is a very bad idea, IMHO. C# is a small step in that direction.

EDIT: I also don't see it as an "aweful hybrid." And certainly not a VB hybrid. It's nothing like VB at all.
mhalstern
Posts: 484
Joined: Wed Nov 18, 2009 1:09 am

Re: Need help with compiler and language choices

Post by mhalstern »

Thanks for the replies.

Dan,

Thanks for the links.

The Microsoft download site states:

Visual Studio 2008 Express Editions are free development tools.
Register your product within 30 days from installation.

Are these fully functional? Do I have to pay after 30 days?
User avatar
Greg Strong
Posts: 388
Joined: Sun Dec 21, 2008 6:57 pm
Location: Washington, DC

Re: Need help with compiler and language choices

Post by Greg Strong »

You do not need to pay - registration is painless and they are fully functional. The Express Edition is, of course, lacking some enterprise functionality, like a code profiler (showing how much CPU time is spent in each function.) But it includes everything you will need to go a long way ...
Dann Corbit
Posts: 12792
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Need help with compiler and language choices

Post by Dann Corbit »

mhalstern wrote:Thanks for the replies.

Dan,

Thanks for the links.

The Microsoft download site states:

Visual Studio 2008 Express Editions are free development tools.
Register your product within 30 days from installation.

Are these fully functional?
Sort of. The optimizer is not as powerful as the expensive one.
[/quote]
Do I have to pay after 30 days?[/quote]
no