It's been nearly a year since I worked on Martian Agora or updated this blog. I had a busy school year. I bet you thought I moved on from this project! Well I kind of did.
But I'm definitely back now, full swing, because I was accepted to speak at the International Mars Society Convention! It's in August 2015 in Washington DC. Speakers this year include: NASA directors, a former astronaut, authors, a Google VP, and me. I'm super flattered to be on the same speaking schedule as these people. Luckily the education software angle makes my topic really unique: "Inspiring Future Marsonauts with 3D Games Programming"
In my proposal, I think it helped lots when I said I'm a high school technology instructor. It shows I'm not a crazy person and that people trust me with kids. Something I'm usually hard pressed to prove ;)
I've had almost a year to reflect on Martian Agora and improve my skills. I also recently completed an online course about education games. So you can expect more Martian Agora updates this summer because I need to make this project the best that I can. I envision a major refactoring.
A special thanks to Robert Zubrin, the author of this Mars book. I judged it by its cover and bought it on a whim because it sounded neat, and it ended up channelling a lot of my creative energy.
Following my solo task of creating an early Mars colonization game. Discusses real Mars data, 3D models, programming, game mechanics, and science. Visit my website: www.stuartspence.ca
Monday, 8 June 2015
Wednesday, 20 August 2014
Book Review: The Martian
The Martian by Andy Weir is the fictional story of Mark Watney who is accidentally abandoned on Mars. Space exploration and engineering principles are used in clever ways to build a non-stop thrilling plot, but sadly character development was trivial. Overall a very enjoyable science fiction read. This review has no spoilers.
Anyone who enjoys tales about realistic space exploration with a focus on engineering. The science talk is sometimes detailed, but generally the language is easy and accessible.
The protagonist Mark Watney comes up with a lot of clever survival ideas and his inventive use of all his resources was really interesting. The language was playful, funny, and easy to read. Finally, the book does a good job switching between mission logs, personal logs, text chat, and traditional novel prose.
Unfortunately, there was little mention of the training and personal history of any characters. The motivations, fears, and personal desires of characters were also never explored or explained. And every single character essentially performed their roles ideally. Aside from internal NASA affairs, events on Earth were rarely described, and when they were it was extremely vague. This felt like a huge missed opportunity to me. To enjoy the book more, often I had to imagine by myself what NASA and Earth would be thinking as certain events in the book occur.
When a good book ends usually you are a little (or a lot) sad that the characters you've grown to love have ended with that last page of the book. Not so with "The Martian". I put down the book and thought "well that was neat".
Who should read this book?
Anyone who enjoys tales about realistic space exploration with a focus on engineering. The science talk is sometimes detailed, but generally the language is easy and accessible.
The Good
The equipment, catastrophes, plans, calculations, and flight trajectories all seemed to make sense scientifically. Given the ambitious content, this is actually a huge achievement for the author. So bravo!The protagonist Mark Watney comes up with a lot of clever survival ideas and his inventive use of all his resources was really interesting. The language was playful, funny, and easy to read. Finally, the book does a good job switching between mission logs, personal logs, text chat, and traditional novel prose.
The Bad
Oddly, Mark Watney would say things like "according to my boring math". I understand the author is trying to connect with a wider audience, but this was unbelievable to me. We have a world class astronaut and mechanical engineer saying math is boring. The head of public relations at NASA also showed disdain for the "nerds" and "geeks". Again, unbelievable. It felt like the dumb and stereotyped opinions of the masses were sneaking into the wrong characters.Unfortunately, there was little mention of the training and personal history of any characters. The motivations, fears, and personal desires of characters were also never explored or explained. And every single character essentially performed their roles ideally. Aside from internal NASA affairs, events on Earth were rarely described, and when they were it was extremely vague. This felt like a huge missed opportunity to me. To enjoy the book more, often I had to imagine by myself what NASA and Earth would be thinking as certain events in the book occur.
When a good book ends usually you are a little (or a lot) sad that the characters you've grown to love have ended with that last page of the book. Not so with "The Martian". I put down the book and thought "well that was neat".
Summary
This book is a great science adventure novel about exploring the frontier. Although there is little character development, the writing is witty as Mark Watney turns out to be quite the comedian. You won't walk away from the book feeling inspired, but it is a thrilling read.
Thursday, 7 August 2014
Book Review: On to Mars
On to Mars: Colonizing a New World compiled by Robert Zubrin and Frank Crossman had a huge variety of content that varied wildly in its quality. It is a collection of papers about many aspects of Mars exploration: engineering, business, law, finance, spirituality, public outreach, science, and ethics.
This section is about the first type. As a rule, any technical paper with actual calculations, charts, or graphics were worthwhile. The propulsion, power, and colony design articles were great.
"First on Mars Should Own It" by Ron Pisaturo was perhaps the only philosophy paper worth reading. It presents the notion that the first human to set foot on Mars for a year and return should own the planet. I recommend this article highly because at first the idea sounds absurd but Pisaturo effectively guides us through all the good that would happen as a result. Along the way he justifies the immense importance of private property. Unfortunately the paper concludes with a hamfisted capitalism masturbation, but overall it is very worthwhile.
"The Race to Settle Mars: Is the Public Ready?" is some great work done by Peter Perrine where he collected public opinions on Mars exploration. He interviewed people in laundromats, parents at swim lessons, swimming instructors, and senator's offices. The responses are all there, and well worth a read.
"Terraforming and Human Ecologies on Mars" by Robert Zubrin also had a ton of surprises. I now feel very well equipped to talk about biomatter exchange between Earth, Mars, and solar systems.
I was particularly surprised to see four articles written by reverends. From an atheist's perspective, it is delusional in the extreme to think that a blood soaked book from bronze age Palestine could give us any insight into the science and ethics of space exploration. Unsurprisingly, the theology papers were less about Mars and more about promoting spirituality and creationist theory, including the now thoroughly debunked "bacterial flagellum" as an example of irreducible complexity.
I see some utility in gathering support from religious communities for Mars exploration. But I think it's asking a lot for religious people to have faith in a scientific endeavor because a reverend says so.
Who should read this book?
If you are interested in Martian engineering, public outreach, space exploration business and law, or exobiology I recommend just reading those sections and skipping the rest.
The Good
There were generally two kinds of articles.- Interesting, informative, and well researched papers.
- Papers I could have written myself by just bullshitting how I felt Mars exploration relates to philosophy, spirituality, or general technology.
This section is about the first type. As a rule, any technical paper with actual calculations, charts, or graphics were worthwhile. The propulsion, power, and colony design articles were great.
"First on Mars Should Own It" by Ron Pisaturo was perhaps the only philosophy paper worth reading. It presents the notion that the first human to set foot on Mars for a year and return should own the planet. I recommend this article highly because at first the idea sounds absurd but Pisaturo effectively guides us through all the good that would happen as a result. Along the way he justifies the immense importance of private property. Unfortunately the paper concludes with a hamfisted capitalism masturbation, but overall it is very worthwhile.
"The Race to Settle Mars: Is the Public Ready?" is some great work done by Peter Perrine where he collected public opinions on Mars exploration. He interviewed people in laundromats, parents at swim lessons, swimming instructors, and senator's offices. The responses are all there, and well worth a read.
"Terraforming and Human Ecologies on Mars" by Robert Zubrin also had a ton of surprises. I now feel very well equipped to talk about biomatter exchange between Earth, Mars, and solar systems.
The Bad
Perhaps half the papers are not worth reading under any circumstance. The articles on the human hand, Mars IT, theology, and distant future legal frameworks for Mars were particularly worthless. Most finance papers also seemed worthless, though I'm not knowledgeable enough to say for sure.I was particularly surprised to see four articles written by reverends. From an atheist's perspective, it is delusional in the extreme to think that a blood soaked book from bronze age Palestine could give us any insight into the science and ethics of space exploration. Unsurprisingly, the theology papers were less about Mars and more about promoting spirituality and creationist theory, including the now thoroughly debunked "bacterial flagellum" as an example of irreducible complexity.
I see some utility in gathering support from religious communities for Mars exploration. But I think it's asking a lot for religious people to have faith in a scientific endeavor because a reverend says so.
Summary
This is a generally good collection of articles that I learned a lot from. Even though the standards of the editors may have been too low, it is clear that every author cared about Mars exploration and wanted to contribute what they could. Even the articles whose content I do not recommend were well written. A reader will have a good experience by picking and choosing which topics interest them most.
Wednesday, 6 August 2014
The Ride of the Rover
I'm at my third iteration for the colony design system and I'm still not happy with it! I was getting sad so I decided to try something completely new and fun. Introducing, the Mars rover! I am shocked how well this turned out. It only took me five hours or so, and hardly any planning. The 3D model is temporary and thus hideous. Here it is!
Like always, I've made the code flexible so it should work with vehicles that have any number of wheels. And now that I think of it, in any configuration too... Hmmmm!
Linear algebra is not just for school
I had to whip out my knowledge of linear algebra, friction, dampening coefficients, torque, and kinematics. As always Unity3D was a great help. For example: I didn't have to code my own 3D vector projection function: it already existed. Always ask yourself whether you are writing code that already exists. Re-using code is faster for you, clearer for other programmers who read your code, probably faster for the computer, and far less likely to have errors and bad fringe cases.
Each wheel applies an upwards force to the rover, parallel to "up" on the rover, linearly proportional to how compressed the suspension is for that wheel. If it is fully compressed, it applies 100% of its force.
Each wheel applies an extra friction force proportional to how much the vehicle movement is sideways - but only if that wheel is touching the floor. That force can potentially make the vehicle roll over. Rollovers are critical to gameplay because they are a very real and serious concern. I needed a rover that will flip if you're reckless. It opens up all kinds of fun things like damage to the rover, and getting a jack to flip it back.
Gizmos
You may notice a green or red glow inside the tires. Those are Unity "Gizmos". They are helpful things that appear in the 3D world, but not in the final game.
void OnDrawGizmos()
{
if (wheels == null)
return;
foreach (Wheel wheel in wheels)
{
if (wheel.IsTouchingSomething())
Gizmos.color = Color.green;
else
Gizmos.color = Color.red;
Gizmos.DrawSphere(wheel.transform.position, 0.2f);
}
}
Test scene
The first scene in the video helped me debug. I just had to press play to see four cases on the same slope:
I strongly suggest setting up a "test scene" for cases like this. It consumes far too much time manually driving around to find issues - and it's impossible to reproduce exactly the same event.
Ugly rover?
So how about that ugly rover? That model (made in 5 minutes) is temporary because it's possible I will be getting help! Oscar Mathews who is a "nuclear engineer at Norfolk Naval Shipyard and a LCDR select flight test engineer and Mission Commander for the Navy Reserve as an officer" has offered to help. He is learning blender and produced these drawings for us to collaborate:
They also serve as good evidence that he has technical and artistic skill. So I eagerly await attaching my rover scripts to his beautiful rover!
Mars Colony Challenger
In my quest to learn all things Mars, I've found a Mars colonization game called Mars Colony Challenger. While I sympathize with how much work must have gone into it, it didn't rate very well and there are clearly some major gameplay issues. Still, I watched a couple hours of gameplay videos with commentary and learned a ton about how people experienced the game. I have a very good idea of what that game is missing and I intend to move Martian Agora in that direction.
Like always, I've made the code flexible so it should work with vehicles that have any number of wheels. And now that I think of it, in any configuration too... Hmmmm!
Linear algebra is not just for school
I had to whip out my knowledge of linear algebra, friction, dampening coefficients, torque, and kinematics. As always Unity3D was a great help. For example: I didn't have to code my own 3D vector projection function: it already existed. Always ask yourself whether you are writing code that already exists. Re-using code is faster for you, clearer for other programmers who read your code, probably faster for the computer, and far less likely to have errors and bad fringe cases.
Each wheel applies an upwards force to the rover, parallel to "up" on the rover, linearly proportional to how compressed the suspension is for that wheel. If it is fully compressed, it applies 100% of its force.
Each wheel applies an extra friction force proportional to how much the vehicle movement is sideways - but only if that wheel is touching the floor. That force can potentially make the vehicle roll over. Rollovers are critical to gameplay because they are a very real and serious concern. I needed a rover that will flip if you're reckless. It opens up all kinds of fun things like damage to the rover, and getting a jack to flip it back.
Gizmos
You may notice a green or red glow inside the tires. Those are Unity "Gizmos". They are helpful things that appear in the 3D world, but not in the final game.
void OnDrawGizmos()
{
if (wheels == null)
return;
foreach (Wheel wheel in wheels)
{
if (wheel.IsTouchingSomething())
Gizmos.color = Color.green;
else
Gizmos.color = Color.red;
Gizmos.DrawSphere(wheel.transform.position, 0.2f);
}
}
Test scene
The first scene in the video helped me debug. I just had to press play to see four cases on the same slope:
- Rover upright.
- Rover aligned to slope.
- Sideways rover upright.
- Sideways rover aligned to slope.
I strongly suggest setting up a "test scene" for cases like this. It consumes far too much time manually driving around to find issues - and it's impossible to reproduce exactly the same event.
Ugly rover?
So how about that ugly rover? That model (made in 5 minutes) is temporary because it's possible I will be getting help! Oscar Mathews who is a "nuclear engineer at Norfolk Naval Shipyard and a LCDR select flight test engineer and Mission Commander for the Navy Reserve as an officer" has offered to help. He is learning blender and produced these drawings for us to collaborate:
They also serve as good evidence that he has technical and artistic skill. So I eagerly await attaching my rover scripts to his beautiful rover!
Mars Colony Challenger
In my quest to learn all things Mars, I've found a Mars colonization game called Mars Colony Challenger. While I sympathize with how much work must have gone into it, it didn't rate very well and there are clearly some major gameplay issues. Still, I watched a couple hours of gameplay videos with commentary and learned a ton about how people experienced the game. I have a very good idea of what that game is missing and I intend to move Martian Agora in that direction.
Friday, 1 August 2014
Airlocks and a Modular Base
I faced a couple design challenges and it took some trial and error getting things right (or rather, acceptable). My first iteration of the base was butt ugly. The "Martian cement" on the outside of the base that protects from radiation was nearly the same shade as the terrain and it just looked like shit, literally. Now it's painted white!
I probably won't be able to keep up the quality I've enjoyed so far with my 3D modelling. There is so much to do and I am no artist. Maybe sometime in the future I can team up with a competent artist. My colony is boxy - but I'm more interested in making it do things than making it look nicer.
The colony is generated procedurally. Consider that the game was an empty field before I started. The code to create that base is something like this:
Create hallway at 0,0
Create room at -1,1
Create airlock at 1,3
Furthermore, the pieces you see at the end of the video should be a nice way to show a gradual construction process during gameplay. And the sections of room that are like slices of pie will allow me to re-use room designs. And since the "outside" is a separate model from the "inside", different insulation is a possibility.
Airlock
As usual I didn't program just an airlock. I kept the door, doorknob, and mouse-hover-highlight code as re-usable as possible. Like the colony, the first airlock was ugly as hell so I remodelled it.
Sound
The sounds are free so long as I give credit. I am sort of keeping track of that.As for music, I am considering the original Starcraft soundtrack! But that's only an option if I never make a penny on this game. That's a possibility.
My friend Alex also knows a band that have already made a lot of music that really suits my game.
NASA
Here's some exciting news in space propulsion research.
Monday, 21 July 2014
Structure statuses. Distributed resource consumption and production.
It's that time again to celebrate progress. Here's a nice video so you know what I'm talking about:
Game immersion..? You know that feeling when your mind dives into a game, movie, or book so much that the real world goes away? That is full immersion. It can be disrupted many ways: a real life phone call, cat, awkward writing, or bad game design.
Those blue transparent "blueprints" don't exist in the game world. That ruins immersion because it makes no sense for us to see them. I needed an excuse to show them to the player. So now you must be wearing the visor to see the structures you have planned. This way it still feels like you're only seeing what your Martian is really seeing. I thought this was a great solution because "virtual reality" is a real technology that we have today. It also got me started on my first of many "visor" items.
Finally I fixed a bunch of bugs.
Onward!
The Details
Introducing: the virtual reality visor! This overcomes a game immersion issue I had.
Game immersion..? You know that feeling when your mind dives into a game, movie, or book so much that the real world goes away? That is full immersion. It can be disrupted many ways: a real life phone call, cat, awkward writing, or bad game design.
Those blue transparent "blueprints" don't exist in the game world. That ruins immersion because it makes no sense for us to see them. I needed an excuse to show them to the player. So now you must be wearing the visor to see the structures you have planned. This way it still feels like you're only seeing what your Martian is really seeing. I thought this was a great solution because "virtual reality" is a real technology that we have today. It also got me started on my first of many "visor" items.
Structure list
Resources can be produced, consumed, or stored. A resource with a green circle means that structure produces that resource, a red bar means it consumes it, and a white square means it can store it. Not super beautiful but it works great. Note that the number of icons is an approximation of the rate/capacity. The game uses real units internally like kwh, kg, etc.
Structure blueprints
The new blueprint window! It's getting easier and easier making new windows like this because I can re-use code. Resources are displayed here just like how they're displayed in the structure list. That is my ResourceReusable class, just one of many "reusable" classes for GUI stuff. This is one of the advantages to planning out my GUI system. I know in advance which visuals I am going to re-use.
Coroutines
Coroutines? If you're not a programmer, maybe skip this paragraph.
I started using coroutines. This way, every single building isn't calculating what it's doing every single frame (which can be up to 60 times a second). Each structure does its thing every second and generally on a different frame because the coroutine is started whenever you start the building. I am aware there are cleverer uses of coroutines, as I've read about them and even went to a talk from a Unity3D software engineer about them! But this is actually my first time using them in any language so it's great to start simple. They're performing great.
Comments
I wrote a ton of comments in my code.
Comments? Commenting is this thing that programmers always say is great to do, but then never do it. As you can see from the picture below, code is weirdly halfway between human-readable and computer-readable. Humans can "read" computer code like this, but it's more work than reading English comments.
Well this is now my second biggest Unity3D project (4942 lines of code). Even though my pseudo-professional design patterns and coding architecture choices are all in my head now, they won't be forever. Sometime, future Stuart is going to wonder what the hell past Stuart was doing with his bizarro code. When that happens, it is much nicer reading a paragraph in English than trying to make sense of hundreds of lines of magic code.
I've never felt the need to comment my code this thoroughly for any project. But I intend for it to get a lot bigger. And that's not going to be possible if it's too hard to remind myself how the pieces are put together.
Milestones
I keep a spreadsheet listing all game ideas I've ever thought of, sorted by priority (around 100 ideas now). Well I invented a "milestone" system which allowed me to go through them all and re-prioritize. My first milestone is "plausible survival and death". Everything I do will be focused on that until I feel I've achieved it. I was surprised how some tasks ended up being much higher priority or lower priority than I thought when put into context.
Distributed resource consumption and production
This also used coroutines. Whenever a structure tries to consume or produce electricity, water, oxygen, or whatever, it makes a request to nearby structures. A producer must check nearby storage if there is space. A consumer must check nearby storage if there is enough to operate. For now, all structures are magically connected to all storage.
Flywheels are like batteries.
They store energy by spinning a heavy internal disc. Thanks for the idea, Karl.
A crate filled with lithium batteries.
A crate filled with oxygen tanks.
A small water tank.
A big water tank.
Plastic sheet.
Blender is fantastic! I put together this render in no time at all. Like, ten minutes.
Finally I fixed a bunch of bugs.
Onward!
Sunday, 13 July 2014
Generation of water and electricity. And a toolbar!
The colony generates water and electricity! Plus I added windows, tooltips, and a toolbar.
GUI..? GUI stands for graphic user interface. This just means all the buttons, menus, labels, and pictures that help the player play the game and get information about the game.
It's been over a week since any major progress because I've been intimidated by all the options that I faced. Designing how information is displayed requires knowing a lot about the future of your game. In the end I actually needed to write out my interface requirements in a document:
This took several hours and it was an extremely good idea. While reading and writing my interface requirements, I was able to clearly imagine the appearance of all the controls and game information. I vividly imagined what it would be like to want information and use my menu to find it. I imagined the exact graphical layout of each window. And because it was written in English and not code, it was easy and painless to revise or completely rewrite.
I highly recommend this process to anyone starting a big GUI system before writing any code. Had I not done this I would have burned a lot of time writing dead-end code, frustrating myself profoundly. That sort of motivation-trap puts the whole project at risk.
At the bottom of the screen is the overview toolbar which turns on and off by pressing "O".
For now I've coded the colony resources window (first button) and colony structures window (fifth button). I have planned the others in my document but will code them only when it adds something meaningful to the gameplay. I don't want to work on something unless it adds something interesting now. Otherwise I would be squandering my motivation.
Thanks to Unity's GUI.Window you can reposition the windows. I also made a tooltip system. My system works great with Unity's OnGUI calls. Just place a single TooltipManager function call in OnGUI for each tooltip and it does the rest. Tooltips follow the mouse smoothly. Tooltips everywhere! Here's a tooltip for the electricity resource (you can't see the mouse in the screenshot):
In other news, I fixed the weather balloon animation, and made a plastic dome for the AWG. I also mass produced a ton of icons. Here are some:
The art is far from perfect. And some of you may be thinking: "surely you could have found some of that art online, for free". Why yes, there are indeed some great free video game icon packs out there. But I think consistent mediocre art looks better than non-matching fabulous art. And since I'm the only artist, all my art has the same mediocre style. That style being the only style I can probably do!
I wrote a python script to count how many lines of C# code is in my project. So far we're at 3706. Gee, C# sure is verbose.
I wrote a python script to count how many lines of C# code is in my project. So far we're at 3706. Gee, C# sure is verbose.
For research I started reading A Traveler's Guide to Mars but found it a little slow so I just switched to On to Mars. It came with a CD with 60 pdfs on Mars colony science but of course the mailman decided to smash it to pieces when he jammed it into my mailbox...
Thanks Canada Post!
Oh well. Onward!
Subscribe to:
Posts (Atom)


















