New Coding Paradigms

So I’ve recently been thinking that the whole idea of editing text files filled with code is outmoded. When I’m thinking about code, I certainly don’t think of it as a set of classes and functions laid out in a particular order. I think of it as a cloud of entities with properties and interactions flowing between them. Shouldn’t our experience of writing code reflect this?

We need to start rethinking our code-editing tools. A lot. Here is a simple example:
XML heatmaps

What else could we do? How about the ability to arbitrarily break off chunks of code and view them in parallel, even nesting this behavior to break long blocks of code into a string of chunks:
Nesting chunks

What if we let the flow of the documentation decide how a reader is introduced to the code base, instead of letting the flow of compiler-friendly source files decide it? Chunks of code are embedded within wiki-style documentation, and while you can follow the code back to its source, reading the documentation will eventually introduce you to the whole codebase in a human-friendly fashion.

The same code could even appear in multiple places (obviously updated when the source changes), and you could see all the places in the documentation where a particular chunk of code appears. This could bridge the gap between documentation and code; documentation will never grow stale, as updating code necessitates interaction with it. Similarly, updating documentation is the same process as writing code. When a standard changes or an SLA (service level agreement) is modified, the code changes too.

But why restrict ourselves to semi-linear, text-based documentation a la wikis? We tend to find UML diagrams extremely helpful for visualizing complex systems in code. What if we could build powerful, adaptable tools to translate between raw code, text-based documentation, and visual diagrams? Strictly binding them together might restrict you in the lowest levels of coding (much like, for example, using a high-level language restricts your ability to control memory allocation), but it opens up the new ability to make changes to a diagram and have most of the code rearrange and resolve itself before you. Then you step in to give a guiding hand, and adjust the text documentation, and voila! Best of all, this is more than a diagram-to-code tool; the diagram is a living thing. In fact, the diagrams, the documentation, and the codebase are synonymous. A change in one is a change in the others.

We’re getting to the point where it is much more useful to be able to dance across a codebase quickly than to be able to tweak and tune the minutiae of your code. Some allowances must be made for processing-intensive applications. Perhaps this system wouldn’t even be useful in those cases. But when you find yourself favoring adaptability and iteration speed over efficiency during development, and when you find yourself being hampered by the need to go between files, scroll through large swathes of code, or referring back and forth between code and documentation, maybe it’s time to rethink your coding paradigms.

Mass Paradigm

One of the most interesting things to think about with respect to the near-future of space travel is the removal of limited mass as a paradigm. That is to say, right now the predominate design constraint for spacecraft is mass, because rockets are very expensive, so each kilogram of payload must be put to best use. Unfortunately, this means that the design and construction costs for spacecraft are very high, as much effort is put towards shaving off grams by using exotic materials and efficient designs.

But soon the current launch vehicle renaissance will result in launch costs low enough to demolish the limited-mass paradigm. There is a tipping point where it is economical to cut design costs and take the hit on launch costs. There will also see a growing emphasis on tough and reliable systems that last a long time, rather than fragile, light, efficient systems. Combined with lower fuel costs from asteroid mining and improved refueling technologies, the predominant modus operandi will be repairing spacecraft rather than replacing spacecraft. Designing for reusability and, more importantly, refurbishment will be critical.

We’re already seeing a shift towards this paradigm with SpaceX. Their launch vehicles use redundant systems to make up for their cheaper designs — their avionics electronics, for example, are not rad-hardened but instead redundant in triplicate. The mass penalty is minimal, however they also make up for it by using modern electronics concepts. For instance, instead of running numerous copper wires up and down the length of their rockets, they run a single ethernet cable and use a lot of multiplexing.

This kind of change is just the beginning, however. There will be a time when it makes sense to loft a big bundle of steel rods into orbit and have workers weld them into a frame for a spaceship. This has a number of benefits: the frame doesn’t have to be fit into a fairing, it can be reconfigured on the fly, and it doesn’t have to endure the acceleration and acoustic stresses of launch. Additionally, lifting big bundles of steel makes best use of the volume in a launch vehicle fairing.

I think the only two questions about the future of space travel are: How much will it be dominated by robots? and Where will the money come from? But those are questions for another time.

Burn

I’ve been aiming to make a post about this for a while. Here is one preliminary design document I made a while ago. It calls for something similar to the situation described in A Deepness in the Sky.

Game Beginning

You start out as a young man, fleeing a vicious civilization collapse. As the member of a wealthy Qeng Ho family and son of a fleet leader, you are in charge of the only ship that escaped. You are powered down in orbit of a gas giant, watching the aftermath of the Fall. A lot of your archives have been corrupted, so you need to find some other traders or find a world to raise up.

The very first thing you do is name your family branch. Then you figure out how to take inventory of your ship systems, and how to scan surrounding space. You learn about light-lag. You have just enough fuel to get up to operating velocity. You can choose a target system.

