Wednesday, July 31, 2013

"Hit enter to exist"

Typos in code are sometimes interesting and inspiring. Take my code for populating the stars in the galaxy. The application iterates through an infinite loop until it is unable to create more stars given the criteria. Stars can't be closer than X and the minimum distance between stars in certain areas cannot exceed N and the distance between stars in this other area cannot be less than A.

While the code runs it provides verbose output and accepts a number of commands during the operation to steer the direction of galaxy expansion. While the galaxy is technical a large square box, the star locations are completely random making the galaxy less of a box and more of a massive isotoxal  decagram. So using W-A-S-D controls it is possible to paint the 100k pixel grid.

The other interesting part is working with the random number generator which uses a series of weighting mechanisms. Intended for use in gameplay for randomizing events, this was a great test to see how well the random numbers were coming up. The game uses three different dice rolls, 1d20, 2d10 and 3d4. I guess the difference between real dice and this game is that I allow the random numbers to go out to 4 decimal places where the whole number is just as significant as the distance between it and the next.

It's important to give a brief explanation of the random events used, either in combat, crafting, mining or anything where a random number is needed. All actions in the game can be boiled down to scenes. So from the time combat is initiated to when combat is over is a scene. The scene will have many events, such as shooting a laser or attempting to run away. Events have sub-events, in the case of trying to run away, there are a number of systems that have to fire up properly in order to have a successful escape. Most of these sub-events are not initiated or monitored by the player. They are just part of the game's complexity to create a more realistic experience rather than saying that a 2d10 roll determines if the engines started. Instead each system used to initiated the starting of engines has 2d10 rolls applied and even if one sub-system fails, it does not mean the engine won't fire up, it just means that there are some things lingering in the background that could creep up later on in the flight and cause problems. Some events can be stored and extend beyond a scene, these are part of the story which is the entire gameplay experience.

So for example, two rolls that are somewhat close. 10.4218 and 10.0056. The distance away from 10 in the first roll may either eliminate positive special events or introduce other random negative events, like triggering a series of events that leads to a system failure. So the number 10 represents the roll, this is played against the other rolls taking place to determine the winner of the event. But the decimal places are collected and used over the duration of the scene. In some cases the outcome of the decimal place events can extend into the story. In this case the story then invokes a special scene to handle the triggered event. Some scenes will then eliminate the problem that found its way from a scene to story while others may expand the problem further. A simple example is you exit combat as the winner with a ship that has been beaten up badly. Engine systems are weakened, cooling systems for the weapons are barely operational and the life support systems are beginning to fail. The scene being invoked in the story now is one of survival. How quickly can you get help, get the ship to a safe place, abandon ship or as the manager of operations, dismiss the ship entirely from your command.

If you are ever in the position to write an application that requests user feedback, consider the wording carefully, your mistake could inspire others. Imagine if the instructions for signing up for Facebook told you to "click here to exist" instead of "submit".

No comments:

Post a Comment