Has colonist AI improved lately?

Started by Holy-Fire, February 23, 2016, 07:14:06 PM

Previous topic - Next topic

Fluffy (l2032)

Ugh, that should teach me to make assumptions, I'd figured chess AI's would use neural networks, but then I guess those AI's pre-date the popularity of ANN's.

Sounds interesting, and I think I'd like to see that happen too :) I'm still not convinced an economic simulation isn't going to substantially increase the workload of pawn AI, but it'd certainly be a nice thing to have - if it's smart enough :P I'd rather have something dumb that I can understand, then something dumb and complex.

That does  imply that there needs to be a job listing though, a central job queue for pawns to check. Currently, that's not the case. When a pawn wants work, it actually scans possible jobgivers for the availability of jobs - which now that I come to think of it, actually seems like a horribly inefficient way to do things.


porcupine

Some of these issues could be fairly easily solved.

The AI has a concept of where it's main base is (after all, visitors concentrate there, raiders go there, etc.).

The AI clearly has a bailout mechanism that triggers when moods get too low/needs get too high (IE: I'm going home to sleep, screw this).

The AI bailout could be paired back relative to distance from the main base, the further away a pawn is from the main base, the sooner he's going to call it quits/think about heading back.

When the AI stops a job because his bailout conditions are right (IE: need to sleep), the further the pawn is from the main base, the pawn could be more likely to seek a hauling job as his next to-do, instead of walking immediately home.  Basically at that point, you'd probably need "soft" bailout, and "hard" bailout conditions (IE: to stop the pawn from repeatedly picking up small half-way hauling jobs on the way home and becoming broken), much like a battery has a soft shutdown on your laptop (go to sleep) at say 15% battery, then a hard shut down (hibernate/power off entirely) at like 5% battery.

isistoy

I like how porcupine puts it. It seems a manageable way of changing some things so the AI fill in the gaps for long distance hauling after a job.
Can't say if that would cope with the problem entirely, but it seems simple enough to be worth a try, maybe?
<Stay on the scene like a State machine>

Tynan

The problem is that you are now violating the player's instructions on which work to do in which priority order.

Once you do that - once you have the AI making judgment calls and sometimes doing lower-priority work ahead of higher-priority work - you've broken the basic principles of the AI design, which is that it is 100% predictable and mechanistic.

This AI was never meant to be optimal as a game colonist, or to simulate a real person. It's meant to drive little chesspiece automaton workers, so the player can do the interesting task of arranging them and their work settings to create whatever efficient arrangement he wants.

This is leaving aside the massive complexity and performance problems you invite when you start trying to chase highly contextual, judgment-driven, rules-breaking optimizations in behavior. Once you do one, you start to realize there are thousands of archetypical situations where the AI could be a bit smarter. And, that once you start trying to do that, the AI then does new dumb things, or violates the instructions of a player who tries to do something unusual, and so on. It's a world of hurt that we won't be journeying into. And even if we made net improvements, we'd just have to rebalance the game to make it harder to compensate, so ultimately there is very little upside.

Instead, the game is just balanced for the AI the way the AI is, while keeping the AI predictable so players can play the game instead of watching the AI play the game for them.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

porcupine

Quote from: Tynan on February 29, 2016, 10:27:56 AM
The problem is that you are now violating the player's instructions on which work to do in which priority order.

Once you do that - once you have the AI making judgment calls and sometimes doing lower-priority work ahead of higher-priority work - you've broken the basic principles of the AI design, which is that it is 100% predictable and mechanistic.

The AI already does this by bailing home after a single hit of the pick-axe to go sleep/eat/etc.

The tasks I'm suggesting run in parallel ("go home", and "haul stuff" are generally the same thing).

Mikhail Reign

Quote from: porcupine on February 29, 2016, 12:41:18 PM"go home", and "haul stuff" are generally the same thing.

Generally, but not always, which is what Ty is talking about.

An example would be a colonist mining away from base uncontrollably losing half a days work each day by bringing back a stone to a stockpile 'closeish' to the base. Currently the AI is dumb, but dumb in a predictable way - when I tell them to do something, they do it. I dont really need the AI over riding my decision - its bad enough when they strip off and run out into the snow and -100 weather.

Britnoth

Quote from: Shurp on February 24, 2016, 05:04:13 PM
In this case it's actually not that hard.  Just include a distance variable in the action priority.  So the pawn goes out to mine one tile, and finishes that.  Now he queues for the next task.  Halfway across the map there is some corn needing harvesting, next to him is 5 bits of steel, and next to him is some more steel to mine.

It'd be nice if he kept mining so he carries back more steel, but at the very least he should prioritize the steel next to him over the corn.

Maybe the problem is that it is using the wrong distance -- the distance to the stockpile instead of the distance to the object being picked up.

This mod already exists, but no one expressed any interest in developing it further so I have not touched it since.

porcupine

Quote from: Mikhail Reign on February 29, 2016, 09:34:35 PM
Quote from: porcupine on February 29, 2016, 12:41:18 PM"go home", and "haul stuff" are generally the same thing.

Generally, but not always, which is what Ty is talking about.

An example would be a colonist mining away from base uncontrollably losing half a days work each day by bringing back a stone to a stockpile 'closeish' to the base. Currently the AI is dumb, but dumb in a predictable way - when I tell them to do something, they do it. I dont really need the AI over riding my decision - its bad enough when they strip off and run out into the snow and -100 weather.

Sure, but what I'm talking about, is if the colonist is already at the point where he has done a soft break (IE: decided to return home), he's already loosing half a days work, cuz he's about to go home empty handed either way. 

You could also tie this to any resource he was gathering (IE: dead if hunting, logs if cutting, ores if mining, etc.), if that proved necessary


Mikhail Reign

Doesn't carrying stuff slow pawns? Thats how I'm looking at it. If they start doing things that I didn't explicit tell them to do, then they stop being predictable. What happens when a pawn is about to break so he decides to head home, but first picks up enough to slow him down. Now he is even more likely to break because its going to take him longer to meet his needs.

Also, isn't a soft break a binge or dazed etc, as opposed to a hard break being leaving the colony or becoming violent. Didn't think that stopping work to meet a need was considered a type of break

porcupine

Quote from: Mikhail Reign on March 01, 2016, 08:13:30 AM

Also, isn't a soft break a binge or dazed etc, as opposed to a hard break being leaving the colony or becoming violent. Didn't think that stopping work to meet a need was considered a type of break

I'm using the word "break" liberally, you could call it "soft stop" if that was easier to follow, it doesn't really matter what you call it.

My suggestion noted scaling back the "soft stop" relative to the distance away from the main colony, to stop work earlier, which would also account for the slower walking speed/etc. (to ensure there was not a mental break), per my original post :).

