Artificial Life Simulator (in VB6)

This is what the Artificial Life Simulator looks like in action

The Short Description:

Here you have it: the largest, most complex programming project now available on tannerhelland.com. Originally a final project for a university bioinformatics course, my artificial life simulator has now been completely retooled as a full-blown lesson in evolution and population genetics.

As with most artificial life simulators, a set of simple artificial creatures compete for limited resources.  Each creature has a strand of pseudo-DNA that determines three basic attributes: size, speed, and range (how far it can see).  When the little critters reproduce (asexually… unfortunately), mutations may occur.  Over time, this can lead to remarkable changes in gene frequency throughout the population.  Typically the creatures with a balance of speed and range tend to win out over bigger, slower creatures and smaller, faster ones.

The code is well-optimized, so it should run decently on any hardware.   As a bonus, the simulator can be surprisingly addicting – my longest simulation to date ran for over 500,000 cycles before all the creatures died.  For further analysis of a particular simulation run, all data can be saved to a tab-delimited text file compatible with any major spreadsheet software.

The Long Description:

As you can imagine, a project of this magnitude warrants a fair amount of documentation.  I am currently working on a “how to use this software to teach evolution and population genetics” tutorial that educators – or anyone interested in biology – can read to see how things like genetic drift, population equilibrium, the “bottleneck” effect, and other aspects of a small, closed population work.

Unfortunately, a document like that takes some time to create… so rather than holding off until I’ve finished it, I’ve decided to upload the project for people to start playing with.  If you have any comments or questions, let me know and I’ll see if I can’t work answers into the final version of the tutorial.

(If you’d like to be notified when the documentation is finished, please let me know via the contact form.  I plan on sending out an email once all updates have been posted.)

 

DISCLAIMER: These download files are regularly scanned to ensure they remain free from malicious content. Unfortunately, some virus scanners will flag these .zip files as suspicious simply because they contain source code and/or executable files. I have submitted my projects to a number of companies in an attempt to rectify these false-positives. Some have been cooperative. Others have not. If your virus scanner alerts you regarding these files, please allow the file to be submitted for further analysis (if your program allows for that). This should help ensure that any false-positive warnings gradually disappear for all users.

This site - and its many free downloads - are 100% funded by donations. Please consider a small contribution to fund server costs and to help me support my family. Even $1.00 helps. Thank you!

Mathematically Generated Fire – REVISED

A demonstration of mathematically-generated fire

Because the first draft of this project has received more traffic than I anticipated, I’ve gone ahead and written a new and MUCH faster version of the algorithm.  As before, no pre-built images or palettes are used, meaning that both coloring and flame generation are done using only math (and ingenuity!).

Updates to this version include the following:

  • DIB sections are now used in place of Get/SetPixel.  This alone nearly tripled the frame rate on my old 1.6ghz laptop.
  • Flame coloring is now done via look-up tables.  Previously this was calculated on the fly, which required way too many duplicate calculations.
  • Random horizontal movement of individual flames is now calculated for every 4th pixel (instead of every single one).  Random number generation is costly, and visually this method looks almost identical (but is markedly faster).
  • Scrollbars are now available so that you can color the flames however you’d like.  Red flames, blue flames, green flames, or any combination in-between – so knock yourself out.

On my aforementioned 1.6ghz laptop, the original version of this code ran (compiled) at 6-7 fps for a 512×256 image.  The new code runs between 27 and 28 fps – or a 400+% increase.

Enjoy, and if you have any recommendations for Fire v.3, leave a comment!

 

DISCLAIMER: These download files are regularly scanned to ensure they remain free from malicious content. Unfortunately, some virus scanners will flag these .zip files as suspicious simply because they contain source code and/or executable files. I have submitted my projects to a number of companies in an attempt to rectify these false-positives. Some have been cooperative. Others have not. If your virus scanner alerts you regarding these files, please allow the file to be submitted for further analysis (if your program allows for that). This should help ensure that any false-positive warnings gradually disappear for all users.

This site - and its many free downloads - are 100% funded by donations. Please consider a small contribution to fund server costs and to help me support my family. Even $1.00 helps. Thank you!

How to Use Math to Create Fire

A demonstration of mathematically-generated fireThis fire image was mathematically generated using the code available below.

(NOTE: as of February 26th, 2009, version 2.0 of this code is available here.)

Whether working on an old-school RPG or a state-of-the-art FPS, every game programmer needs to be able to generate a fast, cool fire effect at some point in his/her career.  In this example, I’ve opted for a straightforward and easy-to-understand method for generating real-time flames.  No pre-built images or palettes are used, making the code quite small and easy to reuse.  Coloring and flame generation is done using only math and a little cleverness.  :)

To simplify the code, I’ve used SetPixelV for drawing the fire.  This slows the demo down significantly, but DIB sections could easily be dropped into place if speed is a major factor for you.

 

DISCLAIMER: These download files are regularly scanned to ensure they remain free from malicious content. Unfortunately, some virus scanners will flag these .zip files as suspicious simply because they contain source code and/or executable files. I have submitted my projects to a number of companies in an attempt to rectify these false-positives. Some have been cooperative. Others have not. If your virus scanner alerts you regarding these files, please allow the file to be submitted for further analysis (if your program allows for that). This should help ensure that any false-positive warnings gradually disappear for all users.

