Tuesday, February 23, 2010

About C / C++ / C#: A Prediction for 2010 - Online Games

If you can't see this email, click here

About.com

C / C++ / C#

Fundamentals

Tips & Tools

Going Pro



From David Bolton, your Guide to C / C++ / C#
By coincidence I predicted that running games in the browser would be a trend for 2010 and also discovered a game server service (http://playerio.com) that lets you write multi-player browser games. On a related note, I saw a very sensible point why a large number of Flash games would not easily move onto the iPhone/iPad that easily. Those games that rely upon some kind of cursor or mouse pointer would need a rewrite for the touch interface. It makes you think! Have a great week!

A Prediction for 2010 - Online Games
FreeCiv A little bit late to start predicting this year, but probably good for 2011. When I notice something once, it may be a fluke, but twice and it's probably not and three makes it a dead cert or at least a trend. The trend in question is taking an existing game and running it in a browser. There's an awful lot of open source games to tap into. The newest generation of browsers able to do fast JavaScript, Google's Chrome for example uses the V8 engine so those games can run pretty quick. These Games in question were originally written in C or C++.
  1. Quake III- Quakelive.com - Runs as a browser addin.
  2. M.U.L.E - See PlanetMule.com. This has been rewritten in Java.
  3. FreeCiv on Freeciv.net - JavaScript front end, C server backend. You can even play it on an iPhone 3GS.
If you know of any others, please let me know.

Changing Command Line Input in C#
The System.Console class has a couple of methods for controlling where input and output come from. The SetIn() and SetOut() methods switch input or output so that any of the read or write methods use the new stream. These methods require a TextReader or TextWriter which are abstract base classes and so not used directly. Instead StreamReader or StreamWriter are used. This code below shows this in action, changing input to come from a text file. I've also added this as a quick tip.   using (StreamReader SR = new StreamReader(@"C:\path\example.txt")) {     Console.SetIn(SR) ;     string line;     while ((line = SR.ReadLine()) != null)        {          // Do something with line        }    }

Wrie Your Own Flash Player
While you could start from scratch and write one, it's a bit pointless given that there is an open source implementation of the engine from Flash Player 9 by Adobe and this is available as a Mozilla project called Tamarin. Written in C++, Tamariin is a high-performance, open source implementation of the ActionScript 3 language. ActionScript provides many extensions to the ECMAScript language, including packages, namespaces, classes, and optional strict typing of variables. Tamarin implements both a high-performance just-in-time compiler and interpreter. This is done with Adobe's blessing and the source code is triple licensed so you choose which to use and it is cross platform. In theory then you could host Flash applications within yours and while I can't imagine many C++ applications using a Flash interpreter (except for browsers), it remains an interesting possibility.

Never Programmed Before? Start Here
For the complete novice to computer programming. Learn how a computer works and how to control it by writing computer programs.

 


C / C++ / C# Ads
Featured Articles
Other Blogs You might find Interesting
Welcome to the C Area with Articles about C Programming
Welcome to the C++ Area with Articles about C++ Development
Welcome to the C Sharp Area with Articles about C Sharp Development
Learn about Commercial Software Development
All about Games Programming

 

More from About.com

Managing Dog Behavior Problems
Understanding common dog behavior problems like barking, biting, and chewing is key to handling them appropriately. More >

Healthy Bodies, Healthy Minds
Keep yourself, and your family, happy and healthy this fall with these tips. More >


This newsletter is written by:
David Bolton
C / C++ / C# Guide
Email Me | My Blog | My Forum
 
Sign up for more free newsletters on your favorite topics
You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter. If you wish to change your email address or unsubscribe, please click here.

About respects your privacy: Our Privacy Policy

Contact Information:
249 West 17th Street
New York, NY, 10011

© 2010 About.com
 


Must Reads
Programming Challenges
About C, C++ and C#
C++ for Beginners
C++ Programming
Intro to OOP

Advertisement

Tuesday, February 16, 2010

About C / C++ / C#: Sticking My Neck Out

If you can't see this email, click here

About.com

C / C++ / C#

Fundamentals

Tips & Tools

Going Pro



From David Bolton, your Guide to C / C++ / C#
Being experienced at programming does not guarantee that you can write Challenge winning Bots, but I decided for once to enter a Challenge. It's the Google AI Challenge I wrote about last week. The Details are below so you can follow my progress and success or failure. So long as it doesn't come last I'll be happy, but a top ten position would be nice! I'll have a very busy week, you have a great one!

Defragging A Drive
Hard Disks store data in concentric circles on a disk. Each circle is called a track and is made up of a number of sectors each holding data in a block of a few Kb in size). As files are usually much bigger than a sector, they are spread across many sectors and sometimes many tracks. Over time, as files are deleted and created, it may not be possible to store a file in consecutive sectors and reading it may take longer as the head has to wait for the other sectors and this can be a rotation or more which is a long time. It's fascinating watching the head move across the disk and a tribute to precision engineering that it can so quickly and precisely move to a specified track. Because the disk read head floats on a microscopic cushion of air that is less than the thickness of a human hair, you don't normally get to see the head moving as its in a case where the air is kept free of impurities, dust etc. Removing the case (as in the disk in this video Hard Disk) means that the disk is doomed to earlier failure though how soon depends on the air quality. More disk reads or writes means slower file I/o and that's when defragmentation software comes in to reorganize the sectors on disk. Windows has a rudimentary defragger but you can get a powerful open source one that does every version of Windows from NT onwards (not 95 or ME). Written in C, UltraDefrag is at version 4.0 and is designed to defrag as fast as possible. It can also move files to optimize for fast disk operations and also defrag during the boot up for those system files and registry that can't be defragged during normal operation. The thought of developing defraggers has always been a bit scary as the potential to mess up a disk seems quite high so congratulations to Dmitri Arkhangelski the author and his team for their work which is GPL licensed.

