1. Home
  2. Computing & Technology
  3. C / C++ / C#

Latest Programming Tutorials

About C, C++ and C# brings you tutorials for C Programming, C++ Programming and C# Programming; part works built up week by week. Choose C, C++ or C# or all three.

Latest Programming Tutorials

C / C++ / C# Spotlight10

Programming Computer Chess

Thursday July 7, 2011

In the news this week was a story about a chess program Rybka that was discovered to have been copied from top rated open source programs. The International Computer Games Association (ICGA) has decided that Rybka was cloned from the open source Crafty and Fruit chess programs and was stripped of the titles it had won.

Written in C though probably not originally, as it was first started in 1968 and in an earlier incarnation was Cray Blitz. Crafty Chess is still being developed by Associate Professor Dr. Robert Hyatt and can check 2,400,000 nodes per second on a dual Xeon 2.8ghz machine.

I've had an interest in computer chess since 1977 and wonder how long it will be before somebody uses a GPU to boost the strength of a program, if it's possible. Computer chess is at heart a battle of algorithms and processing power to look ahead and winnow down the best positions. You can investigate Crafty Chess yourself, as the source code is available for download and is free. You'll also need the opening books and end game databases for 4,5 and 6 turns which are available on his FTP site.

I've added a new page Source Code for Computer Chess and include links to Crafty, Brutus and BBChess 1.3. If you know of any others in C, C++ or C#, please let me know and I'll add them to this page. Fruit no longer seems to be available.

CodeSmell The Smell of Bad Code

Wednesday July 6, 2011

This isn't a new concept, in fact I think its been around since the early 90s, possibly earlier. CodeSmell is the feeling that you, as an experienced developer get when you examine code and know that there's something not quite right about it. There is a page about CodeSmell that tries to define what it is, what it means and has a lot of definitions.

Here are a few out of the many listed to give you a flavor! I'm sure that some of my code must "rank" high for some of these:

  • Methods too big. I.e. single methods that span pages and pages.

  • Many similar subclasses.

  • Classes becoming large and bloated

There's a lot more and it's not all one sided. Programming is as much an art as engineering but if you dvelop an instinct for what works well then you'll eventually be able to pick up CodeSmell.

A New Windows Console

Monday July 4, 2011

The current console is a hangover from the mids 90s when Windows became useful but people still needed Dos access.. As most Linux power users will tell you, a GUI is fine but without a Terminal (Linux name for a console), it's very hard to do everything and the same is true in Windows. Writing GUI programs is slower and takes more time than the console equivalent.

Developer Marko Bozikovic decided that the standard Windows console wasn't good enough and he has been working on and off for almost ten years on an improved one. His console includes multiple tabs, text editor-like text selection, different background types, alpha and color-key transparency, configurable fonts, and different window styles. If you use consoles a lot in Windows, then check this out- 748 user's recommendations mark it as something special.

Written in C++, the last full release was 1.5 but 2.00 is under development.

Create 3D Objects from 2D With OpenSCAD

Sunday July 3, 2011
OpenSCAD Polyhedron

3D graphics isn't just about playing Quake or Modern Warfare. It's about creating the graphics for those games or for more serious uses say for printing in a 3D printer such as the slice of cheese, I mean polyhedron pictured. One way to do this is take a 2D drawing then produce a 3D image from it; add depth.

This is the realm of Computer Aided Design, but not interactively like Blender. Instead you write code to do this in the cross platform open source OpenSCAD language which is a scripting language loosely based on C/C++. E.g.

for (i = [0:5]) {
  translate([i*25,0,0]) {
    cylinder(h = pow(2,i)*5, r=10);
    echo (i, pow(2,i));
  }
}
If this doesn't make sense, consult the Wikibooks hosted OpenSCAD user manual which has plenty of exampls with illustrations. OpenSCAD not only looks like C/C++, it's also written in C++.

Discuss in my forum

  1. Home
  2. Computing & Technology
  3. C / C++ / C#

©2011 About.com. All rights reserved. 

A part of The New York Times Company.