Sunday, 12 October 2008

Tic Tac Twiddling

With the Game of Life simulation mostly finished, I today started a new mini-project: making a Tic Tac Toe game in SDL. This will be a player-versus-computer affair when it's completed, and has a spiffy hand-drawn look to it:

So far I've finished the GUI (as you may have noticed) and most of the logic. The turns system is implemented, the player and computer can both insert their respective symbols, and it can tell if someone has won. All that's missing is the computer AI that puts in its pieces (which is why there are no crosses in the above image - the computer doesn't actually do anything during its turn yet). The next step is to try and work out an algorithm for determining which move to make each turn, and ultimately try and make the computer unbeatable. It should prove somewhat challenging, at best...

It's finished! The source code is available here.

Saturday, 11 October 2008

Game of Life... now with more SDL!

You might have been wondering why there have been no updates recently - and it's very likely that you've assumed that the cause of this is a lack of progress. Well, actually progress has been incredibly good recently; however, I have been having problems getting recent videos of the Game of Life simulation onto Vimeo. As it's been a full week since my last update, I decided that I'll just post screenshots for now and post videos when Vimeo works again.

So, firstly, I completely finished my text-based version of Conway's Game of Life. It now supports the loading of user-made text files (containing a grid of 50*25 ones and zeroes) into the simulation, and has been cleaned up significantly. The new source code is available here for your viewing pleasure.

Then, deciding it was time to continue my SDL learnings with a view to getting the GUI done soon, I continued on with some tutorials, and soon created a game/test thingy where you can add, delete and drag around a collection of clou
ds (each inscribed with a helpful "Drag me!" message):

Finally, after much procrastination (and feature creep of the test above), I decided the time was right to start making the Game of Life GUI. So, after many hours of fiddly coding and battling with screenfuls (literally) of errors, here it is - the SDLGOL:

As you'll notice, now that it's drawn onto a window instead of being displayed as ASCII in a command-line view the simulation grid is significantly larger. 200*150 cells, to be exact. And yet despite the fact that TestNeighbour() alone is now run around 240,000 times per frame, it still runs incredibly quickly - which is a testimony to the speed of C++. So, in true open-source fashion, here is the source code.

Saturday, 4 October 2008

Everybody Play the Game

So, as has been tradition for a while now, the updates here have gone all sparse again - although the last post was but two days ago, the one before is weeks old. So once again, I'm aiming to change that, the only way I know how...
A progress update!

Now, the last time I posted, I mentioned that I was learning SDL. This has been continuing, but now there is a goal - I'm trying to create a C++ implementation of Conway's Game of Life. So far, I've been battling with the most confusing errors under the sun for almost 270 lines' worth of coding, and after fixing The Strangest Two Bugs Ever To Crop Up Directly One After The Other Just To Annoy Me this morning I have got a working command-line version up and running! Here's a nice and shiny demo of it, straight from the new ExeSoft Vimeo page:

Keep watching for an SDL interface soon!

Thursday, 2 October 2008

Silly Drawing Layer? Super-Duper Loveliness? Someone Did Loads?

Well, no-one really knows what it stands for. But it is in fact the main reason I came here today with a view to posting.

SDL, or Stupid Digital Lollipop, is essentially Pygame for C++. Well, in truth, Pygame is Slimy Duck Lice for Python; Someone's Dung-Ledge is the original module. And now that I've gained some sort of coding ability in C++, I decided now would be the time to learn Scary Doodling Lithuanians. As it turns out, Scale-Drawn Lithium is quite hard. Yes, Splendidly Drunken Leige is very hard indeed.

As I'm running out of acromym ideas, I believe now would be a good time to tell of my SDL ventures thus far. Well, I decided a few days ago that I would start trying to make graphical programs in C++ instead of just console-driven ones. Firstly, I tried out wxWidgets (which spawned the awesome wxPython). Unfortunately, I couldn't even get as far as include "wx/wx.h", as MinGW (the compiler I'm using) simply refused to include it - perhaps I compiled it incorrectly, perhaps I put it in the wrong place, perhaps my system variable was dodgy; whatever the cause, it simply wasn't going to happen. So, having failed at the first wxHurdle, I decided that as Pygame is the graphics module in which I am most comfortable I should probably give SDL a go.

This ended up being an absolute unholy 'mare to install as well, but to a slightly lesser degree - I got it installed eventually! And so, having followed the obligatory "Hello World" tutorial, I now proudly present to you the fruits of my labour:

Awesome, no? Well, it's kinda cool if you've seen the source code - over 100 lines went into this simple marriage of two images on-screen. Admittedly, many of those lines were expended in superfluous comments and whitespace, but it's still gigametres away from the ~10-line Pygame version.

More updates on my progress will follow, so watch this space: " ".

It might do an amusing trick.