Friday, February 10, 2006

Virtual World Building is the subject of building computer models or simulations of the world. This is on the border between serious scientific modeling and the simulated environments of games. It's intended to be educational and exploratory.

I've been an avid reader of science fiction and fantasy, a player of computer games and a little bit role-playing, and have some education in the sciences, mathematics, and computer programming, and a taste for individuality as well as improving on different things. What this qualifies me to do is not clear, but world-building and simulation are some of my passions, and so I hope to open a discussion of some of the techniques.

I'm assuming readers have an elementary knowledge of C/C++ computer programming, but since my computer and programming manuals are in storage some distance away, I can't easily check my work or try techniques. Suggestions and corrections are invited.


To begin with, a virtual world needs time. Simulations do not have the luxury of being open-ended; they need a beginning and an end of some kind. It's probably not possible to make time pass continuously as in the real world. What can be done is to divide it into arbitararily small increments, to create the illusion of continuity. Due to motion pictures and animation, this may be an obvious and trivial idea, but it's fundamental enough that I will be coming back to it time and again.

A practical problem is determining the appropriate size of step. Something that is appropriate for modeling nuclear reactions is going to proceed far slower than the reactions themselves, and trying to model the development of the universe on this scale will take longer than the expected lifetime of the universe. On the other hand, if the time step is too long, so many changes take place within it that it will proceed in an extremely jerky fashion. The choice of an appropriate time scale has to be refined by experience.

A minimal C/C++ program is:

const int FIRST = 0; // Typically time begins at 0
const int LAST = ???;
const int TIMESTEPSIZE = 1;
bool the_end = FALSE;
int time = FIRST;

while (!theend)
{
[other stuff]

time += TIME_STEP_SIZE;
if (time >= LAST)
the_end = TRUE;
}

The "other stuff" may include processing of an event generated by a computer timer, or a user input, and it may include an output to indicate that indeed time is passing.
Variants on this include a timeless world (there needs to be some other way to set the_end true); an open-ended one (likewise, there needs to be some way to set the_end true, and the time variable may overflow); and one where time is reset (like the open-ended one).

Next up: Space

0 Comments:

Post a Comment

<< Home