Sunday, April 27, 2008

Monster Hunter secret origins

The monster hunter game was a game that had to be included in my Ultimate Retro Project and was originally going to be placed into the first volume as it had a lot in common with the early style of seeking games that were common in the early seventies. While I never played these text games until the mid eighties and did so by typing in the BASIC game from a listing and running the game where finding all the inevitable bugs really helped me learn to program. Besides, I couldn't afford to buy that many games so typing in games from library books or magazines helped keep me entertained as a kid. I decided to place it into the adventure game collection when I realized that it essentially had a lot of the early elements that later text adventures would utilize and beating up monsters definitely has the ring of role-playing to me.

The Monster Hunter game was derived from a number of monster hunting games, though the biggest influence on this game was the classic game by Gregory Yob known as “Hunt the Wumpus.” This game was kind of unique as it's map was a squashed dodecahedron instead of a regular grid like most other monster hunting games of it's time. Considering that computers were quite limited in 1972, the year that the game came out, it was quite an impressive game for it's time not to mention the game that finally taught me how to take advantage of arrays and data structures.

My monster hunter game uses a flexible map file that allows for the creation of any type of map, though the initial map is a dreaded grid. Perhaps if there is interest in this game I will create a squashed dodecahedron map and a few other alternative maps. I, however, suspect that this game is going to be more of a curiosity than anything. The number of traps in the game is controlled by the map file, as is the number of arrows within the map. My game will start the player off without any arrows, though there will be a number of arrows (determined by the map configuration) that will be hidden through the map. All the monsters, traps, arrows, and the players starting position will be determined randomly.

What is really interesting about the code I am writing for this game is that a lot of the code that goes into this game is shared with the later adventure game that will be developed. The adventure game is obviously inspired by Colossal Caves, but that is a different story.

Thursday, April 24, 2008

Ubuntu 8.04 released.

Modern Light Box was just posted on Blazing Games. I was originally going to post a strategy guide for Light Box today but then I found out that Ubuntu 8.04 LTS was officially released today so I decided to change the topic for today. Actually, when I think about it, perhaps giving readers a chance to play the game and figure out their own strategies before giving them mine might be the best way of doing things anyway. I will probably post the strategy guide next week. Today I am going to talk about Ubuntu.

Ubuntu is a distribution of the Linux operating system. Linux is a free open source operating system that has become a major contender in the operating system space. Like OSX, Linux is a version of the Unix operating system but unlike OSX you can run the operating system on any computer you like. One arguable downside to Linux, however, is the fact that there are a number of different distributions, each with it's own advantages and disadvantages. Ubuntu is a distribution that is focused on making Linux usable by everyday people in addition to all the geeks that gravitate towards Linux. It has grown quite a bit in popularity which is good. Not only can you download the distribution for free, the disks can also be ordered and they even have a program where you can obtain the disks for free.

This is the part where I describe the latest version, except I can't. While I have tried a couple of times to upgrade from 7.10 to 8.04, the demand for the upgrade is so high that just like the Nine Inch Nails Ghost download (they have just released a new single that is freely downloadable from the nin.com website), I can't get it. I am sure that in a day or two all the situation will have calmed down and I will be able to upgrade my Linux machine. If you are interested, you can go to http://www.ubuntu.com/ to get your copy. It would probably be best to wait a few days before doing so.

Sunday, April 20, 2008

The Lorenz Attractor

As Professor Edward Lorenz died of Cancer on Wednesday, I thought it would only be fitting that today's article be about the Lorenz Attractor which is one of the earliest (if not the first) example of chaos theory. Chaotic systems are those in which a very small change can have a drastic impact on the outcome of the system over time. The butterfly effect is probably the best known example of this. Essentially, a butterfly flapping it's wings can as a result alter the weather weeks in the future. This happens because the extremely small change in the weather pattern can slowly be amplified over time. This is also the reason why we are so poor at predicting the weather.

Professor Lorenz discovered this fact in the early sixties when he was trying to develop a computer model of the weather. Back then computers were not that powerful so the professor simplified the model so that it consisted of three differential equations:

  • dx/dt = 10(y - x)
  • dy/dt = xz + 28x - y
  • dz/dt = xy - (8/3)z

When running these equations, Professor Lorenz found that if he tried to pick up the equations from where he left them in an earlier run that the outputs were not the same. After verifying that the computer was in fact working properly and that there were not any bugs in his program, he isolated the problem down to the precision in which he was entering the information. He was only entering the data to 3 decimal places where as the computer was keeping the data up to 6 decimal places. Did I mention that this was the sixties and that the computer was primitive?

The result of this is the discovery of Strange Attractors. Other forms of chaos, such as fractals and the Mandelbrot set, have since been discovered and have been used in the generation of some of the most incredible graphics and animations. There are a number of open source programs that can plot these equations for you and there are certainly many books on the subject. I personally feel that it is more fun to write your own generator, but then I like programming and find the programming aspects as much fun (if not more fun) as looking at the results.

Friday, April 18, 2008

Some early May planning

It is kind of appropriate that this week's game on Blazing Games is an episode of One of those Weeks because this has been a pretty bad week. I had meant to write an article for the middle of the week but simply didn't have the energy. While I could go into details about why my week was bad, I doubt anybody cares so will instead keep this post relatively short and provide a few details about what I am thinking about doing for next month's releases.

Next month has five Friday's so there will be an extra week that I need content for. I am pretty sure that modern minefield will be finished this weekend. The open source release has already been planned for the next couple of months. That leaves two weeks and I did want to double up on One of those Weeks releases so I think that is what I will be doing. This leads to a bit of a problem. I don't want to give away any details of what is going to happen to the story. Having a short description and screen shot for episode 38 would kind of give away a bit too much as people would not have played episode 37 yet. My thoughts at the moment would be to just have the name and episode number and leave the description and screen shot blank until the game is released.

Sunday, April 13, 2008

Recursion

Classic minefield is now finished, and I should have the modern version finished next Sunday. Part of the minefield core game revolves around the use of recursion so today I am going to explain the concept behind recursion while using minefield as an example.

In mathematics, a function that calls itself is said to be a recursive function. This technique can also be useful for all sorts of programming problems as long as the function is properly written. The problem with recursion is that a poorly written recursive function can be dangerous. Lets take a look at recursion and how it was used in the Ultimate Retro Projects' minefield games.

In the minefield game, the player has to uncover hexagons which reveal how many nearby hexagons have mines in them. In some cases, there will be hexagons that have no mines near them. In these cases, the player would automatically uncover all the surrounding hexagons, which is a pain. To make the game flow faster, this is automated for the player so that clicking on a hexagon with no mines will automatically uncover the surrounding hexagons. This uncovering of tiles is done in the uncover function by calling the uncover function for each of the surrounding hexagons.

The reason that the uncover function is called instead of just automatically marking the hexagons as uncovered is due to the obvious fact that it is possible that one of the uncovered hexagons may also not have any mines nearby. However, this leads to a potential problems that can cause an infinite recursion to occur. Technically speaking, infinite recursions don't happen in Java because making function calls uses stack memory so the recursion will eventually run out of stack memory causing an exception to occur. The net result is still the program crashing so obviously infinite recursions are something you want to avoid.

The potential problem is that if uncover detects that the hexagon is not near mines, then the surrounding hexagons are uncovered. If one of the uncovered tiles also has no mines, it is going to try and uncover the hexagon that is responsible for uncovering it. This continues back and fourth until the call stack is filled. The solution to this problem is fairly obvious. You simply need to check to see if the tile that is about to be uncovered has already been uncovered If so, immediately return from the function with the uncovered value.

The above example points out the key thing that has to be kept in mind when you are creating a recursive function. You must always make sure that the recursion has a stopping point and that the end of the recursion will always reach this stopping point in a reasonable amount of time. In fact, some people place recursive functions in the same category as self-modifing code and the goto statement and consider it bad. It is always possible to avoid recursion but often recursion is the fastest and easiest way to implement something.

Thursday, April 10, 2008

Dozen Day Plans

Before I get to the bulk of this post, I'll just let you know that Classic Light Box has been posted on Blazing Games. I don't know if I would consider this entry as an article, more like an update on the plans for Blazing Games. In particular, I am going to give some heads up details on what I am planning on doing with my Dozen Days series.

At the start of 2008 I was going to use the dozen days project as a monthly game release that would be developed live on the site. Two episodes were developed live on the site, but there seemed to be very little interest in the live aspects of the release. When you add the fact that developing the game live adds addition stress to an already stressful development the lack of interest makes doing the episodes live not worth the effort. More to the point, when I did the second live game, I did so when I was sick and had a really hard time doing it with the easy game taking twice as long to write as it should have. Had there not been a live aspect to the development, I could have simply put off the development by a week or two and done the proper thing by taking the day off.

As regular visitors already know, I am currently spending Sunday afternoon working on Ultimate Retro Project and at the moment development on those episodes are on fire! This means that I am filling up all of my Friday release slots at a rapid rate so don't really need to have any Dozen Days episodes. I have also decided that keeping the source code closed for a game in a day project does not make that much sense and all future releases of Dozen Days episodes will have the source code as part of the release. That being said, for the next three months I am going to be releasing the source code and diaries for the first 6 episodes!

The first six episodes were developed using Flash CS3, which is not the most open source format to use due to the fact that Flash CS3 is an expensive tool. That is why I am going to be making a transition from Flash over to writing pure ActionScript 3 games that can be compiled using the freely available Flex 3 SDK. Vector graphics and animations will probably still be created in Flash CS3 but because those assets are strictly artwork resources it would be easy for somebody to replace them without needing an expensive tool.

Before I make the switch for Dozen Days work (which will happen with the development of the official seventh episode even though technically it is the eighth episode created for Dozen Days of Dice) I am going to first create a different game using the Flex 3 SDK for compiling the game. This game is going to be an updated version of Thirteen Spikes. Obviously, I have great hope that this game will be finished before June 13 for reasons obvious to anybody who owns a calendar.

After June I am hoping to release new episodes of Dozen Days every month or so and will probably have sneak previews of those games available for readers of this blog.

Tuesday, April 8, 2008

Google App Engine

On April 7, 2008 Google announced the release of their Google App Engine. It is a SDK and hosting service for the creation of web applications. Sadly I never heard about it until this morning so when I went there and tried to register an account, I found out that all 10,000 accounts that were made available for testers have been taken, though the SDK can still be downloaded if you are interested. This is kind of disappointing because I think that the Google App Engine would be a perfect platform for experimenting with my development of multi-player games. This is largely because the platform hosting is free for small projects and you only have to pay for the service once your service has reached a high enough threshold. That threshold is roughly the equivalent bandwidth or processing power equivalent to five million page views per month.

One of the features that the Google App Engine offers is the ability to use the Google user accounts for tracking users of the service you create. This would essentially mean that the work that would be required to create a secure registration system for users is already done so all the overhead for doing that (not to mention the additional costs of getting a SSL certificate) is gone making it much easier to set up a multi-player game service.

Of course, I would not just be creating a multi-player game but would want to also create tools that would allow the players to create their own content for the game. The game would likely be a strategy game that would be using hex maps. I have the game in my head so once the Ultimate Retro Project has been finished I will start playing around with the SDK and once I can get a proper account then I will post early builds of the game for those of you who are interested.

One criticism that I keep hearing about the SDK is the fact that the language used to program the applications is Python. When you consider the fact that there are a lot of Python programmers at Google, this decision does make a lot of sense. More importantly, Python is a very simple language to learn and is very scalable. To be perfectly blunt, if you can program in one language, switching to another language is relatively easy as most of the core concepts are the same. I don't think that the language is an issue, and Google has stated that other languages will eventually be supported.

Sunday, April 6, 2008

Ultimate Retro Minefield Hex Maps

Classic Minefield playable version has been posted to the ultimate retro project repository. It still need to put in proper level selection but the game is fully functional and the instructions have been written. I hope to have the release candidate ready next week. Now, the article about hex maps that I promised.

Hex Maps

The Minefield game I am developing for the Ultimate Retro Project uses a hex grid instead of your typical square grid. The reason for this decision was twofold. First, I wanted my minefield game to be different from other ones that I have seen and having a different type of grid certainly accomplishes that goal. The second reason was future planning. I knew that in the future I wanted to create some strategy games and a lot of the pen and paper strategy games use hex maps. The thought here is that by using hex maps in my Minefield game I would be able to build some of the basic technology that would be used by future games. Those strategy games are still in the back of my mind so perhaps someday this will actually happen but I have other projects that need to be finished before I even think of developing these future strategy games.



The key question is why do so many pen and paper strategy games use hex maps? The answer to that is that you gain more flexibility in movement. A square only has four directions that you can move in while a hex map gives you 6 directions. If you count diagonal directions then the case for hex maps grows even stronger. With a square grid, you would have 8 directions, with the cardinal directions having an distance of 1 unit while the diagonal directions having a distance of 1.4142 so moving diagonally gives a player extra movement which in strategy games may not be desirable. More to the point, if you do allow for diagonal movement, then the hex map gives you 12 directions and the error for moving diagonally is slightly smaller so diagonal movement on a hex map gives a player less of an advantage.

Implementing a hex map

When I got around to working on hex minefield, the first problem I encountered was the big one of how to actually deal with the hex map. Grids are very simple to deal with, but the hex map looks much more complex. Thankfully, this was one of those cases where looks are deceiving. When originally working out the code I looked at a sheet of hex paper while scratching my head. I then looked up at my ceiling which happens to have an offset grid pattern on it. Looking back at the hex paper, the obvious solution immediately clicked in. A hex map is essentially a grid but with ever other row offset by half a square. That may not be technically correct, but from a data management point of view it works perfectly. What this means is that map information can simply be stored as if it was a grid making it incredibly easy to manipulate.

Movement through the map is a bit trickier. How the hexes are laid out can alter this, but if the point of the hex is facing North then movement through the grid is as follows:

  • North East = X + 1 if on odd row otherwise X unchanged, Y - 1
  • East = X + 1, Y unchanged
  • South East = X + 1 if on odd row otherwise X unchanged, Y + 1
  • South West = X – 1 if on even row otherwise X unchanged, Y + 1
  • West = X – 1, Y unchanged
  • North West = X – 1 if on even row otherwise X unchanged, Y – 1

Determining if the row is even or not can be done using a very simple boolean operation. if ((row & 1) == 1) then the row is odd.

Wednesday, April 2, 2008

A slight change in direction

I have decided to take the direction of this blog in a slightly new direction. As I look over my posts, I am thinking that instead of breaking a topic into multiple short posts, I would be better off reducing the frequency that I post and instead focus on writing longer posts that better cover the topic I am going to write about. Of course, the articles will follow the basic topic of game development, though I want to focus more on the theory behind the code rather than doing step by step code dumps. The first article that I am planning on writing will likely appear Sunday and will be about hex maps. There will still be posts whenever something important happens. Likewise if there is a particularly compelling news event, this blog will be used as my way of expressing my opinion.