Has colonist AI improved lately?

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

Previous topic - Next topic

Holy-Fire

I haven't played Rimworld in over a year. (Since about Alpha 7: Things made of stuff). I'm wondering if I should get back to it.

Despite all the great things about the game, the one thing that always bothered me is that colonists are too stupid.

The prime example: I have a remote mining location. One of the colonists walks all the way over there to mine. By the time he gets there, he suddenly realizes he has someplace else to be (sleep, eat, whatever). So he returns to base empty-handed! I mean, come on, you've come this far, at least mine a haul and carry it back before you leave... Otherwise it's just a waste of a trip.

There are similar situations when there are items, say potatoes, in my farming zone, which need to be carried to the main storage, and from there to be used in food preparation. A colonist wants to prepare food, so he goes to the farming zone, and picks up just the 2 potatoes he needs - instead of using this opportunity to carry an entire haul.

The whole thing makes me feel the colonists are working against me instead of with me. It's frustrating.

Has there been any significant improvements in this regard in the versions since?

Thane

Not really. Colonist cooks will still do that. Though you can use zones and priorities to sort of make it work. Not a perfect solution, but serviceable.
It is regular practice to install peg legs and dentures on anyone you don't like around here. Think about that.

lbee

If that bored you, I think you should wait for later release because they still stupid like that in Alpha 12d.

Coenmcj

There was some work done on it. For instance, Haulers will bring more than just the single piece of metal back from a long haul for a multi-building construction.
Moderator on discord.gg/rimworld come join us! We don't bite

Mikhail Reign

Quote from: Coenmcj on February 23, 2016, 11:33:18 PM
There was some work done on it. For instance, Haulers will bring more than just the single piece of metal back from a long haul for a multi-building construction.

*sometimes.

Colonists will still grab only 17 metal to build a 40 block long piece of wire, even tho they could grab all 40 and place it in once trip. The range of 'is there any jobs near my job that requires the same resources' could defiantly be increases.

Also people still walk in front of guns.

Holy-Fire

#5
Well then... Is this officially recognized as a problem? Are there any plans to improve it in the future? Because honestly, I think that would improve the game much more than pet animals or whatever the latest craze is.

Thane

Yeah... Logical pawns are really high up on my list....
It is regular practice to install peg legs and dentures on anyone you don't like around here. Think about that.

Fluffy (l2032)

Tynan did implement the occasional AI teaks, but having pawns to a step from different jobs in an intelligent manner would be a massive, massive amount of code and testing to get right. This stuff is logical to us, but a computer needs precise instructions - and precise instructions are hard to write when there's many, many possibilities. Hence the modular nature of jobs, and what we would say are AI failures (e.g. ignoring nearby hauling jobs).

The gun thing should really be fixed though, I'm actually thinking of sending out hunters with a sword and some modded power armor or something.

Listen1

Raider's AI changed quite a bit too.

But their prime enemy are still the doors. The real thing, not the band.

humblebundle

Quote from: Listen1 on February 24, 2016, 02:18:08 PM
Raider's AI changed quite a bit too.

But their prime enemy are still the doors. The real thing, not the band.
I enjoy running with one colonist they are attacking around a rock, while all my other colonists shoot them :P
english is not my main language, that should explain a lot...

Holy-Fire

Quote from: Fluffy (l2032) on February 24, 2016, 01:53:36 PM
Tynan did implement the occasional AI teaks, but having pawns to a step from different jobs in an intelligent manner would be a massive, massive amount of code and testing to get right. This stuff is logical to us, but a computer needs precise instructions - and precise instructions are hard to write when there's many, many possibilities. Hence the modular nature of jobs, and what we would say are AI failures (e.g. ignoring nearby hauling jobs).
I'm not saying it's going to be easy, but you're overestimating the difficulty. You don't need to code precise instructions for every situation - you need to code precise instructions for how to evaluate any situation that presents itself. Just like chess engines don't have instructions for what to do in every position, but rather for how to search the game tree in any position.

The general direction should be making the AI more economy-oriented. It should figure out the value of different things (with help from the player where needed), and maximize the value of its actions. For example, it should realize that potatoes in storage are more valuable than potatoes in the farm, so if it has a colonist in the farm, it should realize that picking up a few more potatoes will allow it to gain value without costing a lot of time, and should be done.

Fluffy (l2032)

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

Shurp

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.
If you give an annoying colonist a parka before banishing him to the ice sheet you'll only get a -3 penalty instead of -5.

And don't forget that the pirates chasing a refugee are often better recruits than the refugee is.

Fluffy (l2032)

If he goes harvesting, that's because the player set harvesting to have a higher priority. This is actually not just a tool to give you some control over what pawns do, it also limits the amount of jobs that the pawns needs to consider in order to decide what to do. If a pawn would need to consider all jobs it could possibly do (which it would need to to really make the decision you're describing), you're adding dozens if not hundreds of options to the list. Not to mention that it would completely break the priority system, and really piss me off when I actually want a pawn to do something at the other end of the map and prioritize it.

Again though, this is one of those situations where a 'if you're going to walk a long way, go see if you can haul something' could be a viable hack to at least make it feel like the AI is smarter. But even that isn't simple - you have to queue the 'main' job, and do you actually lock the resources for the main job? If you don't, they might get moved or otherwise invalidated, which messes with your job logic. If you do, the resources might be locked for quite a long time.

Holy-Fire

Quote from: Fluffy (l2032) on February 24, 2016, 04:22:20 PM
Even then, there's usually extensive training of neural networks to train the AI how to behave, within the very limited rules of chess.
ANN is actually not something that is usually used in current chess engines. Some people tried and it didn't give good results.

Quote from: Fluffy (l2032) on February 24, 2016, 04:22:20 PM
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.
It doesn't need to be "truly smart". It just needs to be less stupid.

Don't forget that there's still a human player deciding strategy and directing the AI. The AI just needs to fill in the blanks in a semi-reasonable way.

While Chess and Go are objectively much simpler than Rimworld etc., what makes them difficult is that they are highly tactical - tiny variations can affect the game tremendously, so it's difficult to reason about the situation in any way other than considering all possible lines. Despite the many possibilities in Rimworld, it's easier to figure out which ones make any sense.

Quote from: Fluffy (l2032) on February 24, 2016, 04:22:20 PM
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 ).
The thing that was demonstrated for arcade games is a one-size-fits-all algorithm where you just throw a game at it and it figures out everything on its own. That's impressive but hardly the only way to approach game AI - you can use domain knowledge to write algorithms for some parts, while using machine learning to optimize others. AlphaGo, uses a combination of ANN training, Monte Carlo simulations, and game-tree search algorithms refined by decades of chess engine research.

Quote from: Fluffy (l2032) on February 24, 2016, 04:22:20 PM
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.
Shouldn't be that hard. Economic values are updated incrementally based on supply and demand. Possible tasks can be grouped by location, so that when a colonist considers a task in a location, he can consider all other tasks he can do while he's at it. Value of each combination is calculated easily. With only hundreds of possible tasks, choosing one should take milliseconds, and only needs to happen once per minute or so.

And again - of course actually doing all of that is a significant amount of work. But all the stuff Tynan adds every alpha is probably much more work, and I couldn't care less about it. If he were to release "Alpha 13: Colonists which aren't stupid" I'd be much more interested...