Live data from Hacker News

How Dwarf Fortress is built

stackoverflow.blog

291–300 of 407 posts

Re: How Dwarf Fortress is built

#291
post #28

Earlier quoted context omitted.

> My policy: OOP is like salt. Use little and that's great. I only allow a single inheritance layer, and ideally no inheritance at all. That's been my observation as well - there's no free lunch and DRY isn't free either, certainly not if you use inheritance chains to achieve it. I'm starting to think that the only programming axiom that will survive in the end is KISS.

A few weeks ago some commenter here said they ascribe to WET - Write Everything Twice. Basically worry about abstraction when you get to number three. And what an acronym given the context!

I've never heard this as an acronym, but I use it in practice! For me, it's an extension of "three or more, use a for" that made sense for all repetition and not just loops.

Re: How Dwarf Fortress is built

#292

Earlier quoted context omitted.

Even if it were open source I doubt there would be enough impetus to implement multithreading. It would literally be easier to completely make a new game from scratch with async and threading designs taken into account, instead of trying to adapt an existing monolith. Async and multithreading are complex and introduce many subtle bugs. It's not so easy to just move to that from a single-thread event loop.

I would hope there would be low hanging fruits. Pathfinding for example causes huge huge issues late in the game, same with the fluid calculations. Of course we have no idea how Tarn implemented these things, but I would have to guess if you need to do pathing for 50 entities in a single frame, you could probably parallelize them?!

Not if those entities are moving relative to one another (combat, tasks, social interactions, just moving past one another)

Re: How Dwarf Fortress is built

#293
post #262

Earlier quoted context omitted.

Mattias Johansson uses basically this example in his argument for composition over inheritance. You have humans, robots, and dogs all fitting into your nice class hierarchy. But now you need a robot dog that breaks everything. https://www.youtube.com/watch?v=wfMtDGfHWpA I think inheritance makes the most sense when your problem domain has been known for decades - like airline reservations. But for new blue sky projec…

Robot dogs inherit from robot and dog. Mammalian dogs inherit from mammal and dog.

In a multiple inheritance world yes. But I think most C++ devs decides that led to a big mess in large systems. Supposedly one of the best things about Java was no multiple inheritance.

Re: How Dwarf Fortress is built

#294
post #33

> What’s your favorite bug and what caused it? > A: It’s probably boring for me to say, but I just can’t beat the drunken cat bug... That was the one where the cats were showing up dead all over the tavern floor, and it turned out they were ingesting spilled alcohol when they cleaned their paws. I think that bug explains very well just how deeply complex Dwarf Fortress really is. Drinks can be spilled. Some drinks ha…

Sounds like it’s not a bug but working as intended

The bug was the quantity. Cats that walk around in a place with spilled beer will indeed lick themselves clean, but the amount of beer ingested is tiny.

Imagine getting drunk by licking beer residue off your hands.

Re: How Dwarf Fortress is built

#295
post #144

Earlier quoted context omitted.

I've been working on a project for a long time. It's not even yielding income, though I hope it will. A friend referred to it as a passion project. That hurt for some reason. I can't explain why.

Yeah I agree with this, I would feel hurt too. For some reason the word "passion" has this hidden connotation for me which makes me feel like the project isn't serious, isn't making money, isn't popular, and is just eating up all my time as it is something I constantly obsess over. In the case of Dwarf Fortress, I would say for him it is "the sole project he's been working on for 20 years now, which takes up $large_n…

People do their best work when they care about it. I'd measure success in quality of work rather than monetization. I'll never be impressed by someone with a boat but the person meticulously building what they love will get a beer from me.

Re: How Dwarf Fortress is built

#296

Making the item system polymorphic was ultimately a mistake, but that was a big one. Q: Why was this was a mistake? A: When you declare a class that’s a kind of item, it locks you into that structure much more tightly than if you just have member elements. It’s nice to be able to use virtual functions and that kind of thing, but the tradeoffs are just too much. I started using a “tool” item in the hierarchy, which st…

composition over inheritance... Its the fragility of large inheritance hierarchies. They work well for very rigidly defined real world structures but not so well in most real-world usages.

I came to the comments to say exactly this. I think like any ideological stance, it's extreme and there are exceptions to the rule, but for games it's great for a lot of reasons.

Tarn was wrong about this though:

> Using a single object with different allocated subobjects is almost certainly worse for cache misses

It depends a little on the context, but having object pools is exactly the right thing to do when you're trying to scale. It allows you to group together similar data, reducing cache misses when batch processing. You can even cache-align your primitives, or even run SIMD and multi-core jobs to batch update an entire set of attributes that belong to multiple objects.

Re: How Dwarf Fortress is built

#298
post #88

Earlier quoted context omitted.

Hah, this is like EVE Online for me. I love reading about the espionage and cloak and dagger and pure insanity, but other than a brief toe-dip...oh no I will not play it. DF lives in my blood, however.

Totally agree on reading about EVE Online. This is a real classic if you haven’t seen it before, and actually contains a lot of very important notions for identifying Ponzi schemes: http://web.archive.org/web/20091026234156/http://geocities.c...

"I put the isk in risk!"

Re: How Dwarf Fortress is built

#299

This is a little bit of a hijack but if I wanted to start coding games as a side project, where would I start? Which platform? Mobile, PC, console? Any good introductions on the subject of solo game development? I know I can google this, but I trust HN users more than the Google algo.

The very first game you should make is a Pong/Breakout/Asteroids/Galaga/Frogger clone. It seems simple, but you need to have a surprising amount of systems: graphics, audio, controls, collisions, game states, menus, scoring, user interface.

The engine and language does not matter for this first game. The only thing that matters is completing one small game.

After that, you'll have the level of knowledge to make somewhat informed choices about project #2, where you can expand and innovate. You can use hobbyist engines like Godot and have more control, or more professional engines like Unity or Unreal if you want access to those tools and asset libraries.

/r/gamedev has a useful article: https://www.reddit.com/r/gamedev/wiki/faq#wiki_getting_start...

Re: How Dwarf Fortress is built

#300
post #33

> What’s your favorite bug and what caused it? > A: It’s probably boring for me to say, but I just can’t beat the drunken cat bug... That was the one where the cats were showing up dead all over the tavern floor, and it turned out they were ingesting spilled alcohol when they cleaned their paws. I think that bug explains very well just how deeply complex Dwarf Fortress really is. Drinks can be spilled. Some drinks ha…

Space Station 13 is another game with a lot of serendipitous emergent gameplay but with a slightly less steep (but still insane) learning curve and multiplayer antagonist fun.
Post reply on HN