Your aim is to become the leader of the Qeng Ho. This is not an easy feat; the Qeng Ho is a diffuse trading race, with no clear organizational hierarchy. There are several trading “families”, each with large offshoot branches (e.g. Vinh 2.0.3). The objective is to gain enough influence, and then call a meeting of the Qeng Ho. At this meeting you either convince all the families to follow you, or perform a hostile takeover.

You have as many years as are in your life to do this. Note that if you meet a civilization with hyper-advanced medical technology, this means a time bonus. You do have cryo-freeze for the time in transit between stars.

Personal Mechanics

Throughout the game there are personalities on your ship and on other ships that you can talk with. What you say affects what they think of you. If they hear bad things about you from others, they will enter into relations with poor expectations. Reputation influences the trades you can get, as well as favors you can ask.

If you gain a high enough reputation and interact enough with a person, you may become friends. You are not notified whether or not they consider you a friend until you bring it up. Friends will vouch for you or join in on a plan. Friends are much more likely to answer a distress signal you put out.

Traders that are well known often have available profiles. When you trade for someone’s profile, you can see their reputation with others, their personality, and most of their history. By gaining enough reputation with a person, you can find out what they think of other people.

Interstellar Travel Mechanics

A Bussard ramjet is used to travel quickly between star systems. A ramjet can only go so far before the mechanism breaks down. A ramjet needs to move at a certain fraction of the speed of light in order to scoop up enough fuel to continue operating. While flying above that threshold, your fuel tanks fill up. When decelerating, accelerating, or maneuvering, you burn fuel without regaining any. It is only possible to accelerate up to 30% the speed of light; a lot of energy is spent accelerating floating interstellar hydrogen up to your speed.

Ramjet engines can not be repaired on the fly. In order to fully repair an engine, you need to trade with a civilization that has the requisite technological level. This means that you may have to raise a civilization to high-tech in order to continue flying.

If your engine breaks down mid-flight, you will very slowly lose speed (from colliding with interstellar particles), and continue to drift until you either exit the galaxy, crash into a star, or are picked up.

Note that different regions of space have different interstellar medium densities. For instance, our local cluster lies inside a relatively sparse region, making ramjets less feasible. One aspect of choosing a destination in the game is navigating around low-density “bubbles”.

Choosing your target is important. Since you can only hear transmissions from the past, you have to judge whether or not a civilization will be as advanced as you want it to be when you arrive. Flying to a system that is at a peak level of technological advancement will probably have collapsed by the time your fleet arrives. This just means you have to spend time (although you have cryogenics, you still usually come out of it every so many months to make sure the fleet is still on track) helping them get back up to a sufficient level to repair your fleet.

Trading Mechanics

Planetary civilizations rarely want materials. They can mine almost everything they need from their system, and the price of lugging raw materials across interstellar space is too high for you. The exception is high-tech equipment. Civilizations will pay dearly for technology that they either cannot physically manufacture (as with Beyond relics) or are nowhere near the technological sophistication needed to synthesize the tech.

Civilizations value information more than anything. A faction will pay a grand sum for anything that will let them dominate their opponents. Advanced secrets help advanced civilizations keep their expanding infrastructure under control. Usually you can broadcast such information ahead of you, as long as its encrypted. This gives the civilization warning that you are coming, and when you get there you can trade away the keys needed to decrypt the information (on this note, the Qeng Ho constantly broadcast a certain amount of information for free to make sure that civilizations they meet have similar measurement standards, language, etc.).

Conversely, traders have a huge store of knowledge, but lack the infrastructure or resources to maintain themselves. Spacefleets will often bargain limited pieces of technology in order to buy volatiles, fuel, and new equipment. Sometimes civilizations will provide these for free to weasel better deals from you.

Occasionally a civilization will become exceedingly advanced in one area of technology. They will invent something truly revolutionary. If you get your hands on one of these pieces of technology, you will have leverage over all other Traders. You may have to bargain hard to wrest the technology from the civilization at hand.

Combat Mechanics

Be warned. Consistent use of weapons will cause other traders to shun you and make civilizations bar you from their systems. Someone might even try to hunt you down if you destroy their civilization but leave even part of a defense fleet.

Space combat is a fickle subject to approach. It is best summed up by these two pages on Atomic Rockets, although every page there provides good insight.

Interplanetary Flight

This will probably be some sort of simplified KSP-like interface. That is, you initiate maneuvers to change orbit. The problem here is balancing technical details against flexibility and realism. Optimally, players should be able to identify their desire to conserve fuel against time constraints, and let the computer select the best orbital maneuvers to transfer between planets, space stations, Lagrange point colonies, etc. However, because players may want to do wonky things in orbit during a battle sequence (establish oblique orbits, do hard burns, etc.)

