Live data from Hacker News

How Dwarf Fortress is built

stackoverflow.blog

191–200 of 407 posts

Re: How Dwarf Fortress is built

#191

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…

That's very interesting, because I had observed exactly the same when I tried to implement a rogue-like in Java some years ago. For example, I had to decide whether there should be different subclasses for spell books, the different weapon types (e.g bows vs swords), drinks, etc. or just one big Item class. Closely related to that, another decision I had to make was whether object or character properties should be im…

Definitely components are the way to go. These have gotten very well known recently in the game dev world thanks to entity component systems, which is what I would call "heavy components," but you can also do "light components." Meaning, you don't need to organize your entire system around an ECS in order to take advantage of some of their benefits.

They make changing behavior dynamically extremely simple. Instead of needing to hardcode classes for each different type of thing players may want to create in your world, you just assign and unassign components. Give a rock the Moveable component and now it moves. Remove the PlayerControl component from the player and put it on, I don't know, an orc -- now you've implemented body swapping. They're even more useful in a game like traditional roguelikes, where you don't have to worry about animating all these dynamic states.

I've actually never thought about how a component system might fit into a more traditional business application; it's an interesting thought experiment but I'm not quite sure it would be a strong benefit.

Re: How Dwarf Fortress is built

#192

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…

Hickey nails this one in his talks. When you make something a class, that's NOT an abstraction, that's a concretion. You make a Tool class, you haven't abstracted what a tool is, you've made a fixed decision about what it is. For games that want this level of complex interaction between components, entity component systems are the way to go.

> For games that want this level of complex interaction between components, entity component systems are the way to go.

Entity component systems are still in a half-baked state, with everyone rolling their own slightly different conceptual model. They're solving a problem, but not solving it well.

One promising direction is getting rid of entities. Components need to link to entities and other components anyway, so one may as well treat entities as zero-size components. Old writeup (not mine): https://github.com/kvark/froggy/wiki/Component-Graph-System

Re: How Dwarf Fortress is built

#193

Earlier quoted context omitted.

As long as you feel good I think it's OK. Most passion projects don't really generate a lot of revenue.

Oh Markus where were you like 5 years ago?!? :)

Me? I don't really have any completed passion project :/ so sad I wish I could at least finish one of them.

Re: How Dwarf Fortress is built

#194
post #28

Earlier quoted context omitted.

"Tool" is still a class, with perhaps very generic polymorphic methods (e.g. do_default_action() ). The problem is not polymorphism per se, but rather about having a deep class hierarchy aka lasagna code. 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.

> 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.

KISS is universal, not only to programming.

But the single responsibility principle and the idea that you should divide your code in components where the lower components should be abstract by the point of view of the higher ones are almost never wrong.

Not by coincidence, those last two are consequences of how people think. While KISS is kind of a physics law.

Re: How Dwarf Fortress is built

#195
post #150

Earlier quoted context omitted.

Liquid items are funny in the game. When you look at an item listing and you see something like “Mead”, that is truly all the item is —- it isn’t a cup of mead, it’s just a vague amount of the liquid mead itself, as if your hand was the only thing keeping it from hitting the ground. But there are containers that can hold your liquid. You have mugs and goblets that hold one quantity of “Mead”, giving the impression th…

My favorite feature in Dwarf Fortress is that all eyelids automatically clean their associated eyeball, just so that players don’t post about how their dwarves have vomit on their eyeballs.

Ahh, so if a dwarf would have a missing eyelid because of combat or some mining accident, then they could have vomit on their eyeballs.

Re: How Dwarf Fortress is built

#196

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…

"Tool" is still a class, with perhaps very generic polymorphic methods (e.g. do_default_action() ). The problem is not polymorphism per se, but rather about having a deep class hierarchy aka lasagna code. 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.

Another good rule for OOP: Objects are fine, object graphs are a killer. Graphs are what get you into "all I wanted was a banana" territory. Objects should either be atomic, agrigated by simpler structures like maps and arrays, or if you absolutely must have objects pointing to objects, be sure that they form a tree and not a graph such that each object need only know about the things below them which can be encapsulated at a single point.

Re: How Dwarf Fortress is built

#197
post #135

Earlier quoted context omitted.

I think you're interpreting his meaning in saying that incorrectly. You're not an employee for somebody else (correct? It's your own project) - it's not a salaried or hourly position where somebody else is currently signing your paycheck. You obviously don't hate it (I hope? If so, not sure why you wouldn't have canned it yet) Thus, this is what most people would refer to as a passion project. You may have a differen…

Yeah for sure, he didn't mean anything by it. I try not to be super sensitive, that makes interacting with people impossible. But sometimes it's hard :).

I have a similar sensitivity around my primary vocation: I'm an artist with a day job, like many others, but since my day job is programming and I take it seriously, a lot of people think of my art as a "hobby." Which it very much is not.

FWIW I have found that three things help me deal with this sensitivity:

1) Take it as motivation to be more outwardly "professional" about my art. Improve the website, be more active on social media, try harder to exhibit, even (ugh) sell things.

2) Remember that most people are just saying that out of ignorance: they don't have a mental model for anything outside of "work for the Man" or "mess around in free time."

3) Have examples ready if someone needs an explanation, and also as inspiration for yourself. For instance: was William Carlos Williams[0] a "hobby" poet?

[0]: https://www.poetryfoundation.org/poets/william-carlos-willia...

Re: How Dwarf Fortress is built

#198

Earlier quoted context omitted.

I was with you until: > Whether it is successful is irrelevant. At some point something needs to be successful or you can't keep working on it, right?

As long as you feel good I think it's OK. Most passion projects don't really generate a lot of revenue.

Yea, but you specifically mentioned this as a career. You'd want _some_level of success if your passion project is your career.

Re: How Dwarf Fortress is built

#199

Earlier quoted context omitted.

Hickey nails this one in his talks. When you make something a class, that's NOT an abstraction, that's a concretion. You make a Tool class, you haven't abstracted what a tool is, you've made a fixed decision about what it is. For games that want this level of complex interaction between components, entity component systems are the way to go.

> For games that want this level of complex interaction between components, entity component systems are the way to go. Entity component systems are still in a half-baked state, with everyone rolling their own slightly different conceptual model. They're solving a problem, but not solving it well. One promising direction is getting rid of entities. Components need to link to entities and other components anyway, so o…

I think this is more of a language paradigm problem. Game programming is very much tied up in C++ and C# for historical and performance reasons, ECS is a way to try and graft what is entirely natural in a more value-based language into OOP mechanics and C++/C# type systems.

ECS is so common and easy in lisps that it doesn't even warrant its own name.

Re: How Dwarf Fortress is built

#200
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…

Noita also had a fun one during early development: deer drowning in their own urine.

And now that I dug up the Reddit AmA thread (https://old.reddit.com/r/Games/comments/d7cqjz/we_are_nolla_...), there's a comment there about the drunken dead cats ...

Post reply on HN