Today I want to tell the story of what happened to the AI that I programmed for a game. As a developer of AI code in games, you typically write the behaviour and decisions of character in the world that are not directly under the player's control. We call them Non Player Characters, or NPCs.
These characters should conduct their business in the game world so that it mimics intelligence. They need to plan their actions to achieve goals in this world.
Sometimes though, your AI creations can outsmart the programmer. They can decide to do things that the programmer did not plan for, or expect. This is called emergent behaviour. They end up doing stuff that was not explicitly specified by the programmer. They figured out something new, unforeseen the the developer.
This is a story of such emergent behaviour.
So I had prototyped a test world where the AI could perform a set of actions. And the AI knows when/where those actions are applicable, and what its effects would be. In this test world there was a notion of travelling, like going to a shop, or the woods. Actions like cutting trees was available, as was buying, selling, and other basic actions.
Now, to test my code, I had set up the world where I expected my AI to obtain lumber (Goal for the plan was to have lumber.) When I executed my code, I was expecting my AI code (the planner) to come up with the following plan:
- Go to shop
- Buy axe
- Go to forest
- Chop tree
- Drop axe
- Pick up lumber
So I run the code, and the AI comes back with a plan to obtain lumber. And the plan started with:
- Go to forest
- ..
Oh no! I have a bug in my code. Why did my AI decide to directly going to the forest, without first getting an axe? But when I examined the rest of the AI's plan, I was overjoyed. Almost like a proud parent, seeing its virtual child do something smart!
- Go to forest
- Pick up firewood
- Go to store
- Sell firewood
- Buy axe
- Go to forest
- Chop tree
- Drop axe
- Pick up timber
Oooh Yeah!!! How amazing.
So in my test world, I had not given my NPC any money. And it is smart enough to know that without money, you can't buy an axe! But because I had added the concept of selling in the game world too, and picking up random stuff, the AI had out smarted me. It decided it should get something to sell in the shop first. That's why it went directly to the forest.
Being outsmarted by your own AI code is a great feeling! I hope it will happen some more in the future.
Bram
ᴘᴏsᴛsᴄʀɪᴘᴛᴀ
- The action planner I used when writing this code, I have open sourced as General Purpose Goal Oriented Action Planning.
- I made a free game that uses GPGOAP called Children of Orc.
Now to wait for the AI to pick up firewood, go to store, sell firewood, and buy lumber.
Solid storytelling for a fun moment, and much better than how such bugs would usually turn out - the bug of forgetting to give the AI money, where it'd just randomly stop.
Nothing like failing forward moments in design :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Quite so! It would indeed buy the lumber if I had set up the test world with lumber available at the 'shop' location.
And I learned a new term: failing forward :-)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I love stories like this! I also love hexagons :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I have yet to get to programming actual AI in a game, most of my AI code is in the way of extremely predictable, like goombas.
Would love to read something technical about your GPGOAP. Overview of how it was designed and such.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hi poet,
GPGOAP is an implementation of GOAP by Jeff Orkin. This in turn, is based on MIT's STRIPS planner.
The README.md on my GPGOAP page walks through the mechanisms of how the planner works.
My implementation has the property of being completely decoupled from the game's code. There are no enums, types, objects required from the game in the GPGOAP code as it is all based on symbols that the game feeds it.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
wow. that is such an exciting moment! I love it! Im currently on the lookout for developers to talk to about an idea I have. It is for an evolution based tamagochi style game that could potentially be classed more as an experiment than a game, but has plenty of room for discussion. I imagine its main development feature would be packets of information that can in turn create new packets of information, and that the complexity would be indexing the relationships between the information. I am not a developer so I am not eloquent in this field and I realise that this sort of thing is a lot of work so I am looking for developers who are excited about the concept of artificial evolution and would be interested in a passion project. Obviously in the crypto world there is plenty of potential to monetize but those considerations may have to be secondary to the thrill of the experiment! If this is not something you're interested in, no worries, but Iove what you're doing, and I checked out the little crane too :) supercool. this idea would probably just be a 2d experiment, but your experience with AI would be SO amazing. would love to chat :) x basil
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit