2010-05-18

Greater than One?



Nothing increases my faith in science like seeing a highly cited article that experimentally measures a probability larger than one. Hmmmmmmmmm.

2010-05-14

Game Review: Dwarf Fortress

I've been pretty hosed at work lately, so I apologize for the lack of recent posts. It is hard to write a blog when you've spent the past few weeks writing a paper (or three) at work. However, I just wanted to practice my non-technical writing and talk a bit about a Dwarf Fortress, a game that I thought I'd review.

The game has three modes: fortress, adventure and legend. All three modes center on different aspects of a single world - for the sake of brevity I'll be focusing solely on fortress mode, which is a mode similar to Sim City but with a fortress instead of a city. Adventure is a hack-and-slash mode similar to NetHack, and legend is an encyclopedic mode that is still in the works.


Two shots from legends mode show information a dragon that was slew in the year 118. If you like reading encyclopedias, you'll love legends mode!


The basic premise behind the game is all there in the title. You have dwarves, and you want to build a fortress in the side of a mountain (mountain optional). If you enjoyed playing Sim City, you'll probably enjoy Dwarf Fortress, though it has a *much* steeper learning curve. There isn't an end goal to the game, though as your fortress gains wealth and population your fortress will receive noble dwarves, such as a baron(ess) or a count(ess). The easiest way to create wealth is through workshops, though other resource-gathering is available. The population either grows from natural procreation or immigration.

The entrance to a fortress is shown at the left-hand side. There are two ballistas in the center-left defending the fortress entrance, along with two rooms straddling the entrance to allow cross-bow wielding dwarves to defend the entrance. On the right hand side of the screen is a bridge (red double-tildes with outline) crossing a brook (blue tildes). A dwarf is chilling on the bridge. The middle portion of the screen contains three catapults with ammo stock-piles to the left of them.


The first thing you'll probably notice is that the game has an ASCII tile-set. If you're not used to ASCII games like NetHack, you might have a very hard time adapting. There are other tile-sets that are a little easier on the eyes. I personally don't mind the graphics so much as the limited view of the world. Many modern games use zoom mechanics to deal with complexity, but it isn't possible with Dwarf Fortress.

The game can be split into roughly three categories: building/mining/economy, combat, and history. I'll tackle the subjects one at a time to review the game

History


Dwarf Fortress keeps track of almost everything. The legends screens above about the dragon? One of those is created for each one of your dwarves, tracking the life events of the dwarf. Every sentient or large creature that your dwarf kills is tracked. Your dwarves can be happy, sad, or go crazy if their spouse dies. Baby dwarves can go insane if their parent dies. This, too, will be recorded.

The history system can be a bit overwhelming at times, but at the same time it feels as though the game you're playing has an epic quality to it. You're never forced to look at the history system, which I think is a big plus. Did a dragon just arrive at your fortress and take out half your population before one of your champions brought it down? You won't feel so bad after you look at the legend screen and find out that once upon a time that dragon killed the elven king.

However, if that dragon takes out your fortress, it is gone. Dwarf fortress is a one-way game with no mulligans. You can only pause the game and quit. You can never save the game, make a mistake, and then reload the game. If a dwarf dies, they're dead. This may make it difficult for some players, and if you like do-overs then this game probably isn't for you.

Combat


The combat system allows dwarves to train, equip specific weapons and shields, and become injured or die. The detail found in the history system also exists in the combat system. Axe-dwarves or sword-dwarves will lob off heads, while marks-dwarves (cross-bow wielders) will kill enemies by puncturing vital organs. You can find out (if you wish) that your marks-dwarf killed that fox by puncturing its spleen before the fox bleed out. Your soldiers will break bones that will take months to heal while doctors attend to them.

Overall the combat system is a nice balance to the economy, which I'll talk about below. One disadvantage with the system is that fights tend to be very one-sided. If a dragon shows up, your dwarves are either prepared or they're dragon-meat. There isn't really a delay-the-dragon-while-dwarves train option. Goblins will occasionally siege your fortress, which (again) isn't a problem if you're prepared.

Control with the combat system is probably the weakest link in the game. You can lump dwarves together into a squad, but if the squad leader is sleeping when the goblins attack you have to re-arrange the squad. I think it takes too long to re-arrange the military to respond to the threat. Controlling your civilians is also difficult; control is very coarse, only allowing you to shut off whether civilians or soldiers should stay underground. Additionally, civilians complain so much when they're forced to stay inside that it makes playing the game difficult during an attack. All you see is "civilian complains about going outside because civilian wants to do X." I think this area needs a little bit of work before the game can shine.

(above) Dwarves train in the barracks on the top left.

(above) Examining the wounds of a dwarf. The yellow text signifies a broken bone.

(above) Some goblins (purple and white 'g' characters) ambush and kill a bone carver (dead blue dwarf).

(above) An axe-wielding soldier (blue dwarf) is about to "axe"-xact revenge on the goblins.

(above) The goblins didn't have a chance.

Resources for the Economy


I love building games like Sim City or Civilization. Dwarf Fortress has a great building system. You start by ordering dwarves to mine out an area of a mountain, creating a safe haven from the outside world. You then can create areas for stockpiles of resources, and workshops to turn the resources into either goods or other resources. A trade system exists with caravans to trade for goods. There is a complex assembly line for some goods - for example, to make steel armor, first you'll need steel bars. To get steel bars, a dwarf needs to process iron bars, a flux stone, and charcoal at a smelter. The charcoal needs to be produced at a wood furnace, and the flux stone needs to be mined from specific types of minerals. Charcoal is also used in other industries besides metal-smithing, such as glass-making, so to optimize the resource through-put you have to lay out your fortress stock-piles and workshops correctly.

Creating an effective economy is quite difficult. The distance to the surface of certain industries, such as the wood industry, needs to be balanced against fortress defense. Some structures, such as farms, have restrictions on what type of soil you can build them on top of. Your dwarves need to eat and sleep, but they'll have trouble sleeping near noisy workshops or eating near garbage.

When I first started playing the game I found myself thinking in 2-D...but over time, I realized that highly optimized fortresses needs to be built in 3-D. The extra dimension really adds a lot to the game if you love building assembly lines or working with resource management.

(above) Fields next to a river.

(above) Quarters with a bed and a door for about 100 dwarves. A set of nicer quarters with smoothed walls is in the middle

(above) A stock-pile of furniture on the left.

(above) A set of workshops spread across two rooms to the left of the hallway. There is a nearly empty stockpile of wood below one row of workshops (empty stockpiles are denoted by "=" signs).

(above) A dining room to the left of the hallway, with a garbage dump on the right. A row of workshops is below the garbage dump. The purple cloud is a miasma cloud coming from decomposing waste.


One of the most novel features of the game is the trap and pump system. You can pump water, and then use pressure plates to activate or deactivate flood-gates or pumps. If you want to build an auto-filling cistern or an underground irrigation system, you can set it up so you only have to pull a single lever to get your pumps and flood-gates to do what you want. Are you having trouble with goblins attacking your fortress? Place a puppy some food outside as bait and then drown the goblins when they step on a pressure plate. If you prefer to catch the goblin, use the plate to slam doors shut or just use an old-fashioned cage trap. You could build an arena and then have goblins fight to the death! Or maybe start a goblin breeding program and use the baby goblins as a source of totems.

The building system, I think, is the strongest feature of Dwarf Fortress. The possibilities are endless - whether you want to build an arena or figure out how to build a computer, the open-ended system is one of if not the best I've seen in a game.

Overall


Dwarf Fortress is an old school ASCII game with a lot of promise. If you can look past some of the rough edges with the combat system and incomplete features (the game is still an alpha), the game plays out like Sim City meets tinker toys. Much like Sim City, there is some dead-time while you wait for things to happen, but there is a great reward for building that auto-filling cistern. Overall if you liked NetHack and Sim City I think you'll love this game; but beware the high learning curve almost mandates using a guide to help you out with the first few steps.

2010-03-25

Tip About Airline Flights

On my recent trip from Amsterdam to Boston to Iowa to Amsterdam, I needed to move my last set of flights forward a day because of an important meeting. I called up American Airlines, and because my Boston to Iowa trip had been delayed, AA didn't charge any money to change my flight to Amsterdam.

If you ever need to reschedule flights, AA will be very accommodating if you've had previous delays. This is probably true for other airlines. I hope someone finds this tip as useful as I did.

2010-03-24

Grocery Stores in Iowa

How can any store carry hummus but not pita bread! They even had the extra garlic type of hummus.