I guess you could distinguish between normal navigation and battles. Battles would probably happen around one central body, unless there was a moon involved. However, battles would probably happen really fast (over in minutes) or really slow (taking months).


And that’s as far as I got in describing it.

Programming a 40K Simulator

(further reading)

This has been a pet project of mine for a long time. I’ve taken a couple cracks at making one, but have failed miserably each time. My objective is to create a simulator that allows players to play battles with various armies, allowing them to refine their strategies before actually buying the models. However, I want a fairly flexible and modular rule system that enables alternate rulesets to be introduced (not only other official rule editions, but custom gametypes like racing) and of course custom armies. There are two inherent problems with creating a realistic simulator:

  1. The number of exceptions to the rules is about as large as the number of rules. Many exceptions rely on human understanding of the rules, and get resolved intuitively. This is problematic when going for a procedural approach
  2. The rules change. I started playing with 4th edition rules. My first attempt was during that phase. When I made my second attempt, the rules had moved onto 5th edition. Now they are in 6th edition. It’s a pain in my ass.

The two previous times I attempted to make a simulator, I programmed from the ground up. This time I’m thinking about using Unity3D. This makes sense in at least one regard: Line of Sight is contingent on precise model and terrain geometries. If I want the project to match my objectives, I need some sort of 3D system behind it.

I see a pretty clear path for development. The first step is to breakdown the rules into a clear procedural system. After I can see the possibilities that need to be encountered, I can figure out how to generalize that into as simple an architecture as possible. Then I can figure out how to implement that in Unity3D.

Unfortunately, every step of that is hard. I’m still stuck on that first step. First, I’m unaccustomed to the 6th edition ruleset. Second, the rulebook isn’t laid out optimally for my purposes. It works well for a beginner building up their understanding. The basics of each step is introduced, and then later modified with exceptions and special cases. I need an organizational somewhere between a flowchart and an outline.

So I have two things I need to do: map the rules, and learn C# for later use in Unity3D.

Sim State

I’ve been meaning to write this post for a while. This idea really started when I watched Day[9] play the new Sim City, and then picked up Sim City 4 again. I wanted to create a game which brought the ideas of micromanaging infrastructure and government into a larger scale. The player would be able to control education, government type, military, trade, etc. Eventually it grew into a sort of “third-world country simulator”, since that seemed like the most interesting route to people I pitched the general concept to.

The basic premise is that you are the leader of a small country, recently put in power by a violent revolution. This country is located in a faux South or Central America, but there is also the possibility for having multiple templates: African, Southeast Asian, etc. The player can only really see the small land area he controls, plus some of the bordering sovereignties. There is no global map (and this isn’t a game about conquest), but there are references to current global institutions (or fictitious characterizations thereof) like the UN and US, or WHO, etc.

Winning the game means pulling your country out of poverty and onto the world stage. This requires many parts, including building infrastructure, establishing governmental rule, and appeasing the international community. However, the win condition is gaining control over every province in your nation. Control just means being the dominant power faction. Routes to control include stamping out resistance (militarily) and appeasing interest groups. Thus a large part of the game is balancing political control; keep the military leaders on your side, stop workers from striking, and stay elected. The last one may mean establishing a dictatorship, rigging elections, or spending a lot of resources maintaining public image.

At the start of the game, your country is poor and unequipped. There are two forms of currency: money, and international repute. International repute can be spent on relief or treaties; perhaps getting a foreign oil company to leave your country. On the other hand, if you drive out the oil company by force, some factions in your own country may approve, while the international community may impose sanctions. Similarly, if their are pirate along the coast, you could demand tribute or try to exterminate them at a potentially great cost. If the world catches wind that you are allowing pirates to operate, however, you will lose repute.

The other form of currency is money. A little macro-economics comes into play here, since you have to manage your currency (printing money), and real “world dollars”. Rapid inflation can be bad for your industries, but it attracts tourists (but only to good parts – nobody is going to visit the region controlled by drug cartels). Real dollars come from exports, mainly. One way to get a boost in the beginning of the game is to exploit your natural resources: cut down rain forests, strip mine mountains, etc. However, you have to establish a more mature manufacturing industry at some point, otherwise you will exhaust your resources and fall back down into poverty.

In terms of infrastructure the player has to build, the main forms are education and industry. Industry includes transportation networks and resource collection, as well as processing. Industry also means municipal improvements, since nice cities attract high-tech corporations and commercial companies. Another route to improving the quality of your workforce, reducing crime, and eliminating overpopulation is education. Building schools takes a lot of resources for little immediate payoff, but it will start to improve your country greatly. It is also a great way for dictators to indoctrinate the population.

Late-game opportunities may include hosting Olympic Games or researching nuclear technology.

As you can see, there is a lot of room for expansions; this is more of a framework for a game, rather than a fleshed out game idea. I know there are games like this, such as Tropico. I think this would be more political and deep than Tropico, but obviously I would aim to offer a different experience overall were I to build this.

