Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Dwarf Fortress Programming Questions  (Read 31234 times)

AMarkos

  • Escaped Lunatic
    • View Profile
Dwarf Fortress Programming Questions
« on: July 12, 2008, 05:30:33 pm »

In what language is Dwarf Fortress written? I am curious also what books the brothers studyed in order to write it, like AI and stuff. Im a noob gamedev with a knack for ASCII games and I am thoroughly interested on how to achieve that level of realism!
Logged

Tahin

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Programming Questions
« Reply #1 on: July 13, 2008, 12:11:23 am »

DF is written in either C or C++. I forget which. It uses OpenGL to display the characters, which are actually drawn on a flat plane in a 3d space, if I remember correctly. You might want to look at Curses or something if you're interested in programming ASCII stuff.
Logged

Keiseth

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Programming Questions
« Reply #2 on: July 13, 2008, 12:27:17 am »

Aye, as Tahin said. Fairly certain it's C++ though... a program like this in C would be a nightmare!* Besides Curses, If you're not up to raw OpenGL, you can try the SDL library.

I'd really like to know what books or resources for programming Toady used(uses?), if any.

(*Fun with switch statements!)
Logged

Ostsol

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Programming Questions
« Reply #3 on: July 13, 2008, 02:06:46 pm »

How would C++ eliminate the "fun" with switch statements?  Keep in mind that there are many very large projects that even now still use plain old C.  For example: the Linux kernel.
Logged
Ostsol

Tahin

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Programming Questions
« Reply #4 on: July 13, 2008, 02:45:46 pm »

I'm pretty sure Toady said he used C++.
Logged

Radtoo

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Programming Questions
« Reply #5 on: July 13, 2008, 03:36:10 pm »

If you want me to state my 2 cents on the matter:

While a versatile language, C++ isn't really responsible for "realism". That's all achieved through having a good idea for a game and then the persistence to see it through.

What you may want to learn a bit about is the fairly dry matter of data structures (trees / graphs etc) and their algorithms. You can build a lot of things, including game AIs, on top of that knowledge.

Most others who have done so and described it (books / online) generally expect you to know this stuff anyways, since they pretty much want to describe what they do additionally / better on top of the basics.
Logged

Zurai

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Programming Questions
« Reply #6 on: July 14, 2008, 05:56:26 am »

There's nothing you can write in C++ that can't also be written in C. C++ was written in C, after all.
Logged

Earthquake Damage

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Programming Questions
« Reply #7 on: July 14, 2008, 06:46:02 am »

If you're just starting out, it's probably better to learn ANSI C than C++ (though Python may be even better since it presumably will help you develop better coding style -- the syntax is pretty strict apparently).  Once you're fairly adept with that, you can move on to C++ with its additional set of (syntactic/grammatic) bells and whistles.
Logged

Volatar

  • Bay Watcher
  • The Mutant Cheese Monster
    • View Profile
    • Anilist
Re: Dwarf Fortress Programming Questions
« Reply #8 on: July 14, 2008, 07:12:31 am »

I personally am learning to code in C++ as my first language. I like the language.

The problem with saying you can do everything C++ on C is that for some things you will have to rewrite bits of C++. C++ is already written, and in my opinion, does not need to be written again  ;)
Logged
Quote from: Vilien
Yes, you should always apply more magma.

falsedan

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Programming Questions
« Reply #9 on: July 14, 2008, 07:43:54 am »

There's nothing you can write in C++ that can't also be written in C. C++ was written in C, after all.

Zurai write me a C-only replacement for auto_ptr<>, or a similar function for variables allocated memory from the heap that automatically deletes them when it goes out of scope
Logged

TheSpaceMan

  • Bay Watcher
    • View Profile
    • http://www.digital-lifeform.com
Re: Dwarf Fortress Programming Questions
« Reply #10 on: July 14, 2008, 07:48:53 am »

yeah it's defenetly c++. It's the reason between the long time between updates a while back. Changing the entire thing from C to c++ i think.

Programming games isn't about the books or the tutorials in a way. It's just as important to have the right people around you that can find that can give the right answers to the completly wrong questions. :)
Logged
Poking around with a DFParser.
Bodypart names, creatures names in one easily overviewable place.

Oh my new (old) picture?

Dr. Melon

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Programming Questions
« Reply #11 on: July 18, 2008, 11:27:50 am »

You can't expect to achieve much in the way of games programming through books and tutorials. I've tried, and it doesn't work. You need to apply the things you learn from those into games.

The main thing about games is the backbone; graphics and gimmicks come later. You need to focus on the logic and maths of the game before the rest comes in.
Logged

xzzy

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Programming Questions
« Reply #12 on: July 18, 2008, 05:42:41 pm »

The main thing about games is the backbone; graphics and gimmicks come later. You need to focus on the logic and maths of the game before the rest comes in.
And for that, I think something like Python is a much better tool. It lets you focus on the program, instead of the programming.

Yeah you'll lose some performance by not using a compiled language, but it's not something you'll notice as a beginner. Seeing results is much more important early on, from a motivation standpoint, which is what a scripting language can provide.
Logged

Keiseth

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Programming Questions
« Reply #13 on: July 18, 2008, 06:13:58 pm »

Seeing results is much more important early on, from a motivation standpoint, which is what a scripting language can provide.

I agree entirely. In fact, not getting any sort of even useless initial result is what almost made me give up on programming. I had erroneously tried to learn C++ first, but found a scripting language later that was much nicer to start with.
Logged

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile
Re: Dwarf Fortress Programming Questions
« Reply #14 on: July 21, 2008, 06:36:01 am »

Zurai write me a C-only replacement for auto_ptr<>, or a similar function for variables allocated memory from the heap that automatically deletes them when it goes out of scope

It's fairly trivial, except you would have to add some function call at the end of every function using this feature. That's what they did with Samba 4 AFAIK.
Logged
Pages: [1] 2