Kayak C# HTTP Server
Kayak is interesting, especially if you're considering writing a game server as I do from time to time. I don't think its a full web server as much as a http server and request handling framework that maps http calls to C# methods with minimal syntax. The whole http model was designed nearly 20 years ago for sending text files to a browser. A full web-server does an awful lot more than Kayak usually through 3rd party modules, think cookies, authentication, JavaScript, and all of the complex http protocol that deals with page caching, expiry etc. Kayak has stripped that all away so you can add your own code from the ground up and build something entirely differently but still working of a basic http protocol. I wonder if it will work out the box on Mono.

Google AI Challenge - I've Entered it
I'm not saying my Aboutbot entry will be any good and I'm not going to publish the source code until later this week but I fancied having a go at the Challenge, (see my entry about it) and even in the 12 days left I hope to have a bit of fun as I normally don't enter any challenges that I run, except where I have to write code to mark them or generate the answer. It's not the same anyway! So I'm sticking my neck out. As challenges go, writing a winning entry is an interesting task. You are given a map, and can get the location of where your opponent is at any time so what strategy to use? My first strategy is making sure my bot has plenty of room to roam in. That means identifying danger areas on the map and avoiding them. The first turn can be up to 3 seconds long. So my C# bot will generate a heat map with one byte for every map location indicating proximity to a wall, ranging from 0 (no danger) to 255 (wall) and points between. As the round progresses I'll update that with walls (both mine and my opponents) so that my bot can try and keep to the wide open vistas. However that has to be tempered with trying to trap the opponent's bot. The API allows reading of the opponent's bot's position so knowing where it is, my bot needs to head for it and try and limit the available space it has to maneuver in. If my bot can box it in and stay mobile itself then it wins the round. The first entry went in today (just the default C# bot) and is 418th (page 5) on the ratings page so plenty of scope for improvement. I'm now busy coding a new bot now and will keep entering revised bots so keep looking out. Anyone else got a bot entered we can watch? Email me and I'll publish their names.


Looping Loops Programming Challenge
This runs until the end of February 2010. Write code to complete loops.

 


C / C++ / C# Ads
Featured Articles
Development Projects from Initial Design to Completed Code
Reviews of Software - Tools, Compilers, Editors etc
Book Reviews
Top Tools, Utilities and Resources
Glossary of Programming Terms

 

More from About.com

Managing Dog Behavior Problems
Understanding common dog behavior problems like barking, biting, and chewing is key to handling them appropriately. More >

Healthy Bodies, Healthy Minds
Keep yourself, and your family, happy and healthy this fall with these tips. More >


This newsletter is written by:
David Bolton
C / C++ / C# Guide
Email Me | My Blog | My Forum
 
Sign up for more free newsletters on your favorite topics
You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter. If you wish to change your email address or unsubscribe, please click here.

About respects your privacy: Our Privacy Policy

Contact Information:
249 West 17th Street
New York, NY, 10011

© 2010 About.com
 


Must Reads
Programming Challenges
About C, C++ and C#
C++ for Beginners
C++ Programming
Intro to OOP

Advertisement

Tuesday, February 9, 2010

About C / C++ / C#: Challenge 31 Marked

If you can't see this email, click here

About.com

C / C++ / C#

Fundamentals

Tips & Tools

Going Pro



From David Bolton, Your Guide to C / C++ / C#.
Congratulations to Adrian Grigo of Australia for a 57.8 nanosecond speed entry, that's the fastest ever in any programming Challenge and most certainly pushing the limits of my PC. Thanks to both Adrian and Gabriel Dubois for their entries in Challenge 31. Meanwhile Challenge 32 is now underway. Last week also saw the next C++ tutorial published and a C# one is nearly completed. Have a great week!

Google AI Challenge - Play Tron
Tron BikeTron was a so so film from the early 80s when Computer Generated Images were a lot cruder than today and I believe a sequel is on its way. For the time it had a few Wow moments and it spawned a computer racing game where you and your opponents have bikes that leave a wall behind as you zoom through an entry. You bot must outlast your opponent and not crash because it ran out of space. That game is the subject of an AI challenge at the University of Waterloo in Canada and is sponsored by Google. C++ and C# are among the allowed languages for entries and you can compile the C++ starter package with Visual C++ Express Edition or GCC. The interface is very very simple so even beginners should be able to write code for this. There are a variety of test courses provided in text files and bots (in Java). A C# starter pack will be provided shortly. About the only rule is don't take longer than a second to decide your move. The Challenge runs through most of February and started on February 4th so you can start now. There are already 166 entries so don't expect it to be easy!


New C++ Tutorial Published
Text files, love em or leave them are a vital part of computing. An XML file is just a text file holding xml data. I regard them as a necessary evil. So this tutorial, with 8 examples shows you how to read and manipulate text files. The last two examples are longer and show how to read a config file to memory and then access it. One version uses pointers, the other vectors. Rather than have 8 different downloads, all source files are bundled up in one zip file. Enjoy!


How Open Source Spreads out
An open source project starts for one platform, most likely Linux and a few developers are attracted to it and it gets released. However one or two developers also use Windows so they build binaries for Windows and maybe Mac, Solaris etc. The project expands and then the organizers decide to make it cross-platform using Qt or WxWidgets etc. An example- DigiKam. This also fulfills Bolton's 18th law of Computing- If a project name has a K in it, it probably was originally developed for KDE. This powerful software, written in C++ is for managing a photo collection, from reading the raw images from something like 1,000 different digital cameras, storing the photos with all the EXIF data, tracking and tagging photos and then displaying them. DigiKam uses Qt 4 for cross-platform, as since Qt 4 was GPL'd KDE software (using Qt 4) can be distributed to Windows and Mac.

Never Programmed Before? Start Here
For the complete novice to computer programming. Learn how a computer works and how to control it by writing computer programs.

 


C / C++ / C# Ads
Featured Articles
Other Blogs You might find Interesting
Welcome to the C Area with Articles about C Programming
Welcome to the C++ Area with Articles about C++ Development
Welcome to the C Sharp Area with Articles about C Sharp Development
Learn about Commercial Software Development
All about Games Programming

 

More from About.com

Managing Dog Behavior Problems
Understanding common dog behavior problems like barking, biting, and chewing is key to handling them appropriately. More >

Healthy Bodies, Healthy Minds
Keep yourself, and your family, happy and healthy this fall with these tips. More >


This newsletter is written by
David Bolton
C / C++ / C# Guide
Email Me | My Blog | My Forum
 
Sign up for more free newsletters on your favorite topics
You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter. If you wish to change your email address or unsubscribe, please click here.

About respects your privacy: Our Privacy Policy

Contact Information:
249 West 17th Street
New York, NY, 10011

© 2010 About.com
 


Must Reads
Programming Challenges
About C, C++ and C#
C++ for Beginners
C++ Programming
Intro to OOP

Advertisement