This site - and its many free downloads - are 100% funded by donations. Please consider a small contribution to fund server costs and to help me support my family. Even $1.00 helps. Thank you!

Basic Game Physics (Velocity and Acceleration)

This site spends a lot of time focusing on the graphical side of game programming, but what about the underlying math that drives game engines?  After an evening of being inspired by the marvelous Havok physics engine, I decided to bust out some old code and use it to demo classical mechanical physics.

A shot of the physics demo in action
A shot of the physics demo in action

The demo has a pretty simple premise – use the arrow keys to fly a spaceship (taken from the classic game Raptor) in all 4 directions and use spacebar to fire two “lasers.”  As always, the included VB6 source code is very carefully organized and commented.

Also, for any VB-haters out there, it’s worth noting that if the demo’s frame rate limitation box is unchecked, the code will easily run 500+ FPS on any modern machine.  Still think VB6 isn’t a viable choice for game programming?

As a bonus, the demo also includes the code for drawing an animated star field.

 

DISCLAIMER: These download files are regularly scanned to ensure they remain free from malicious content. Unfortunately, some virus scanners will flag these .zip files as suspicious simply because they contain source code and/or executable files. I have submitted my projects to a number of companies in an attempt to rectify these false-positives. Some have been cooperative. Others have not. If your virus scanner alerts you regarding these files, please allow the file to be submitted for further analysis (if your program allows for that). This should help ensure that any false-positive warnings gradually disappear for all users.

This site - and its many free downloads - are 100% funded by donations. Please consider a small contribution to fund server costs and to help me support my family. Even $1.00 helps. Thank you!

Color Shifting – 200% More Graphics for Free! (VB6)

Color shifting is a very fast, very simple effect that can greatly simplify the work of game artists. Here’s a demonstration (using a classic StarCraft Siege Tank):

For the record, I imagine this image is © Blizzard Entertainment...
For the record, I imagine this image is © Blizzard Entertainment...

Color shifting is relatively simple to implement – all we do is shift the red, green, and blue values of each pixel to the right (or left).  For example, a right-shift could work like so

  1. Red -> Green
  2. Green -> Blue
  3. Blue -> Red

Note that the direction of the shift is somewhat misleading (as Windows DIBs, for example, encode color bits in BGR order), but the direction isn’t nearly as important as the effect – that without any extra work, we can generate two color variations on a source image.

Because gray-toned values have RGB values that are identical (or nearly identical), color shifting doesn’t change the appearance of gray pixels.  This is pretty clear on the siege tanks above, as the color shifting merely adjusted the subtle hues of the gray regions.

However, the colored portion near the front of the tank changes drastically.  This is expected, since a sharply colored region must have large variations in its RGB values.

Can you see the obvious game design implication?  :)  If your game has the same unit available for multiple teams, races, or guilds, color-shifting can turn one base image into at least three possible team colors.  And, because color shifting is such a low-cost function, it can be easily performed on the fly – saving your artists work, and saving file bloat from redundant images.

 

DISCLAIMER: These download files are regularly scanned to ensure they remain free from malicious content. Unfortunately, some virus scanners will flag these .zip files as suspicious simply because they contain source code and/or executable files. I have submitted my projects to a number of companies in an attempt to rectify these false-positives. Some have been cooperative. Others have not. If your virus scanner alerts you regarding these files, please allow the file to be submitted for further analysis (if your program allows for that). This should help ensure that any false-positive warnings gradually disappear for all users.

This site - and its many free downloads - are 100% funded by donations. Please consider a small contribution to fund server costs and to help me support my family. Even $1.00 helps. Thank you!

Game Map Editor (Tile-Based) in VB6

Who doesn’t love a classic tile-based game?  VB6 seems to be especially popular for tile games, so I’ve put together a simple tile-based map editor for any aspiring game creators out there.

The demo is pretty self-explanatory – click on the tile bar at the top (with either the left or right mouse button) to select a tile, then click on the large center window to draw that tile onto the map.  Scrolling and zoom are fully implemented, as are saving and loading map files.  I’ve also written the engine using both StretchBlt and PaintPicture, and you can use the combo box on the left to specify a painting method.

The included tile set isn't anything ground-breaking, but it provides a good demo of how the system can work
The included tile set isn't anything ground-breaking, but it provides a good demo of how the system can work

 

DISCLAIMER: These download files are regularly scanned to ensure they remain free from malicious content. Unfortunately, some virus scanners will flag these .zip files as suspicious simply because they contain source code and/or executable files. I have submitted my projects to a number of companies in an attempt to rectify these false-positives. Some have been cooperative. Others have not. If your virus scanner alerts you regarding these files, please allow the file to be submitted for further analysis (if your program allows for that). This should help ensure that any false-positive warnings gradually disappear for all users.

This site - and its many free downloads - are 100% funded by donations. Please consider a small contribution to fund server costs and to help me support my family. Even $1.00 helps. Thank you!