Using Games to Educate

In the last few years we’ve seen the Internet playing a larger and larger role in education. Everyone seems to expect a revolution in education within 20 years. It’s possible, although I don’t think it will come from the direction that everyone thinks it will (see my post on online education). I want to give my two cents about an ancillary approach: videogames. Games don’t have to teach the students anything. In fact, I think they are much more useful as vehicles for the education. Games provide a background, a context, for new knowledge. For example, playing Deus Ex: Human Revolution (play chapters of a game as homework instead of reading chapters of a book?) could help spark discussion about the current situation of computers, implants, artificial intelligence, politics, etc. The experiences within the game outside of the lesson help students stay interested and apply the knowledge, even if subconsciously, beyond the classroom.

I’m going to focus on two games: Kerbal Space Program and Minecraft. Prmrytchr has a whole blog on using Minecraft (as well as other games) in the classroom, so I’m going to focus on the technical aspects.

the KSP splash

Kerbal Space Program (KSP) is an indie game currently under development with an open alpha available for purchase. In the game, you run the space agency of a particularly derpy alien race in their Sol-like system. In sandbox mode, you can throw together rockets, probes, rovers, space stations, planes, and planetary bases from a wide assortment of parts. Then you launch your constructions and control them to the best of your abilities.

KSP Screenshot KSP Screenshot 2

While hard to grasp at first, the game is incredibly fun. You do need a rudimentary understanding of kinematics to play well. This is the first step in its ability to act as an educational tool. While you can strap an engine onto a fuel tank and try to fly it, you quickly realize that doing anything impressive — such as putting an object in orbit — requires a bit of education. While you could watch tutorials, you could also get a lesson about basic kinematics and orbital mechanics from a present teacher. There’s an opportunity for lessons on engineering, as well.

As students become more proficient, more complex opportunities open up to them. Orbital rendezvous and gravitational slingshots get more involved physically. Spacecraft design, between mass conservation, fuel-mass ratio, reaction thruster placement, and properties of engines, is a great opportunity for springboarding into other physics. Other elements of spacecraft design that aren’t simulated in KSP, such as heat management, enter the realm of thermodynamics. Ancillary topics that arise when discussing space exploration can involve relativity and electromagnetic waves.

minecraft splashMinecraft, on the other hand, is about as physically unrealistic as you can get. However, it provides an awesome way to teach logic and economics. Even vanilla Minecraft has a growing arsenal of parts which allow rudimentary (or not so rudimentary) automation. Redstone is a powerful tool for doing any sort of logical manipulation — or teaching it. Watching your toolbox of gates and mechanisms grow out of a few basic ground rules is amazing. Creative minds are pushed to imagining new ways of using redstone, pistons, minecarts, and all the other machines being added in. While I’m not a fan, mods like Technic or Tekkit expand the array of basic parts at your disposal.

Multiplayer in Minecraft is an interesting case study of economic theory. Because the system varies so much from the real world, it provides an outside perspective on traditional economic theory. As you teach the basics of microeconomics, you can analyze why Minecraft’s multiplayer economy and identify how to restrict it. The ultimate goal of the class could be to establish a working economic system on a Minecraft server (perhaps through plugins/mods?).

Redstone Schematic Redstone Screenshot

Whether or not any of these are good ideas, it illuminates how games don’t have to be the primary vehicle of learning to be a useful educational tool. Games can merely be a springboard, a point of reference from which lessons emerge. The game keeps the students interested and grounded in the topic, while providing a useful outlet and vector of fortification for the knowledge they are getting in class.

Into the Unknown: UDK Part 1

I tried this before, but ended up quitting. I believe now that my exit was premature. I refer of course to my adventure into the Unreal Development Kit, a free version of the Unreal Engine that allows developers to create their own games in the Unreal Engine.

My reason for embarking on the adventure was to recreate the gameplay from Halo: Combat Evolved on an updated platform. The bonus is two-fold. For the longest time, I have had a Halo custom campaign in the works, but have never really gotten the Halo Editing Kit tools to work for me. Secondly, I have always felt the need to learn how to use a 3D game development tool. After exploring Unity slightly and having dabbled in CryEngine 2 (and somewhat 3), I decided it would be good to experience the Unreal Engine.

Posting updates on this blog serves two purposes: One, it keeps me from giving up again. Second, it helps me quantify my successes and organize my thoughts. Hopefully I can post an update on this project every two or three weeks, with either video or pictures to show off new milestones.

Without further ado, I want to outline some of my goals for the upcoming project:

  1. Learn how to create:
    • particle effects
    • weapons
    • vehicles
    • characters
    • AI behavior
    • scenery
    • level geometry
  2. Learn what else I need to learn
%d bloggers like this: