Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Idiot Question 1

Status
Not open for further replies.

stormbind

Technical User
Mar 6, 2003
1,165
GB
Hi,

I'm no C programmer but I would like to translate my chess playing AI from JavaScript into C.

I have been pointed to: but it's all rather confusing! :(

In the first instance, I would like to know if there is a C parser: to run a C program as a script without compiling it?

If not, could someone simplify the compiling process for a newbie? Thanks all!

P.S. I made the assumption that C would be the fastest solution for performing an extreme number of loops. Is the assumption correct?

Thanks again! :)

----------
I'm willing to trade custom scripts for... [see profile]
 
> I would like to know if there is a C parser: to run a C program as a script without compiling it?
Yes there is - There is even a win32 port available.

> I have been pointed to: but it's all rather confusing!
I would suggest you get Dev-C++ from This is actually a nice Integrated Development Environment (IDE) which sits on top of the mingw compiler you were pointed to. It provides a nice windowy experience, with lots of menus and icons to fiddle with.

Getting going.
Select the project menu, and select a console application. I think one of the sub-options is to create a "hello world" application. This initialises your project with the archetype first program for you to try out.

Then choose the build option to create the program executables.

Then choose run to see it happen.

> Is the assumption correct?
Pretty much, though there are no black and white answers here. Benchmarkers just love coming up with cases which show that X is better than Y. As a general purpose language, its performance will always be there or thereabouts compared to other compiled languages.

A good assembler programmer will always beat 'C' given enough time to write the code (at the expense of having to tweak/rewrite the code for each new processor).

--
 
Strong emphasis on "good" assembler program! A good C program compiled by a good C compiler will beat the socks off a bad assembler program any day. And even more important, especially in chess, a good algorithm botched together in a slow language will completely and utterly, remorselessly, Flatten the very best hand-tweaked assembler version of a poor algorithm.
This is actually a really important concept; once you've moved to assembler it is such a horendous job to modify your algorithm that you simply won't do it, so sticking to C will probably give you a better program. Look at things like Crafty; last time I bothered finding out, Crafty was firmly non-assembler.

 
Yeah as lionelhill said, double check your code and optimize it in general as much as possible. An O(n) algorithm will run faster in a scripting environment then say a O(n^3) algorithm given enough elements.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top