Well, I guess that is Iowa for you. Sigh.

2010-03-23

A Little Bit of Dancing

Congratulations to my big sister, who was married this weekend! There were some other photos that were shown at the wedding, but this one was my favorite; I think it sums up a lot of the past.

2010-03-11

California Iowa Here I Come

I'm on vacation for the next two weeks - woohoo! Looking forward to seeing you all.

2010-03-01

Sorry about Anonymous Commenting Being Turned Off

A loyal reader has informed me that anonymous commenting was turned off. My apologies, I've switched it back on.

2010-02-28

Trust in Giant Corporations


Nothing improves trust in a multi-national bank's online security quite as much as a directory listing for a home page.

2010-02-07

It's The Small Things

One reason I love VHDL is that the store operator isn't the equals sign:
IF (SHIFT = state_reg) THEN
read_value <= next_value + read_value;
END IF;
Here is some (nearly) equivalent code in C:
if (SHIFT == state_reg) {
read_value = next_value + read_value;
}

Both lines of code instruct that if state_reg is equal to SHIFT, read_value should be incremented by next_value.

In C the = sign doesn't actually mean equals - that is what the == symbol means. In C, as in most programming languages, the = symbol really means "store the right-hand value into the variable." This caused me no end of confusion when I started programming - if you subtracted read_value from both sides of "read_value = next_value + read_value" wouldn't you get "0 = next_value?" In reality the line instructs the computer to add next_value to the current value of read_value, and store this sum back into read_value.

In VHDL = means equals and <= means store. Unfortunately <= also means less than or equal to. I would have preferred VHDL to use the symbol <- for store. In the first programming language I ever learned, TI-86 BASIC, there was a single-character symbol for <-. I still find the first line below to be the most intuitive of the three:
sum <- element + sum
sum <= element + sum
sum = element + sum
I doubt programming languages will ever change from the equals sign to something else, but I would appreciate it. Every now and then my brain seems to go into math mode, and the = symbols still cause me confusion, but the <= is close enough to <- that I don't seem to notice. Oh well, maybe I'll never master C.

2010-02-03

PyCharm

I love PyCharm from JetBrains! I used Resharper when I was a C# monkey, and I am all ready much more productive with Python because of JetBrains. If you're a Python programmer you have to check out PyCharm as an IDE.

2010-01-26

Software Fail



My license is actually valid.

Just so you're aware, people use Xilinx FPGAs and the tool-chain for critical systems. I hope I'm not shaking your faith in that PET scanner, though. They're probably free from the issues associated with radiation therapy systems.

2010-01-19

The End of an Era

Tomorrow my @mit.edu account expires. It is about time, but I'll still miss it like crazy. The account was easily the best managed e-mail and file account I've ever had. I had over 12,000 messages in my inbox alone and nearly a gigabyte of files, capturing some of the best things I ever experienced, along with some of the most educational.

Farewell, account!

2010-01-07

Officially Old

With another birthday under my belt and the new year started, I am officially old. On the other hand, I've now been programming for more than 10 years! I dug up an old piece of my code, prime3b.java, which was last modified on July 14th, 1999. Technically, I've probably been programming for 12 or 13 years, but I don't think my self-taught, TI-86 programming should count as programming.

According to Wikipedia's Java Version Page, this program would have been created for Java 1.2. The program took a number, computed all the primes to that number, and could print out the calculated primes or number of primes.


import java.util.*;

public class prime3b
{
public static void main(String [] args)
{System.out.print("Would you like to print out all the primes?");
String cond = KeyBoard.readString();
boolean f = true;
boolean d = true;
if (cond == "no")
{f = !f;
}
System.out.print("Would you like to print out the number of primes?");
cond = KeyBoard.readString();
if (cond == "no")
{d = !d;
}
System.out.print("Enter a number:");
int x = KeyBoard.readInt();
int a = 0;
int b = 0;
int []m = new int [100000];
m[0] = 2;
int z = 0;
int e = 0;
int c = 3;
int y = 0;
long t1 = (new Date()).getTime();
for(; c <= x; c = c + 2)
{y = (int) Math.sqrt(c);
for(z = 0; m[z] <= y; z++)
{a = c % m[z];
if (a == 0)
{b = 1;
}
}
if (b == 0)
{e++;
m[e] = c;
}
else
{b = 0;
}
}
long t2 = (new Date()).getTime();
t2 = t2 - t1;
z = e;
if (f == true)
{for (; z != -1; z--)
{System.out.println(m[z]);
}
}
if (d == true)
{e++;
System.out.println("There were " + e + " primes at or below " + x);
}
System.out.println("Time is:" + t2);
}
}



PS In case you're wondering about my instructor's feedback, he said that one day I would be a superb programmer, after I had been crushed by the complexity of a few systems (I don't think he said "been crushed by", maybe "grappled with?"). This would teach me discipline, actions like encapsulating code into functions, thinking about testing, using standard formatting, using better variable naming, checking inputs, checking boundary conditions, and learning that code was also meant for people.

I'm still hoping his prediction comes true.

PPS I think most programmers fall into two categories: OCD programmers who need everything perfect, constantly re-visiting and re-working, or lazy efficient programmers who do the least amount of work even if it means more code. I think the above firmly puts a younger me into the efficient camp.

2009-12-16

Nature and Nuclear Reactions

I've blogged about toilets evolving in nature, but apparently nature also created self-sustaining nuclear reactions:
Perrin and the other French scientists concluded that the only other uranium samples with similar levels of the isotopes found at Oklo could be found in the used nuclear fuel produced by modern reactors. They found that the percentages of many isotopes at Oklo strongly resembled those in the spent fuel generated by nuclear power plants, and, therefore, reasoned that a similar natural process had occurred.
...
Scientists think these natural reactors could have functioned intermittently for a million years or more. Natural chain reactions stopped when the uranium isotopes became too sparse to keep the reactions going.
It is amazing to me that the random motion of matter can create a self-sustaining nuclear reaction with an average power output in the 100 kW range. This interesting anecdote of a complex system arising from random processes is evidence that long time periods and random processes can create surprising, complex systems. Maybe even life?

2009-12-11

Google Wave Invites

Even after sending many invites, I still have a few left over. Let me know if you want one.

2009-12-10

Auto-Pilot

I'm sorry I haven't posted. I've been so stressed out lately that it has taken everything I have to focus on getting an iota of work done every day. I tried writing a long, thoughtful post about what is happening, but it just sounded lame.

I'm not dead, I know I'll eventually have things to blog about, but those things just aren't going to happen any time soon, at least not until I'm back in the states for vacation. You can check out today's PhD strip for a decent run-down on the current events in my life...only imagine someone who is convinced that working now will lead to laziness later, but instead this working is leading to more trouble with working. Or some other non-sense like that.

2009-11-21

Rejection

Last week I went to an astronaut's speech on the future of commercial space flight. The astronaut, Steve Smith, worked on the Hubble Space Telescope while it was in orbit. I got to meet and talk with him personally for a few minutes, and loved every second of it.

He had a lot of interesting anecdotes, but the one that I'm still thinking about is this: the space program rejected him as an astronaut candidate four times before being accepting him. You can only apply once every two years, so he was living in a state of space-program rejection for eight years before being accepted. I wish I had had the foresight to ask him whether this was normal for astronaut candidates, or if he was an exception. Either way, the fact that he keep reaching for his dream, even after eight years of rejection, is amazing and inspiring to me.

2009-11-07

Chip



My 2.5 by 2 mm^2 integrated circuit design was finalized yesterday. Maybe now I can stop stressing out so much?

Probably not.

2009-11-02

Randomizing a Coin Toss

Way to report only the problem, Freakonomics blog:
But it may be that the the random coin toss isn’t so random. A 2007 study found that a vigorously flipped coin is likely to land on the same side it started on at least 51 percent of the time, possibly more depending on the person doing the flipping.
Say you have a coin with a bias that doesn't change from flip to flip. You can remove the bias by flipping the coin twice, and taking the first result if the second result differs from the first or repeating if it lands the same way both times.

Mathematically, if the probability of landing heads is P, then:

  • P^2 = Prob[HH]
  • P*(1-P) = Prob[HT]
  • (1-P)*P = Prob[TH]
  • (1-P)^2 = Prob[TT]


Since the probability of HT is the same as TH, taking the first element removes the bias.

Mad props to von Neumann for inventing this trick (publication was "Various techniques used in connection with random digits"), along with fundamental portions of the theory for quantum mechanics, cryptography, and game theory. They don't make mathematicians like they used to.