I wouldn't exactly call this advanced AI, it's just AI following common sense, which is what you expect to see in games generally speaking.

Fluffy (l2032)

The problem, like I tried to explain, and what I think Tynan's post also boils down to, is that common sense is very hard to implement - and potentially unwanted.

1) It's situational, in different situations, different actions make sense.
2) It's personal, for different people, different actions make sense.
3) It can break the rules, which may not make sense to someone expecting his orders to be followed to the letter - like for example a computer, or some players.

Common sense is one of those things, very much like intuition, that are 'easy' for humans, as we've had several tens of thousands years of evolving, but incredibly hard for an AI.

porcupine

Quote from: Fluffy (l2032) on March 01, 2016, 04:37:39 PM
The problem, like I tried to explain, and what I think Tynan's post also boils down to, is that common sense is very hard to implement - and potentially unwanted.

As stated, the existing behavior already breaks the rules.  I've made my suggestion, it addresses these within the same level of reasonableness that the existing AI demonstrates, if Tynan doesn't want to implement for whatever reason, that's entirely his prerogative.  Saying that it shouldn't happen, because colonists are  pawns and should only do what they're told however is a moot argument, they already do something exactly along this line of behavior.

Why?  They didn't used to in previous alphas, your guys would often work until they broke/finished the task.  This changed, their orders were over-ridden by their needs, because people stopped and said "gee, well that's a huge pain in the arse, we really need to address that!"

LeoTessa

