Game NPC AI ideas

Game development specific discussions.
Posts: 1791
Joined: Feb 28, 2009 20:58

Re: Game NPC AI ideas

Postby leopardpm » Jan 02, 2019 0:31

oh my.... it won't even run on my system (I think my desktop is way too large), when I change the lines in the World constructor to this:

Code: Select all

    dim as integer  dskW = 1024, dskH = 800
    'screencontrol   fb. GET_DESKTOP_SIZE , dskW, dskH
    screenRes .7*dskW, .6*dskH, 32, 2, , 0
then at least 'something shows up - a window with a red rectangle around the edge and text that says "This is the World"....
don't know what you are trying to show me, but most of that code is beyond what I know.... I guess I am a basic Basic guy...

in any case, I do think you are still misunderstanding, but its OK, I think you will understand more once I get a simple simulation going

Have you ever played a city-builder? Kinda like an RTS game, but you only indirectly control the Agents. Existing game examples would be:

(1) Towns (free demo here:

(2) Dwarf Fortress (description here: - I don't recommend playing Dwarf Fortress as the learning curve is intense and it is all ascii (there are mods to give it a graphical sheen though....)

Basically in these games there are a multitude of Agents running around, and they construct and do things as you command indirectly - you don't control each agent, rather you assign general tasks to be done (build something over here, dig a tunnel there, make a carpentry station here, patrol this area, etc...) and the agents figure out who will do a task (or multiple agents) and proceed to do them. The agents also have individual stats and variables that determine how sleepy they are (if tired, then they will stop working and go to their bed/house, etc), how hungry they are (if hungry they will go get some food), how hurt they are (if injured, they will seek medical attention, etc). They are basically micro-human(dwarf) simulations and the 'player' acts like the King or Overlord issuing commands.

The AI used is about 80% of what I am envisioning-I propose going one step further: remove the player from the overlord position, and replace him with an AI for each agent which determines their desires - Do they want to build a house? Do they want to build a better house? Do they want to be a Farmer? or a Carpenter? or a Blacksmith? These questions will be ones they themselves will answer, according to a Maslow's based AI. In addition, their local environment and economy will influence these decisions - and THEY will influence the local economy. Say all the Agents decide they want to be carpenters... well, most of them will not succeed(and starve!) because the goods made will be worthless to other carpenters... so some will then choose to be Farmers or something else. This cycle continues until a general market level of distribution is reached (say a population of 100 agents might end up with :15 carpenters, 5 blacksmiths, 30 farmers, 10 fishermen, 5 hunters, 15 lumberjacks, 10 Bakers, 5 Bar Owners, 2 Beer makers, 3 Beggars. This distribution, and the prices of every Good involved, is not set by the programmer, but rather by the environment and the 'personalities' and traits of the Agents themselves. AND, it is fully dynamic, meaning that the 'society' changes to adapt to new circumstances - a volcano explodes nearby, destroying all the local forests...poof... now the lumberjacks gotta figure out what else to do to put food on their plate, same to with the related professions (carpentry, etc). So, the player is removed from the game and it is just a pure simulation - what fun is that? Now, reinsert the player as an individual, just like another Agent and interacting with all the other Agents, figuring out how to survive and thrive in the economy/world. Basically an RPG in a dynamic world setting.

ALL of this depends upon having the agents interact economically (through trade and market prices). Determining prices in a truly free setting like this has been a bit of a conundrum, until I found this paper: A simple system for individual agents to determine market prices in a dynamic setting.... I have yet to prototype it in FreeBasic, but it appears easy enough....

ack! i always get off on these tangents.... sorry for the wall of text....
Tourist Trap
Posts: 2754
Joined: Jun 02, 2015 16:24

Re: Game NPC AI ideas

Postby Tourist Trap » Jan 19, 2019 15:20

leopardpm wrote:...

Unfortunately I think I don't get it well too much. In anycase maybe you will be interested by this link of a contest on agent programming:

The prize money will be at least 500 euros for each league. The prize will be shared among the top agents - winners.

edit: maybe I already told you this? I'm getting old..

Return to “Game Dev”

Who is online

Users browsing this forum: No registered users and 0 guests