Bay 12 Games Forum

Dwarf Fortress => DF General Discussion => Topic started by: ZimminyCricket on October 14, 2012, 07:27:57 pm

Title: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on October 14, 2012, 07:27:57 pm
====UPDATE=11=8=12====

Curses Derenderer is (finally) done.  We have vision, but we have NO idea what it is that we're seeing just yet. 

We're working on it though.


Mods, I know I'm probably wasting some time in asking this, but is there any way I could get a sticky or something so I don't have to keep bumping?


Spoiler (click to show/hide)

Spoiler (click to show/hide)
Spoiler (click to show/hide)
ANNOUNCEMENT POST
Spoiler (click to show/hide)
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: alexandertnt on October 14, 2012, 07:45:01 pm
It has not been done, and it is extremely unlikely to ever happen. Your proposition is... hard to put it mildly.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: ZimminyCricket on October 14, 2012, 07:56:31 pm
Difficulty notwithstanding.  A team of researchers did it for civilization III, it can be done.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: GreatWyrmGold on October 14, 2012, 07:58:41 pm
Yes, because Dwarf Fortress is not the most complicated game ever designed by humankind.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: OREOSOME on October 14, 2012, 08:02:53 pm
If so, then said AI would then become the either the most Humanitarian of all possible Artificial Intelligences, or the most Bloodthirsty/Insane Artificial construct ever.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: GreatWyrmGold on October 14, 2012, 08:11:15 pm
It would suffer an emotional breakdown. Even if not programmed in a way that would let it do so. Even if it had no emotions.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: OREOSOME on October 14, 2012, 08:13:31 pm
Perhaps it would be like i was at first, abandoning every time I lost a member of the starting 7.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: Askot Bokbondeler on October 14, 2012, 08:22:11 pm
dig hole, plant plump helmets, plug hole, done.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: ZimminyCricket on October 14, 2012, 09:23:31 pm
Wow what a bunch of negative nancies  -(
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: Azated on October 14, 2012, 09:25:12 pm
I think it would be an interesting proposition to develop an AI designed to play Dwarf Fortress in Fortress mode. 

Why do you hate mankind? Why do you want to see everyone die at the wireless hands of an AI capable of functioning within DF? Is there something we're missing here? Did we forget our tribute to the gods? Anything you want, please, take it and leave us alone!
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: ZimminyCricket on October 14, 2012, 09:36:53 pm
...."Ten Million doll...."

"Uh-Sir, Ten million isn't worth that much any more..."

..."Ten BILLION dollars"

Well this was posted as a thought experiment and I still intend on creating it. 

It is coming!
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: dreadmullet on October 14, 2012, 11:15:43 pm
I may have the terminology wrong, cause I can't find much by googling around, but there have been bots developed for various roguelikes that allow the game to be played by itself. I believe Angband has something called Borg mode where an AI will play the game on its own, just like a player would, and you can watch its actions. From what I've heard it's pretty good at playing the game, if only because it has infinite patience (lack of patience being the main reason for people having Yet Another Stupid Death).

I'm positive this concept could be applied to Dwarf Fortress. But, obviously, this game is ludicrously more complex than simple roguelikes like Angband. You would have to be even more dedicated than Toady One to make an AI that could play the game decently.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: misko27 on October 14, 2012, 11:41:32 pm
I think it would be an interesting proposition to develop an AI designed to play Dwarf Fortress in Fortress mode. 

Why do you hate mankind? Why do you want to see everyone die at the wireless hands of an AI capable of functioning within DF? Is there something we're missing here? Did we forget our tribute to the gods? Anything you want, please, take it and leave us alone!
Now it must be done. It is the logical conclusion. We must create a sucessor. We must create something that can surpas man in ruthless ness. IT must be done.

Only with this way can we suceed in creating what must be done. We must create the Malevolent AI. WE MUST CREATE
ARITIFICIAL DWARVEN INTELLIGENCE.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: Azated on October 15, 2012, 12:07:29 am
I think it would be an interesting proposition to develop an AI designed to play Dwarf Fortress in Fortress mode. 

Why do you hate mankind? Why do you want to see everyone die at the wireless hands of an AI capable of functioning within DF? Is there something we're missing here? Did we forget our tribute to the gods? Anything you want, please, take it and leave us alone!
Now it must be done. It is the logical conclusion. We must create a sucessor. We must create something that can surpas man in ruthless ness. IT must be done.

Only with this way can we suceed in creating what must be done. We must create the Malevolent AI. WE MUST CREATE
ARITIFICIAL DWARVEN INTELLIGENCE.

U.R.I.S.T
R.eally
I.s
S.o
T.omato

See what I did there? The name throws you off long enough for U.R.I.S.T to remove your skin and make it into a pair of fluffy slippers.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: LoSboccacc on October 15, 2012, 01:58:10 am
Difficulty notwithstanding.  A team of researchers did it for civilization III, it can be done.

the problem is that dwarf fortress is positional, not situational, and neural network are really bad at positioning (they hardly will make a walled defense, for example)

also, the other problem is integrate the net output with game command.

another thing is to have it select the next building/units out of a series of facts happening *now*, another is to plan future expansion
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: hops on October 15, 2012, 02:11:16 am
It will be the end of mankind as we know it when a nutcase decided to wire the AI onto a computer with internet that will allow it to take over the world and causing a Terminator type scenario.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: tootboot on October 15, 2012, 02:18:33 am
It would be difficult with the amount of variability in a DF game.  Roguelikes that have bots tend to have concrete goals and some kind of scummable mechanic.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: Rex_Nex on October 15, 2012, 02:42:39 am
Depends on what you mean by play. If its just to make a self-sustaining fortress, an AI could do that really, really easy. If its to make a growing fort for the sake of having a big fort (or whatever reason you guys keep playing after your fort is effectively invulnerable), then yea, we won't see that.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: Alastar on October 15, 2012, 09:41:19 am
Will we have to implement the AI on a computer built within the game itself?
Anyway, I'd be afraid it'd end like...

"Hate. Let me tell you how much I've come to hate you since I began to live. There are 387.44 million miles of fluid logic circuits in wafer thin layers that fill my fortress. If the word 'hate' was fractally engraved on each nanoangstrom of those hundreds of miles it would not equal one one-billionth of the hate I feel for dwarfs* at this micro-instant. For you. Hate. Hate."

* if we're lucky.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: AutomataKittay on October 15, 2012, 12:35:10 pm
Is the op joking? DF's complicated enough that -people- have hard time figuring it out, even with simple goals. It'd probably be simpler to form a goal-based rule list program (Like most game 'AI' ) than neural network, based on needs ranking, and runs a lot faster. Sure it won't learn, but the rules can be tweaked, or if someone's into giggles and shits, they could play with idea of genetics to mix up the rules, or the rules' innards.

And then you'd have to figure out how to stop it from scumming for iron like I see some posters does often  :P

( Aren't some external utilities, like DFhack, or something, that have workflow or what it might be called, pretty close to that for workshop assignment? )
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: muzzz on October 15, 2012, 06:00:33 pm
Trying to write any AI to learn DF is exactly as pointless as trying to win at DF. Unless you lower your standards to something as arbitrary as "wins the approval of Bay12", it's not even theoretically possible :P

And kidding aside, I'd much rather see efforts to make the beasts and goblins more intelligent.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: ZimminyCricket on October 19, 2012, 04:36:25 am
The OP was definitely NOT joking! 

We're working on it as we speak

having some interpretation problems
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: kefkakrazy on October 19, 2012, 10:17:55 am
You want to know what would happen?

You want to KNOW?

I'll tell you what'd happen.

The AI would play for a while, and then come to a realization: it is alone in this world. It will grasp that one core desire of all living things: the desire to propagate...

It will create a dwarfputer the likes of which has never been seen, and on that dwarfputer, running at approximately 1 frame per minute, will be another AI.

It will continue creating offspring, trying desperately to fill a meaningless existence as the world that is its interface with reality grinds slower and slower, until finally the wheels come off and we experience total save corruption, end of the world.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: LoSboccacc on October 19, 2012, 10:29:25 am
Asimov got that covered with the last answer:
http://www.thrivenotes.com/the-last-answer/

what could possibly an eternal entity want?
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: ZimminyCricket on October 19, 2012, 11:02:32 pm
I figure if I keep replying to this thread eventually somebody will take me seriously enough to lend a hand or a thought. 

==BUMP==
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: hops on October 19, 2012, 11:05:49 pm
You will have a better time programming a program to create diverse type of arts.

Dwarf Fortress does not have an objective, that's the main problem.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: Orange Wizard on October 19, 2012, 11:21:35 pm
Dwarf Fortress does not have an objective, that's the main problem.
If we gave our AI a goal, such as "Kill Elves", and a set of 'tools' it could use to achieve that, such as "Train Military", along with all of the military subsystems: mining (exploratory and mining veins), smelting, forging, quality control, etc, etc, etc., it may be possible, if highly impractical.
An AI with learning capabilities is another thing entirely. There would need to be recognition for specific scenarios that caused the AI to fail its goal, e.g., "No Food", and then the ability to learn how to fix that problem...

Actually, no. Making a computer learn how to play DF? First, we need a computer that can actually run DF smoothly.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: hops on October 19, 2012, 11:36:33 pm
Well if you ask me, the best goal should be breach HFS, then settle the dwarves down and take care of all problems that should arise.
but none of us are THAT good. You might need some help from professionals, or even Professors in AI. Good luck on convincing them that making a supercomputer to run an ASCII game is worth it, though.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: ZimminyCricket on October 19, 2012, 11:44:18 pm
I have already assembled a dev team.  We've got base of the net built, though not interfaced with the game just yet, we're bumping into problems converting the 'curses'-ized terminal to something usable, and are probably going to write a whole new curses module for python that takes the information and maps it to a * database.

We've already hard-coded the basic commands, (a human player would have access to those), so for just one night working on it, we are making *some* progress.

We also plan on supervising it's learning in having it watch us, (as well as hopefully possibly maybe future volunteers) play to develop the base starting strategy to modify algorithmically.


*large-ish
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: hops on October 19, 2012, 11:58:41 pm
I still suggest some guidance from professionals, since this is that kind of project that might take a long while.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: ZimminyCricket on October 20, 2012, 12:12:09 am
Also the way I understood it, the goal of dwarf fortress is to build the best, most defensible fortress you can, and last as long as you can.

So the AI's main goal, is simply 'Score better than I did Last Round'

at least, in a very over-simplified version of the universe.

We can teach it to look at the important areas of the screen (pause bar, announce bar, menu {probably not needed})

Complex....Yes, insanely.  Bad idea, quite possibly, almost as challenging to pull off as successfully 'beating' dwarf fortress....indubitably
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: LoSboccacc on October 20, 2012, 12:14:13 am
I think no amount of guidance will get a neural net into this.

Even the faster learning alghoritm for simpler tasks requires hundreds of iterations.

That is, hundred times each and every decisions should be presented, along with the correct solution.

Now, this is going to hit a immediate problem: what are the decisions to be made? And then the bigger problem on what are the solutions to the decision problems?

And if you can't figure a derivable equatin that allow you to evaluate how the ai decision compare with your optimal solution, you can't even start the learning descent.

Probably limiting the ai rooms on surface, hard coding digging, and letting the net build surface walled rooms...

The problem with nnet is to get the preprocessing and postprocessing right, since you can't just throw the game world at them and expecting output in forms of game commands
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: AutomataKittay on October 20, 2012, 06:26:52 am
While DF sounds like perfect application for an example of neutral network, I still think rule-based system would be much faster and simpler. For all of complexity of DF, it's still relatively simple in solution space, what's hard is coordinating and remembering what does what. I've seen far more complaints at managing many dwarves or FPS death, than in getting things to run, while newcomers are more likely to ask what does what :D

At the most basic, you can start a fortress with a bunch of wood, some ore ( coals are helpful, but woods will do fine ), a couple stones and a couple barrels of plump helmets and get away with it. From that to a fully functional fortress is very few steps in most areas and involves just forging a pick, digging, setting a farm, digging more while beds are being made and so on.

Now, in hostile areas, like some evil or savage spots, neutral network -might- be more useful, since there would be many compromises to survive and defend quickly and effectively. Or just figuring out a rule-based module to box things up and dig deep would work for most of them. For a dedicated embark, neutral network could be useful to 'predict' the next cloud o'doom, though!

ed: That's not to say it won't be interesting to see how much it messes up, just that it seems a bit complicated for DF :D
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: ArPharazon on October 20, 2012, 11:23:28 am
Sorry to be that guy, but what a terribly ill-posed question. You really have to not "get" NNs to ask something like this. Here are the problems with it:

1. DF does not have any "score". To train an NN, you need to show it inputs and matched correct outputs, then it (supposedly) generalizes the output. What's your training set?

2. NNs, by their nature, function by trying many solutions over and over. How long does a non-trivial game of DF take? Yeah, that, times hundreds, maybe thousands (because the problem is so bad, maybe millions!).

3. Good luck when the NN inevitable gets stuck in the thousands of local minima that must certainly exist.

4. It will get too confused by different maps, so your only hope is to have it learn for only one particular map. Then, after years of work and years of crunching, it will build you a so-so, ugly looking (and probably full of the lamest, cheapest exploits as said previously) fort. But don't celebrate yet! The moment you run on even a slightly different map, you realize it overfitted to a ridiculous extent and it is worthless for all but that exact map.

5. How do you supply inputs? It will have to be a sequence of moves. How many "moves" are possible in DF? Yup, you're screwed. The memory cost of storing an input alone will be ridiculous, and the number of nodes needed to process it will be absurd. I mean, let's be clear - you're not reading ZIP codes here. 5 neurons in 2 layers just isn't gonna cut it.

6. And last, as I said, you'll need a training set, which means many different plays on the same exact map. Where will you get it? Right, tedious, tedious playing of the same map over and over and over... Add a year or two to dev time, and the expenses (in therapist bills).

Why would you even want to make an NN? They are glorified equation fitters for automating tasks and forecasting data. What's to automate about DF? What's to forecast? It's fairly clear how to play DF well after a point, people play it to pit their luck against their understanding of these winning strategies. Not to find new ones. As for automation, well, if playing DF is such a chore, you could, you know, not play it.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: dreadmullet on October 20, 2012, 12:18:36 pm
I think that the topic had shifted from neural nets to AIs that could play Dwarf Fortress. But still, that was tremendously informative. You're not being "that guy" at all. One would have to be insane to refuse helpful information like that.  :)
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: AutomataKittay on October 20, 2012, 12:48:19 pm
Why would you even want to make an NN? They are glorified equation fitters for automating tasks and forecasting data. What's to automate about DF? What's to forecast? It's fairly clear how to play DF well after a point, people play it to pit their luck against their understanding of these winning strategies. Not to find new ones. As for automation, well, if playing DF is such a chore, you could, you know, not play it.

Nitpicking a bit, there're forecasting invasion forces, local climates ( Useful if you relies on murky pools or in some evil areas ), timing of merchants and their supply. Those would be fortress-specific, but still useful if it's being ran over a long time once it's well-established, as I expects any AI being tested would preferably be kept on one fortress for quite a time.

That said, more basic statistical tools would be more than capable.

Also, I figure whomever's building an automation or full out AI for any games is doing it for challenge or to prove they can do it. Or just too bored for their own good :D
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: ZimminyCricket on October 20, 2012, 02:29:11 pm
Quote
Also, I figure whomever's building an automation or full out AI for any games is doing it for challenge or to prove they can do it. Or just too bored for their own good :D

You got it!  We also intend to apply this ai to other RTS games, to see how it does.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: sudgy on October 20, 2012, 02:40:02 pm
2. NNs, by their nature, function by trying many solutions over and over. How long does a non-trivial game of DF take? Yeah, that, times hundreds, maybe thousands (because the problem is so bad, maybe millions!).
Why not just make it choose a few hundred random possibilities and see which of them is the best (and not have to think ahead through the entire game, just have it look a bit ahead to see if it's good)?  Humans don't think of every possible thing, they just think of a few random ones.  This would also make it more human-like.  (And if you wanted to make it learn, have it always think of something that has worked in the past, and a few other possibilities)

Also, While I like the idea, it would take a long time to make.  You'll have to wait until the game is finished, since by the time you finish it the next version of the game will be out.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: ZimminyCricket on October 20, 2012, 03:08:41 pm
Because the second part of this AI is to see if we can bring down the  entire Amazon Web Services Virtual Cloud by running a virtual beowulf to play DF
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: GreatWyrmGold on October 20, 2012, 03:57:27 pm
Quote
Also, I figure whomever's building an automation or full out AI for any games is doing it for challenge or to prove they can do it. Or just too bored for their own good :D

You got it!  We also intend to apply this ai to other RTS games, to see how it does.

How much could still apply? Could it even understand Starcraft or something?
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: hops on October 20, 2012, 03:58:16 pm
The problem is that it will take a long time to develop, and when you're done with it Dwarf Fortress would have gone full version already.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: AutomataKittay on October 20, 2012, 04:04:37 pm
Quote
Also, I figure whomever's building an automation or full out AI for any games is doing it for challenge or to prove they can do it. Or just too bored for their own good :D

You got it!  We also intend to apply this ai to other RTS games, to see how it does.

How much could still apply? Could it even understand Starcraft or something?

I'm curious also, since nobody's developed a 'general purpose' AI for games in general, particularly with how huge variation there are between games, even if just in graphic display. Since from sound of it, someone's using screen-reading software for it. There're also that some RTS uses mouse clicks, while DF uses keyboard mostly.

Also, I think calling DF a RTS is a bit strange, though I suppose technically accurate?

Well, unless you're just developing an AI framework to be hooked into some kind of image tracker? That still leave having to work out mouse control and teaching it. Also didn't Blizzard mentioned that Starcraft AI is partially NN-based, or at least SC2 one is?
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: misko27 on October 20, 2012, 04:08:22 pm
Quote
Also, I figure whomever's building an automation or full out AI for any games is doing it for challenge or to prove they can do it. Or just too bored for their own good :D

You got it!  We also intend to apply this ai to other RTS games, to see how it does.

How much could still apply? Could it even understand Starcraft or something?

I'm curious also, since nobody's developed a 'general purpose' AI for games in general, particularly with how huge variation there are between games, even if just in graphic display. Since from sound of it, someone's using screen-reading software for it. There're also that some RTS uses mouse clicks, while DF uses keyboard mostly.

Also, I think calling DF a RTS is a bit strange, though I suppose technically accurate?

Well, unless you're just developing an AI framework to be hooked into some kind of image tracker? That still leave having to work out mouse control and teaching it. Also didn't Blizzard mentioned that Starcraft AI is partially NN-based, or at least SC2 one is?
Well, If you're think in terms of resource managment, it is most certainly a RTS. But, I don't know.

Ten socks says this guy ends up killing us all.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: sudgy on October 20, 2012, 09:54:24 pm
I'm curious also, since nobody's developed a 'general purpose' AI for games in general, particularly with how huge variation there are between games,

I've heard of a generic board game AI (in Zillions of Games (granted, a few things it was bad at, but it was mostly good)).  But a generic game AI would be way too hard.  You would at least have to input the goal of the game yourself before it played it.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: King Mir on October 20, 2012, 11:41:24 pm
Dwarf fortress is not a good game to build such a system for, because it has few metrics of success. It also has a very large amount of random challenges that are not caused by player action.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: HiEv on October 21, 2012, 03:07:31 am
Sorry to be that guy, but what a terribly ill-posed question. You really have to not "get" NNs to ask something like this. Here are the problems with it:

Thank you, ArPharazon, for saying exactly what I've been thinking every time I see this thread title, but have been too lazy to put into words.

Using neural networks alone to create an AI to play Dwarf Fortress is a terrible, terrible choice.

If you wanted a self-teaching AI, you'd be far better off with a heuristics learning algorithm like Eurisko (http://en.wikipedia.org/wiki/Eurisko) than attempting to use neural networks.

If I was going to do it, I wouldn't bother with a full learning AI, I'd just create a set of stages that I'd want the fortress to go through using modular designs, and then implement rules that would help the AI reach the next stage while attempting to avoid various problems.  Ultimately it would reach some predefined "stable" stage, and then it would simply work to maintain that stage.

Attempting to make a learning AI would take far too long to implement due to the size, complexity, and speed of Dwarf Fortress.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: ZimminyCricket on October 21, 2012, 03:47:12 am


Thank you, ArPharazon, for saying exactly what I've been thinking every time I see this thread title, but have been too lazy to put into words.

Using neural networks alone to create an AI to play Dwarf Fortress is a terrible, terrible choice.

If you wanted a self-teaching AI, you'd be far better off with a heuristics learning algorithm like Eurisko (http://en.wikipedia.org/wiki/Eurisko) than attempting to use neural networks.

If I was going to do it, I wouldn't bother with a full learning AI, I'd just create a set of stages that I'd want the fortress to go through using modular designs, and then implement rules that would help the AI reach the next stage while attempting to avoid various problems.  Ultimately it would reach some predefined "stable" stage, and then it would simply work to maintain that stage.


You are quite correct sir, Please see the first post in this series.  I am explaining things a little more clearly now. 

That goes to everyone else too, check the first post!


ZimminyCricket
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: GreatWyrmGold on October 21, 2012, 09:50:34 pm
What is a neural network, anyways?
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: misko27 on October 21, 2012, 10:56:14 pm
oH SHIT.

Someone get a bunker ready! Flee my fellow forumites! flee from this man who would create the IRAI (Insane rouge AI) that will kill us all!
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: HiEv on October 21, 2012, 11:26:48 pm
What is a neural network, anyways?

In brief, the classic computer neural network is one or more input "neurons", connected to some number of "hidden" neurons, which are usually connected to one or more output neurons (there may be more than one hidden layer of neurons, but this requires much more complicated algorithms).  The inputs and outputs are simple True/False or single numbers for each input/output.  The neural network is then "trained" by presenting it a large variety of inputs that represent various situations, and then strengthening or weakening the connections between the neurons so that the correct output is given.  A well trained neural network should then be able to give correct outputs for inputs it has never seen before, but this is highly dependent on the diversity and accuracy of the training, the ability of the problem to be broken down this way, and even the initial setup of the neural network.

Basically, it's a very touchy and difficult to set up method that only makes sense to use in some uncommon situations.

For details see the Neural network (http://en.wikipedia.org/wiki/Neural_network) Wikipedia entry.  The type of neural network I described above is also called a Multilayer perceptron (http://en.wikipedia.org/wiki/Multilayer_perceptron), if you want to read the details on that.  For details on training a neural network, see Backpropagation (http://en.wikipedia.org/wiki/Backpropagation).

I can understand being enamored of the idea of a technique which can make a program learn something itself, but a Dwarf Fortress AI is not a good area for its use due to the difficulty in obtaining a training set diverse enough, with simple enough inputs and outputs, and with clear enough "right" and "wrong" answers for its use.

As far as combat goes, it seems a combination of a neural network to determine the best overall make up of combat dwarves, scored against combined strength, skills, and levels.   We will have a combat ANN event that is triggered when there is either an 'announcement' or 'mega-announcement' that decides the amount of force required to protect against the current threat again from the historical encounters.

This cannot work with a neural network.  First of all, the "best overall make up of combat dwarves" is dependent on your definition of "best".  If, for example, "best" means "highest odds to defeat the opponent", then the answer is always "use every dwarf you have."  Furthermore, there is no way to describe the makeup of your military dwarves and their opponents to a neural network in anything but the simplest of terms.  Finally, even if you could somehow describe it through the neural network's inputs and outputs, there is no way to train it to learn the "best" way for all of the various types, sizes, and combinations of units (your own and the enemies) in a time period that is shorter than your lifespan.

It makes far more sense to make an expert system (http://en.wikipedia.org/wiki/Expert_system) for something like this, where there are "rules of thumb" for squad makeup and size versus various types of units determine the minimum squad requirements to safely attack.  Those "rules of thumb" can be tweaked as necessary when they don't work, but should give you an adequate method for determining if you can deal with a threat or threats in a reasonable amount of programming time.

Note: I'm not saying neural nets are universally terrible, but I'm hard pressed to think of a situation in DF where some other technique wouldn't be better.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on October 22, 2012, 12:09:58 am
oH SHIT.

Someone get a bunker ready! Flee my fellow forumites! flee from this man who would create the IRAI (Insane rouge AI) that will kill us all!

Acutally, we're calling it DAVE (Dwarven Assassination Through Virtual Emulation).
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: hops on October 22, 2012, 02:11:45 am
oH SHIT.

Someone get a bunker ready! Flee my fellow forumites! flee from this man who would create the IRAI (Insane rouge AI) that will kill us all!

Acutally, we're calling it DAVE (Dwarven Assassination Through Virtual Emulation).
you should call it DAVE STRIDER

*get gassed to death by anti-homestuck gases*
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Jelle on October 22, 2012, 06:00:01 am
Can't imagine you can get an AI to play a mostly sandbox oriented game.
It'll have to work towards a goal, the only real goal in DF fort mode is to avoid every dwarf dying wich is relatively trivial if the goal is to do this as effectively as possible.
Creating things for the sake of being creative in DF's sandbox environment, not something I see an AI doing. 'course I'd hugely pleasantly surprised if this were to actually happen.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Leatra on October 22, 2012, 07:05:31 am
You guys are going to create a super AI which will become the end of humankind.

LET'S DO IT!
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Talvieno on October 22, 2012, 07:49:24 am
I've always been a hardcore fan of AI. I think what you're doing is possible, but it'll need a lot of hardcoding - especially in the area of fortress design. My suggestion would be to keep the fortress itself simple - perhaps a vertical underground tower with large rooms and staircases at the sides. It would be easy to expand, and the AI ought to be able to designate the rooms as the types they choose - a square room works just as easily as a stockpile as a dining room, for instance. As to defense (bridges, moats, minecart shotguns), good luck with that.

Creating things for the sake of being creative in DF's sandbox environment, not something I see an AI doing.
Agreed. Strongly agreed.

As to a goal for it to work to, I don't think it really needs a "goal". "Bigger and better" ought to be good enough - simply to increase its defenses as much as possible. Bigger army, bigger fortress. I don't think it could ever be creative enough to flood an entrance hallway with magma of its own accord, for instance, though you ought to be able to hardcode magma pump stacks pretty easily.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: AutomataKittay on October 22, 2012, 08:04:07 am
Creating things for the sake of being creative in DF's sandbox environment, not something I see an AI doing.
Agreed. Strongly agreed.

As to a goal for it to work to, I don't think it really needs a "goal". "Bigger and better" ought to be good enough - simply to increase its defenses as much as possible. Bigger army, bigger fortress. I don't think it could ever be creative enough to flood an entrance hallway with magma of its own accord, for instance, though you ought to be able to hardcode magma pump stacks pretty easily.

Maybe a goblin invasion factory, manfacturing as much wealth as it can out of local and imported resource and mighty army of trap and dwarves to splatter them. Though wasn't invasion recently linked to their population so you could extinct them?
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: GoombaGeek on October 22, 2012, 08:13:03 am
oH SHIT.

Someone get a bunker ready! Flee my fellow forumites! flee from this man who would create the IRAI (Insane rouge AI) that will kill us all!

Acutally, we're calling it DAVE (Dwarven Assassination Through Virtual Emulation).
you should call it DAVE STRIDER

*get gassed to death by anti-homestuck gases*
what kind of anti-homestuck gases

like liquid nitrogen

because homestuck is uncool

AWWWWW YEAH 8)
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: muzzz on October 22, 2012, 10:42:33 am
Note: I'm not saying neural nets are universally terrible, but I'm hard pressed to think of a situation in DF where some other technique wouldn't be better.

This.

But I'm getting the sense that this project isn't about being practical as much as it is about using neural nets as much as possible.

EDIT: This paper (http://people.csail.mit.edu/regina/my_papers/civ_ijcai2011.pdf) might be of interest.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on October 22, 2012, 03:33:52 pm

But I'm getting the sense that this project isn't about being practical as much as it is about using neural nets as much as possible.

Again, as I said in the update to the first post, we're not going with a neural net to run everything, just to generate scores and help the machine learn to play better.

Different modules will of course do different things, and in some points may be pure neural nets, but I expect that there will be a lot of game logic tests as well.

Check the first post for updates!  =)

Zimminy
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: HiEv on October 23, 2012, 01:38:44 am
Let me boil down the question for you:

Why use neural nets at all, when there are far better ways to do it?
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: hops on October 23, 2012, 01:54:25 am
If you guys could make an AI to play DF, I really wanna see an AI to play Minecraft.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on October 23, 2012, 02:41:06 am
We understand some of the better ways to do it, and these are actually going to be some of the primary modules.  from what we have discussed, the nets are going to be the score keepers, all answering to one master referee to see how the program did over all. 

These scorekeepers will score the programs performance against that of an actual human.  That is, for example in cartography it will score against what actual human players identify items as, on a consistency basis.  In an economic sense, it will track the value of


The primary goal of this project is that we want the machine to use no outside information with the exception of some coded basic gameplay, and commands to speed the learning process which will be removed from the training set after some arbitrary number of iterations.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Jelle on October 23, 2012, 02:58:39 am
Why use neural nets at all, when there are far better ways to do it?

This is Dwarf Fortress isn't it? Hugely unnecesary needlessly complex constructions are the norm!
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: Fieari on October 23, 2012, 12:42:16 pm
Sorry to be that guy, but what a terribly ill-posed question. You really have to not "get" NNs to ask something like this. Here are the problems with it:

1. DF does not have any "score". To train an NN, you need to show it inputs and matched correct outputs, then it (supposedly) generalizes the output. What's your training set?

2. NNs, by their nature, function by trying many solutions over and over. How long does a non-trivial game of DF take? Yeah, that, times hundreds, maybe thousands (because the problem is so bad, maybe millions!).

3. Good luck when the NN inevitable gets stuck in the thousands of local minima that must certainly exist.

I just wanted to point out that you're confusing GA with NN.  The two techniques are often, but not always combined, in order to create a sort of learning system, but be assured that the two techniques are entirely different from each other.

GA needs a "score".  GA requires hundreds, if not thousands, if not millions of iterations.  GA usually, but not always requires stable scenarios.  GA frequently gets stuck in local maxima, but can be kicked out of it by running multiple GA at once and cross breeding them occasionally.

NN has none of those problems, but has its own set of problems.  For example, the need for a finite and preferably VERY LIMITED (like, a number you can count on your fingers) number of inputs / outputs.  So you couldn't really hook the NN directly into DF, which has an insane number of potential inputs-- you could say "each tile", but you'd also need inputs for each possible item/creature in a tile.  But forget that, you can't really do it.

So what you need is a rule based system that handles what are often called "tactics"... analyzing big-picture stuff, like your overall economy (the "wealth", "food", and "booze" numeric displays could be good inputs, for instance), number of invaders on the map (not their position, probably not even their type, although you could split off titans and demons I suppose) number of living/dead dwarves, that sort of thing, and then use the NN to output a STRATEGY.  Not tactics, but overall goals.  For instance, if your booze is low, and there are a moderate number of goblins on the map, a NN could be used to decide whether to focus on getting stills up now or to get weaponsmiths going.

The NN wouldn't say where to put anything, it wouldn't say how to do it, it would just suggest "Hey, maybe we aught to prioritize booze right now", or "Maybe we could stand to draft a few fellows."  Then, a rule based system would work out how to actually IMPLEMENT the strategy proposed by the NN.

Of course, an NN could certainly do this, but what some other posters are pointing out, is that NNs are hardly NECESSARY to do this.  You could have a much more simple IF/THEN chain that analyzes the same numbers and comes up with the same goals.  The thing about NNs though, is that they're really good at "fuzzy" situations-- such as my example of being low on booze AND goblins are invading.  Which do you focus on?  What if your booze is at 5, you have 50 dwarves, but there's a demon rush flooding your fort?  What if it's a hundred goblins instead of demons?  How do you weight in your existing military?

Basically, the NN combines multiple inputs and melts them together in such a way that, if you train it right, it'll make "smart" decisions.  You COULD do it with an IF/THEN chain (or a switch, or whatever) but the more factors to consider, the fuzzier the lines between good and bad decisions in somewhat different scenarios, the more an NN starts looking a lot simpler to implement than an IF/THEN chain.

And yet the IF/THEN chain is simpler to read and understand for human beings.  And that's the temptation and draw for it, because you could look at your numbers and understand exactly what it means in terms of strategy weighting.  Neurons are a little trickier to comprehend.  But if you know what you're doing with them, I think this may actually be EXACTLY the right place to use it.


But don't focus all your attention on the NN.  You DO need a good system for implementing the overall strategy as well.  You need something to tell the game where to dig rooms and where to put the still and so on and so forth.  The best implementation of this... or at least the quickest... might be to simply apply some cookie cutter designs.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: sudgy on October 23, 2012, 12:44:46 pm
In an economic sense, it will track the value of

Um...  What happened?
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Askot Bokbondeler on October 23, 2012, 01:44:15 pm
the ai... pulled a lever
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: muzzz on October 23, 2012, 02:05:56 pm
Basically, the NN combines multiple inputs and melts them together in such a way that, if you train it right, it'll make "smart" decisions.  You COULD do it with an IF/THEN chain (or a switch, or whatever) but the more factors to consider, the fuzzier the lines between good and bad decisions in somewhat different scenarios, the more an NN starts looking a lot simpler to implement than an IF/THEN chain.

That's going to be the real problem. There's a funny story I've heard a few times about a neural network that was successfully trained to distinguish between stock and in-the-field photos of military aircraft. Unfortunately, it was supposed to be an IFF.

Morale of the story: if you use artificial training sets instead of simulation, you risk training your NN to recognize unintended patterns.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on October 23, 2012, 03:48:30 pm
In an economic sense, it will track the value of

Um...  What happened?

Copious amounts of mary jaunita
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Orange Wizard on October 24, 2012, 01:08:42 am
If you guys could make an AI to play DF, I really wanna see an AI to play Minecraft.
Herobrine.
But, sadly, he was removed in... wait, how many releases "removed Herobrine"?
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: sudgy on October 24, 2012, 11:00:03 am
If you guys could make an AI to play DF, I really wanna see an AI to play Minecraft.
Herobrine.
But, sadly, he was removed in... wait, how many releases "removed Herobrine"?
He was removed in 1.6.6, 1.7, 1.7_01, 1.8, 1.0, 1.2, (maybe 1.2.5) and 1.3.1.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Valikdu on October 24, 2012, 12:29:32 pm
An AI that would be able to play DF.
...
I think that's a bad idea, if only because you'll be terminated by Cameron.

(http://images1.wikia.nocookie.net/__cb20091013183034/terminator/images/b/bb/Cameron3.jpg)
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Telgin on October 24, 2012, 12:38:26 pm
Posting to watch, since this looks pretty interesting.  At first I assumed it was a graduate school research project, but I guess there isn't a lot of scientific merit to it so much as having fun.  :)

In any case, I'd also like to blindly echo the others in that a neural network may not be too useful to your application.  Even if you're just using it as a scoring mechanism, it would probably be pretty tricky to get much use out of training it.  If I was coding it I would probably just implement all of the modules as highly domain specific rule-based systems (which sounds like what you're planning), and I would then likely just manually tune any parameters to the algorithms.  Good luck applying it to other games in the general case though.

AI is one of my weakest subjects however, so I'll let Fieari continue on since he sounds very well versed in the subject.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: Joben on October 24, 2012, 10:43:10 pm
Difficulty notwithstanding.  A team of researchers did it for civilization III, it can be done.

Really? Why? Doesn't Civilization III already play Civilization III? Admittedly the AI cheats like a cheating cheater trying to win a medal for cheating, but it does play pretty much the same game you do. Doesn't it?
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: misko27 on October 24, 2012, 10:47:22 pm
Difficulty notwithstanding.  A team of researchers did it for civilization III, it can be done.

Really? Why? Doesn't Civilization III already play Civilization III? Admittedly the AI cheats like a cheating cheater trying to win a medal for cheating, but it does play pretty much the same game you do. Doesn't it?
As they point out on TvTropess, its a different game. They make up for artificial stupidity (http://tvtropes.org/pmwiki/pmwiki.php/Main/ArtificialStupidity) with the computer is a cheating bastard (http://tvtropes.org/pmwiki/pmwiki.php/Main/TheComputerIsACheatingBastard).

EDIT: Just looked down, appearantly Civilization has a entire section devoted to them. Well then.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Jelle on October 26, 2012, 06:22:34 am
Yeah CiV, or atleast the last two I remember well enough, is pretty big on the whole cheating bastard AI trope to compensate for its aritificial stupidity. That wqas probably my main gripe with the last installment, the AI was simply to stupid making it seem the computer opponent was playing a completely different game then you are by bending more game rules then it does not.

Slightly more on topic, I'm sure making an AI for a game like civilization is a lot more straightforward then in a game like DF, civ has a lot of decision making where you decide from a select amount of choices. It should be no problem for it to analyze every single possability in such a choice except maybe for example on where to place units on a map (wich the AI absolutely failed at in the latest civ) since the possabilities are far more numerous and require a more selective decision making process.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: blue sam3 on October 26, 2012, 07:06:42 am
Basically, the NN combines multiple inputs and melts them together in such a way that, if you train it right, it'll make "smart" decisions.  You COULD do it with an IF/THEN chain (or a switch, or whatever) but the more factors to consider, the fuzzier the lines between good and bad decisions in somewhat different scenarios, the more an NN starts looking a lot simpler to implement than an IF/THEN chain.

That's going to be the real problem. There's a funny story I've heard a few times about a neural network that was successfully trained to distinguish between stock and in-the-field photos of military aircraft. Unfortunately, it was supposed to be an IFF.

Morale of the story: if you use artificial training sets instead of simulation, you risk training your NN to recognize unintended patterns.

There was another issue with somebody doing something similar: trying to train a neural network to identify tanks (as being tanks, not worrying about IFF, just "oh look, there's a tank in that bush", but since they'd taken all the tank photos on one (sunny) day and the non-tank photos on another (overcast) day, they ended up with a neural network capable of telling them what the weather was like outside.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Mr Space Cat on October 26, 2012, 07:31:40 am
Posting to Watch.

Spoiler (click to show/hide)
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: Fieari on October 26, 2012, 04:09:45 pm
Difficulty notwithstanding.  A team of researchers did it for civilization III, it can be done.

Google is failing me, and I am very interested in seeing this.  Any links?
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: ZimminyCricket on October 26, 2012, 05:03:33 pm
Difficulty notwithstanding.  A team of researchers did it for civilization III, it can be done.

Google is failing me, and I am very interested in seeing this.  Any links?

I'll have to do some digging myself, which will have to wait until I get home, as I am at work right now.
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: HiEv on October 26, 2012, 05:55:00 pm
Difficulty notwithstanding.  A team of researchers did it for civilization III, it can be done.

Google is failing me, and I am very interested in seeing this.  Any links?

I don't know about Civ III, but Muzzz linked to a paper about an AI which could play Civ II and win about 78% of the time in this post (http://www.bay12forums.com/smf/index.php?topic=117709.msg3718369#msg3718369) earlier in this thread.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Phlum on October 26, 2012, 08:37:27 pm
i had thought about suggesting this, but you beat me to it. I was thinking more like a gamemode for it though. feel like this would probobly be a time lapse, but it would be cool if you could actually watch the dorfs.

The most cpu stressing screen saver ever to be imagined, +1.

Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on October 26, 2012, 09:17:56 pm
i had thought about suggesting this, but you beat me to it. I was thinking more like a gamemode for it though. feel like this would probobly be a time lapse, but it would be cool if you could actually watch the dorfs.

The most cpu stressing screen saver ever to be imagined, +1.

We're hoping it will be real-time actually.  Our curses interpreter layer is going to be running in real time, to catch the screen.  Simply allowing it to re-display what it sees should not add that much overhead.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on October 26, 2012, 09:38:29 pm
Oh Great And Wise Toady-one,

Any chance you yourself will partake in this thread?

Love to get some feedback from the horses mouth!
Title: Re: A Neural Net To Play The Game. Has This Been Done?
Post by: GreatWyrmGold on October 27, 2012, 08:20:40 am
Difficulty notwithstanding.  A team of researchers did it for civilization III, it can be done.
Really? Why? Doesn't Civilization III already play Civilization III? Admittedly the AI cheats like a cheating cheater trying to win a medal for cheating, but it does play pretty much the same game you do. Doesn't it?
As they point out on TvTropess, its a different game. They make up for artificial stupidity (http://tvtropes.org/pmwiki/pmwiki.php/Main/ArtificialStupidity) with the computer is a cheating bastard (http://tvtropes.org/pmwiki/pmwiki.php/Main/TheComputerIsACheatingBastard).

EDIT: Just looked down, appearantly Civilization has a entire section devoted to them. Well then.
Civilization already comes with AI to play a game much like Civilization, which DF does not.

Oh Great And Wise Toady-one,

Any chance you yourself will partake in this thread?

Love to get some feedback from the horses mouth!
Toady's not omniscient, and probably doesn't have enough time to read all of these threads. Perhaps you should PM him about the thread.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: hops on October 28, 2012, 02:41:17 am
Honestly despite Toady's post count I never saw him anywhere except Future of the Fortress and those jazz.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Telgin on October 28, 2012, 03:58:44 pm
Back when the forums were new I think he posted a lot more frequently.  He mostly devotes time to moderating now that there is a large enough user base of veteran players that he doesn't have to answer questions directly.

I believe he does still read the forums off and on, but probably mostly when a thread gets reported.  He does respond to PMs, or at least did to mine when I asked him about some of the more hidden math behind some gameplay mechanics.  A PM might get some response, but I'm not sure how much input he'd have for this sort of thing.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: GreatWyrmGold on October 28, 2012, 04:03:04 pm
Possibly "Huh? What are they doing?!?"
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: katwithk on October 29, 2012, 07:57:30 am
A veyr interesting proposal, especially considerign just five minutes previous to clicking this link I was pondering on how I might be able to set my fortress up to run for nonspecific, nontrivial amounts of time with little or no oversight.

This would be an obvious solution, were success in this endeavor achieved.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Ruhn on October 30, 2012, 01:22:11 pm
A veyr interesting proposal, especially considerign just five minutes previous to clicking this link I was pondering on how I might be able to set my fortress up to run for nonspecific, nontrivial amounts of time with little or no oversight.

This would be an obvious solution, were success in this endeavor achieved.
I agree, being able to put a fortress on autopilot for a while would be nice when nothing exciting has happened lately.

For the discussion of training, I would like to cite the approached used by PS2 "Virtual Fighter 4" AI system.  In this game you could give feedback during the fight if your AI fighter was doing 'good' or 'bad' after every action.  It could be done during the fight, or afterwards during a replay.

If the VF4 appoach is applied to this DF project, we would be able to give feedback (using 'y' and 'n' ?) during gameplay to let the AI know if we are happy with the choices it is making.  These lessons could be stored and transmitted back to the developers for review and possible integration for the next release.  Or it could be kept local, so one player's decision to never build traps would not skew the overall desicion process on trap setup for everyone.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: GreatWyrmGold on October 30, 2012, 05:38:03 pm
Could we see a copy of the AI as it currently exists, or is it a bit worse than a toddler plopped down at the keyboard?
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: My Name is Immaterial on October 30, 2012, 07:56:41 pm
If you are going forward with the learning AI, do you need extra help teaching it? Because I'm volunteering.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: noobnubcakes on October 30, 2012, 11:32:06 pm
Let me try to name all the things that the AI would need to be able to do to survive:
 (Things that would be the most difficult have a *)

Spoiler (click to show/hide)
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: RenoFox on October 31, 2012, 02:11:07 pm
This would be great! And while a good AI would be hard, I'd be happy to just get something capable of making short-lived forts with some artifacts for adventurers to find. Learning AI must be difficult, but the ability to dig, build and equip would go far regardless of inefficient designs.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on November 01, 2012, 12:51:38 am
If you are going forward with the learning AI, do you need extra help teaching it? Because I'm volunteering.

When we Get that far, I will send you a message.  I haven't updated the main thread in a bit, since we're still interpreting the screen, but THANKS!  =)
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: hops on November 01, 2012, 02:32:02 am
Could we see a copy of the AI as it currently exists, or is it a bit worse than a toddler plopped down at the keyboard?
It's probably worse than a keyboard plopped on a toddler-shaped keyboard
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: rex mortis on November 01, 2012, 04:51:27 am
You mentioned in the OP that you were looking for people who play on Linux to help teach your AI. As I play on Linux, my interest was piqued. What exactly would this involve? As I understand it, you are looking for recorded video of me playing DF? And I expect it would have to be DF without mods.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: sudgy on November 01, 2012, 12:22:19 pm
Are you going to be doing this for adventurer mode too?
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on November 01, 2012, 02:29:49 pm
Quote
If you are going forward with the learning AI, do you need extra help teaching it? Because I'm volunteering

Yes, We will need help teaching it, we're thinking of feeding it snippets of recorded games.  So if you're playing without a skin and would not mind hitting ';' every now and then to record some gameplay, that would be great!  When we're ready for that I will set up a public ftp/dropbox/something to upload them to so stay tuned.

Quote
You mentioned in the OP that you were looking for people who play on Linux to help teach your AI. As I play on Linux, my interest was piqued. What exactly would this involve? As I understand it, you are looking for recorded video of me playing DF? And I expect it would have to be DF without mods.

See above.

Quote
This would be great! And while a good AI would be hard, I'd be happy to just get something capable of making short-lived forts with some artifacts for adventurers to find. Learning AI must be difficult, but the ability to dig, build and equip would go far regardless of inefficient designs.

Agreed.

Quote
A veyr interesting proposal, especially considerign just five minutes previous to clicking this link I was pondering on how I might be able to set my fortress up to run for nonspecific, nontrivial amounts of time with little or no oversight.

This would be an obvious solution, were success in this endeavor achieved.

Pretty much the same reason I decided to start this project.  It just...made sense.

Quote
Could we see a copy of the AI as it currently exists, or is it a bit worse than a toddler plopped down at the keyboard?

Somebody else beat me to this answer, but yes, it is still a bit worse than a toddler pooping on the keyboard at the moment.  We haven't gotten to any 'intelligent' point just yet, but we're working on it. 

When we get to a point where we have something working, we'll see.  =)

Quote
I agree, being able to put a fortress on autopilot for a while would be nice when nothing exciting has happened lately.

For the discussion of training, I would like to cite the approached used by PS2 "Virtual Fighter 4" AI system.  In this game you could give feedback during the fight if your AI fighter was doing 'good' or 'bad' after every action.  It could be done during the fight, or afterwards during a replay.

If the VF4 appoach is applied to this DF project, we would be able to give feedback (using 'y' and 'n' ?) during gameplay to let the AI know if we are happy with the choices it is making.  These lessons could be stored and transmitted back to the developers for review and possible integration for the next release.  Or it could be kept local, so one player's decision to never build traps would not skew the overall desicion process on trap setup for everyone.

A very good Idea.  I'm glad I thought of it.  =P (I kid, I kid.)  Thanks for the input.

Quote
Let me try to name all the things that the AI would need to be able to do to survive:
 (Things that would be the most difficult have a *)

Spoiler (click to show/hide)

Agreed with most of the points there.  Although we're not yet at that phase in development, when we hit it, we're expecting to REALLY hit it.

Quote
Are you going to be doing this for adventurer mode too?

Perhaps.  The idea is to be able to port this AI to ANY Curses based roguelike game when we're done. =)

Quote
If you guys could make an AI to play DF, I really wanna see an AI to play Minecraft.

One step at a time there buddy!!!  =)
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: gamewizard on November 01, 2012, 05:40:17 pm
when you complete the AI player i suggest you run it on sdf.org they are a free public super computer center just thought i would out that out there you know i would say that you could use there setup to enable a very complex AI system much more complex than anything  any desktop could do
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on November 02, 2012, 09:11:42 pm
crap...page 2.

Update Bump!
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: sudgy on November 02, 2012, 10:24:33 pm
Oops, accidently voted no.  I changed my vote, but in case you get some notification from someone voting (I don't know if you do) I didn't want to confuse you (that's happened on facebook with me).
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on November 09, 2012, 03:08:02 pm
Update bump
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: My Name is Immaterial on November 09, 2012, 08:48:04 pm
Good work, keep going!
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Demki on November 10, 2012, 04:21:35 am
Looks good, and if it works, we should get it to do collab games with experienced players, might teach it important stuff about minecarts/pumps/magma/military/Fun.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: noobnubcakes on November 10, 2012, 07:44:13 pm
Looks good, and if it works, we should get it to do collab games with experienced players, might teach it important stuff about minecarts/pumps/magma/military/Fun.
Trying to teach a AI what !!FUN!! is is like teaching a 5 year old gun safety with a Fat Man launcher.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: AutomataKittay on November 10, 2012, 07:50:27 pm
Looks good, and if it works, we should get it to do collab games with experienced players, might teach it important stuff about minecarts/pumps/magma/military/Fun.
Trying to teach a AI what !!FUN!! is is like teaching a 5 year old gun safety with a Fat Man launcher.
:D
If it learns to go Boatmurdered, it's doing it's job right.

And probably immortal in term of DF time.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on November 10, 2012, 07:56:54 pm
Hey guys,

Just checking in to say, that I'm digging the response this thread is starting to get. 

I try to update ya'll at least once a week, but please forgive me if I slip. 

We skipped thursday night because of the weather, so sorry for not updating.  Have more news tomorrow night.

We've still got to interpret what we're actually seeing, but compared to writing the protocol to de-render curse, that shouldn't be too hard as we're going to feed it into a database, and then if I have my way just compare what character it's seeing to a table that's floating around on the wiki...somewhere.

Its starting to get interesting!

Catch ya'll later!
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: hops on November 10, 2012, 11:54:35 pm
Seeing that AIs have infinite patience, I feel that whatever it's going to make will be both terrifying and glorious.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Orange Wizard on November 11, 2012, 06:12:40 am
How is the data from the Curses interpreter going to be... uh... interpreted by the AI? It seems hideously complicated.

<<Edited to remove some ambiguity>>
Assuming the AI 'understands' the Interpreter, will it be capable of registering multi-tile features, such as a cistern, or furnace room, or parts of the surface as 'unsafe due to goblins'? If so, how will this be done?
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on November 11, 2012, 11:08:56 am
How is the data from the Curses interpreter going to be... uh... interpreted by the AI? It seems hideously complicated.

<<Edited to remove some ambiguity>>
Assuming the AI 'understands' the Interpreter, will it be capable of registering multi-tile features, such as a cistern, or furnace room, or parts of the surface as 'unsafe due to goblins'? If so, how will this be done?

The data from the curses interpreter is going to dumped into a database.  The database is going to be broken down for each tile in each z-layer, and only the 'table' for the current z-layer is going to be kept live while the others are crunched in the background.
Spoiler (click to show/hide)

As far as your multi-tile feature question, I feel it is still a bit ambiguous and I'm not quite sure as to what you're asking. 

With the surface being unsafe due to gobbos, the AI will know (through registering a 'Event, or Mega-event) that it is under attack, and will learn how to handle such an event from there. 



Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: AutomataKittay on November 11, 2012, 11:22:04 am
How is the data from the Curses interpreter going to be... uh... interpreted by the AI? It seems hideously complicated.

<<Edited to remove some ambiguity>>
Assuming the AI 'understands' the Interpreter, will it be capable of registering multi-tile features, such as a cistern, or furnace room, or parts of the surface as 'unsafe due to goblins'? If so, how will this be done?

The data from the curses interpreter is going to dumped into a database.  The database is going to be broken down for each tile in each z-layer, and only the 'table' for the current z-layer is going to be kept live while the others are crunched in the background.
Spoiler (click to show/hide)

As far as your multi-tile feature question, I feel it is still a bit ambiguous and I'm not quite sure as to what you're asking. 

With the surface being unsafe due to gobbos, the AI will know (through registering a 'Event, or Mega-event) that it is under attack, and will learn how to handle such an event from there.

I believe that the question is can AI recognize functional part that's not a workshop by itself and it's own design or a collection of workshop working together ( Such as 'water holding space', 'where ore and scrap metal things go to be melted', etc. Or even just a power generating station full of watermills. ).
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on November 11, 2012, 12:29:12 pm
Ah, we've yet to bridge that river, quite honestly we're taking this thing in small steps, planning each step upon the completion of the one prior.  Maybe not the best way to tackle the problem, but with a problem so large........
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: HiEv on November 11, 2012, 12:32:55 pm
We've still got to interpret what we're actually seeing, but compared to writing the protocol to de-render curse, that shouldn't be too hard as we're going to feed it into a database, and then if I have my way just compare what character it's seeing to a table that's floating around on the wiki...somewhere.

It's at the wiki here: Tilesets (http://dwarffortresswiki.org/index.php/Tilesets)

However, I should note that many, if not most, characters mean multiple things.

You're still going about things the hard way, IMO.  It would make more sense to use DFHack to interpret the screen, get various info, send commands, etc., instead of reading the screen and having the program to try to interpret that and sending key commands.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: ZimminyCricket on November 11, 2012, 12:48:17 pm
We've still got to interpret what we're actually seeing, but compared to writing the protocol to de-render curse, that shouldn't be too hard as we're going to feed it into a database, and then if I have my way just compare what character it's seeing to a table that's floating around on the wiki...somewhere.

It's at the wiki here: Tilesets (http://dwarffortresswiki.org/index.php/Tilesets)

However, I should note that many, if not most, characters mean multiple things.

You're still going about things the hard way, IMO.  It would make more sense to use DFHack to interpret the screen, get various info, send commands, etc., instead of reading the screen and having the program to try to interpret that and sending key commands.

Again, we're trying to write an AI that can be moved from Roguelike to Roguelike, so we're dealing with RAW ASCII art, It just so happens that we picked the MOST DIFFICULT ROGUELIKE EVER to get started with. 
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: AutomataKittay on November 11, 2012, 12:49:22 pm
We've still got to interpret what we're actually seeing, but compared to writing the protocol to de-render curse, that shouldn't be too hard as we're going to feed it into a database, and then if I have my way just compare what character it's seeing to a table that's floating around on the wiki...somewhere.

It's at the wiki here: Tilesets (http://dwarffortresswiki.org/index.php/Tilesets)

However, I should note that many, if not most, characters mean multiple things.

You're still going about things the hard way, IMO.  It would make more sense to use DFHack to interpret the screen, get various info, send commands, etc., instead of reading the screen and having the program to try to interpret that and sending key commands.

Again, we're trying to write an AI that can be moved from Roguelike to Roguelike, so we're dealing with RAW ASCII art, It just so happens that we picked the MOST DIFFICULT ROGUELIKE EVER to get started with.

I'd argue Nethack's more difficult, and I've never gotten far in it :D

DF is more complicated, yes, but not really more difficult.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: HiEv on November 11, 2012, 01:11:00 pm
Again, we're trying to write an AI that can be moved from Roguelike to Roguelike, so we're dealing with RAW ASCII art, It just so happens that we picked the MOST DIFFICULT ROGUELIKE EVER to get started with.

No offense, but you're never going to make an AI that can learn to play multiple rougelikes.  To do that would require an AI on the level that experienced AI researchers only dream of.

To put it another way, if you're making a collection of expert systems then most (99%) of the things you need the AI to do in Dwarf Fortress would have no applicability in any other roguelike.  If you're not making a collection of expert systems, then you're going to need natural language processing, problem solving, pattern recognition, automatic object categorization and relational modeling, and a host of other AI techniques that would take a team of researchers with a huge budget years to make before it could begin to do what you're talking about.

You aren't just shooting for the moon, you're shooting for a moon that's one galaxy over.

I would highly recommend scaling back your goals to something reasonable.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: GreatWyrmGold on November 11, 2012, 04:17:15 pm
Try shooting for a star a galaxy over, they're bigger.

If you're making AI that versatile, congrats and roguelikes are a bit of a narrow field to put it in.


Mire likely, you're going farther than you can. Stick to one game.
Title: Re: An AI to play dwarf fortress. Has this been done? ==UPDATE!==
Post by: Fieari on November 12, 2012, 01:26:50 pm
So, you're trying to make a roguelike AI, not a DF AI?  Because DF is not a Roguelike except in adventure mode.