Quote from: porcupine on March 01, 2016, 06:25:27 PM
Quote from: Fluffy (l2032) on March 01, 2016, 04:37:39 PM
The problem, like I tried to explain, and what I think Tynan's post also boils down to, is that common sense is very hard to implement - and potentially unwanted.

As stated, the existing behavior already breaks the rules.  I've made my suggestion, it addresses these within the same level of reasonableness that the existing AI demonstrates, if Tynan doesn't want to implement for whatever reason, that's entirely his prerogative.  Saying that it shouldn't happen, because colonists are  pawns and should only do what they're told however is a moot argument, they already do something exactly along this line of behavior.

Why?  They didn't used to in previous alphas, your guys would often work until they broke/finished the task.  This changed, their orders were over-ridden by their needs, because people stopped and said "gee, well that's a huge pain in the arse, we really need to address that!"

it hardly breaks the rules, heck, is playing cleanly by them. He just programmed that the colonists adresss their basic needs after some point of stress. If common sense were to be actually programmed. Tynan would be creating our robot master race

LeoTessa

Quote from: Fluffy (l2032) on February 24, 2016, 04:22:20 PM
Yeah, with the main difference being that a chess AI has one move to consider, so it can afford to evaluate the many thousands of possibilities of even thinking a few steps ahead. Even then, there's usually extensive training of neural networks to train the AI how to behave, within the very limited rules of chess.

Consider a game like Go. Google has recently made headlines (http://www.nature.com/news/google-ai-algorithm-masters-ancient-game-of-go-1.19234) by creating an AI that could beat the European champion (who by eastern standards is still an amateur), and is now going to take on the world grand master. There's more options in that game than there are atoms in the universe, because the board is just big.

Still, Go 'only' has a 19x19 grid. Sure, there's loads of intricacies involved, and RimWorld is probably not quite such a hard problem to train an AI for (note; read below for more thoughts on that). But consider there's dozens of pawns whose AI needs to update in real-time, as opposed to a single move being made every few seconds/minutes, and you'll start seeing the reasons why game AI's are generally more 'railroaded' (not to mention that Ludeon isn't exactly Google). As for weighing the situation, thats sortof there, in that pawns do consider priorities and distances when selecting jobs.

Thats not to say there's no improvements to be made, there's plenty of situations where a hardcoded 'if you're going to walk more than x distance, go see if you can carry something' or similar 'hacks' would be a huge help. It's just that for an AI to behave truly smart is an incredibly complex task - both in the coding required, and the calculations involved.

Extra thoughts;
I'm not at all sure simulation games are learnable by a neural network. You'd first have to make the AI understand how to interpret the game world, and then train it in what works and what doesn't. What's the outcome variable? Survival? Efficiency? How do you measure that? This has been done for old school arcade games (which have a very limited ruleset, and generally provide immediate feedback - e.g. you make a mistake, you die immediately. In RW, you make a mistake, you might die a year later. Thats very difficult for an AI to understand ).

I'm not sure it can be done for a simulation game - even if you had Google's nerds and cash to back you up. Perhaps when we have quantum computers.

Even more extra thoughts;
Your suggestion of economic value does have merit, and could probably work as one of the 'hacks' I mentioned. Still, actually considering the economic values of even a limited number of possible actions in real-time for dozens of colonists (and raiders + animals) is a fairly massive extra CPU burden if not railroaded to a considerable degree. Even more so if you're going to take into account opportunity costs - the 'loss' you're making by not doing another possibly more valuable task.

to clear a few errors up, go may only have one move per turn, but that didnt keep programmers from inferring 10+ moves ahead because computers are just that fast. The problem with that? You could trick the computer into optimal moves that then them their game.

Heck, the famous chess AI we have these days rely on a few pre saved games that where then used as saved data for the CPU, with that part done, the game was made to play thousands of matches by itself, acquiring more knowledge with every game and then calculating even better optimal moves

Limdood

If you don't want pawns to quit working to sleep, then use the activity restrictions.

My pawns are always set to a mandatory 2 hour "joy" time of day, and a 12 hour mandatory "work" time, with 10 hours of "anything" to get their sleep in (i don't like setting rest times for anything but night owls, they'll sleep when they need during anything time).

A pawn won't cancel his work during "work" time except under extreme collapse-level exhaustion.