Tribe of Pok: Balancing the Human AI

Balancing the human artificial intelligence has been one of the harder parts of development. The difficulty stems from trying to make the AI do things that seem “logical” to the player. For example, consider the two possible desirable actions “harvest food” and “eat food”. We need to determine which action takes priority. If someone is hungry, the logical action would be to see if there’s any food around and eat it. OK, simple. We set the desire to eat to be higher than the desire to harvest food.

20150215 FoodDisplay

What if there isn’t anything to eat lying around? Since the desire to eat is higher, they will continually try to eat and never try to harvest food first. The player thinks, “What a stupid AI”. The logical action would be to harvest food first, and then eat the food. OK, then let’s switch it around so we set the person’s desire to harvest food to be higher than the desire to eat food.

20150215 TreeDisplay

Now what if the player creates 50 “harvest food” tasks on 50 different plants? Remember, the tribe member’s desire to harvest food is set higher than their desire to eat food. The AI thought process will be: hungry -> harvest food -> harvest food -> … -> harvest food -> STARVING -> harvest food -> harvest food -> starved to death. They will continue harvesting until they either finish all the harvest tasks or starve to death, despite being surrounded by plenty of recently harvested food. Once again the player thinks, “What a stupid AI”.

One way to work around this is having a variable desire to eat that fluctuates depending on current conditions. Firstly, add a check for food’s existence before trying to eat food. If there is nothing to eat, then set the desire to eat to be zero, no matter how hungry the person. That way the person will carry out any harvest tasks first. Secondly, if something to eat exists, make the person’s desire to eat higher the hungrier they become. With these extra rules, let’s see how the AI behaves in the above scenario with 50 harvest tasks.

20150215 FoodEverywhere

The AI thought process will be: hungry -> look for food -> find no food -> harvest food -> harvest food -> … -> harvest food -> STARVING -> look for food -> find food -> eat food. This thought process requires more calculations, but it makes the tribe member appear smarter to the player.

Now add in desires for drinking, sleeping, staying warm, fighting, fleeing, finding missing equipment, crafting and building to this equation. It’s pretty easy to end up with an AI that doesn’t always do the “logical” thing if the desires aren’t carefully balanced. Even worse is an AI whose desire fluctuates every few milliseconds, causing it to flip-flop between two different actions but not making any progress on either one. If you’ve ever seen an AI in a game move their units backward and forward over and over again, you’ll know what I mean.

20150123Bug

I’m constantly testing and tweaking the human AI in Tribe Of Pok to balance desires (and stop them burning themselves, like in the above gif). It can be time-consuming, but I think it’s worth the effort. It’s great to see your Pokians on screen running around acting the way you would expect.

By |February 15th, 2015|GameDev|2 Comments

Activity Summary Week 6, 2015

This week I’ve been working on:

  • Average global temperature read from XML
  • Seasonal temperature changes now read from XML
  • Convection (weather fronts) now read from XML
  • Rainfall determined by biome chosen and not slider
  • Worked on Arctic biome setup
  • Make initial water-level settable based on xml
  • Fix global humidity too high for extremely low temperatures
  • Fixed humidity occasionally being too low at game start
  • Implement ability to snow in not-winter
  • Make river water flow better/faster
  • Fixed excessive water created when river freezes
  • Discovered rare crash on save bug (no fix)
  • Animal carcasses are colored images of the original animal
  • Game saves at the beginning of map
  • Clicking on ground when map menu already open should open new map menu
  • Fixed map menu not opening randomly about 3% of the time
  • Removed Pea Fruit
  • Removed Tool Rack and Large Pit (need to think about it more)
  • “Mammoth mammal” now “Woolly mammoth”
  • Added “Sabretooth Tiger”
  • Recentred object thought bubbles
  • Remove side menu cancel tasks button
  • Side stockpile panel warning when no Stockpiles assigned
  • Maximum camera zoom in should be 0.5
  • Volume slider for UI sounds
  • Awl can only be built with small bone
By |February 8th, 2015|Activity Summary|0 Comments

Activity Summary Week 5, 2015

This week I’ve been working on:

  • Player can choose which tiles to expand influence
  • Added check for connection to current influence area when assigning new influence area
  • Influence uses up culture at a certain rate to replenish
  • Influence disappears if campsite moved
  • If culture drops to 0, influence starts disappearing and unable to assign new areas
  • Influence tiles on border of territory are more costly
  • Repeat fighting cloud animation, make it last longer
  • Art for sleep, eat, fighting and building progress bar
  • Overhauled the way buildings are drawn
  • Improved framerate of draw thread
  • Tutorial Notification when culture starts growing
  • Added WeatherPattern class
  • Hourly temperature changes now read from XML
By |February 1st, 2015|Activity Summary|0 Comments

Activity Summary Week 4, 2015

This week I’ve been working on:

  • Implemented main menu text highlighting
  • Updated tutorials xml to comply with new format
  • Added tutorial for influence area
  • Fix clicking on notification button deleting notification when not supposed to
  • Fix task extract ground and task extract object appearing at same time
  • Add notification for no materials to build building
  • Worked on culture requirements for some diplomacy actions
  • Refactored diplomacy panels
  • Added discovery level for each tribe to diplomacy panel
  • Require player to send out scouting missions to get more info on neighbouring tribes
  • Stopped clicking certain notifications from closing notification window
  • Allow button images to be terrain or object sprite
  • Drew some specific progress bar images
  • Implemented changing progress bar texture
  • Fix humans picking up wildfire and trying to store it
  • Fix humans collecting wood when assigned to set forest on fire
  • Add tooltip for Combat Mode cancel button
  • Animals and humans have same priority to display
By |January 26th, 2015|Activity Summary|0 Comments

Activity Summary Week 3, 2015

This week I’ve been working on:

  • Humans give notification when under attack
  • Fix bushes not choppable from UI menu
  • Add Bone Wall
  • Add ability to specify corpse type in animal xml
  • Stop under attack notification from appearing a hundred times
  • Fix combat mode selection box not resetting when mouse going offscreen
  • Created Tribe Of Pok Logo
  • Fixed some issue with combat mode rectangle select not covering all hexes
  • Added “could not make object” to notifications
  • Fix crash when human assigned to move off map
  • Implemented tags in notifications which can be defined in xml
  • Human-created objects automatically get store object task when created
  • Stock panel Allow/Forbid all opens when stockpile clicked now
  • Add “owned” indicators to tribe panel clothing selection
  • Allow multiple UI sounds to play at once
  • Notification for joining tribe members includes culture cost in text
  • Add logo to main menu
  • Created class to hold mouse/keyboard inputs
  • Credits text added
  • Fix combat mode killing animal and then red combat arrows reappearing
  • Fixed human not taking out weapons sometimes when fighting
  • Implemented animal hit animations functionality
By |January 18th, 2015|Activity Summary|0 Comments

Activity Summary Week 2, 2015

This week I’ve been working on:

  • Put clothing restrictions into body class
  • Player can choose to allow/forbid clothing in Tribe Panel
  • Implemented humans drop clothes when forbidden from wearing them
  • Data overlay now uses blackstripe image for negative values
  • Separated legs and hands into left/right
  • Add culture measure to tribe
  • Display culture rate per day
  • Fix buildings not requiring materials bug
  • Added another check to remove a task if any subtask fails
  • Fixed not reading required abilities properly for crafting
  • Wood poles no longer have influence unless lit
  • Task Panel crafts pop-up shows value of items
  • Fix stock panel counting objects on people in “Amount in stockpiles”
  • Stockpiles can be renamed
  • Implement Combat mode RTS-style improvements
  • Fix attacking own tribe member in combat mode
  • Added Stone Statue trinket
  • Implemented art assets
  • Implement new notification system for events e.g new members joining
  • Fixed newly created tribe members only being teens
  • Fixed bushes not generating
  • Created event for Tribute Demand
By |January 11th, 2015|Activity Summary|0 Comments

Tribe Of Pok: New Combat Mode and Prosperity Mechanics

Firstly, there are some new ways I’ll be communicating to the community. You can now follow me on Twitter via @ParsleyPWG for more regular updates on what I’m working on. I’ll also be posting a weekly work log on the website blog. Remember, you can also sign up to be notified when new Early Access versions are available.

Combat mode

Combat Mode was something I put in a while ago, and took out when it became too confusing. When entering Combat Mode, the tribe members stop what they are doing and wait for the player to give orders. Several improvements have been made to the point where I’m happy to put it back in the game.

It works much like in an RTS game now, left-click drag to select and right-click to give move or attack orders. If someone is under attack, you can enter Combat Mode and send other tribe members to help them fight. Much more intuitive than in the previous iteration.

DevUpdate 20150110Animate1

Prosperity

Once a tribe’s food and water needs were met, I didn’t feel there was a strong enough force driving the gameplay forward. While testing the game, I got to a point where everyone was happy and thought to myself, “ok… now what?” Something was needed to tie everything together. There had to be a goal the player could aim for in addition to survival. So I did some thinking and came up with a single measure to handle all this – prosperity.

20150110Image2

Prosperity is a measure of how well your tribe is doing. Currently it is affected by factors such as the size of your tribe, amount of food available, the value of items and severity of diseases. In general, the value of items will only count if they’re located within your “circle of influence”. The circle of influence is an area around the tribe that can grow or shrink. I implemented it a while ago as a way to prevent roaming animals from constantly wandering into the player’s campsite and starting fights. I wasn’t sure whether to display this influence area or leave it as a bit of a mystery, but with the introduction of prosperity, the effect needs to be made clear. The influence area can be expanded by building additional fire poles, which need to be occasionally maintained by adding animal fat to them.

20150110Image3

The intention is to have prosperity fluctuate as the fortunes of your tribe change. I have some ideas to build on this mechanic in terms of progression and unlocking advanced crafts. It needs a bit more work though before I say any more.

By |January 10th, 2015|GameDev|0 Comments

Activity Summary Week 1, 2015

Welcome to the first of a series of weekly summaries on what I’ve been doing! This is basically a cleaned up version of the internal changelog I keep. If this goes well I may consider doing this throughout the development cycle.

– Created animal fat to relight fire poles
– Tribe Panel individual equipment selections
– Minimap shows Mountains properly
– Started Twitter account @ParsleyPWG
– Artist asset request
– Fix rocks spawning in mountains
– Fix humans and animals spawning in mountains
– Fixed Alerts hovering playing clicking sound
– Add right-click sound
– Re-implement predators seeking prey to eat
– Change AddTaskCookMeat to search for any meat available instead of only Mammal meat
– Remove references to “mammal” so we can have stuff like “angry tiger” or “oversized mammoth” in xml
– Change stock panel “Type” to Categories
– Fix Data overlay not disappearing when out of gather mode
– Able to click on UIbutton to reenter pointing state
– Replaced FriendSpecies with animal factions – e.g Herbivores, Lion-types, mammoth-types defined in xml
– Decay rate in querypanel convert to decay per day
– Fixed adding craft task causing craft list to reset
– Change when all task objects are reserved
– Fixed butcher carcass taking no time by adding craft time in xml
– Prosperity calculated and displayed on game load
– Combine “Fruit” and “Cooked” and “Herb” categories into Edible

By |January 4th, 2015|Activity Summary|0 Comments

Tribe Of Pok: Using the UI to improve feedback

This update will be about ways I’ve been improving the UI for a better player experience. Below you can see the new look for the UI.

DevUpdate20141211

Alerts system – to give a bit more direction to the player, I have added an alerts system. It’s similar to the one used in the Europa Universalis series, and a great way to inform the player about issues that need attention. When a certain trigger is activated, a little popup will appear at the top of the screen with some information. Examples of issues that will trigger an alert include lack of available food and water, being under attack and lack of a camp fire. Once these needs are taken care of, the alert should disappear. Hovering over the image also gives a description of the problem.

DevUpdate20141211ga

More immediate feedback – the player will receive immediate feedback when trying to perform an illegal action. I noticed players tended to start clicking random buttons and hexes when nothing in the game was reacting to them, so now a tool tip immediately pops up informing the player what went wrong. This should lead to less frustration.

DevUpdate20141211gb

Minimap – The minimap is more useful after some improvements. It now shows buildings, people and animals wandering around. You can also click on it to zoom the view to that location.

DevUpdate20141211gc

By |December 12th, 2014|GameDev|0 Comments

Tribe Of Pok: Harvesting system update

Food gathering works slightly differently now. Before it was too obvious which trees were fruit producing (like apple trees) and which trees weren’t. This led to a situation where the player is encouraged to cut down only the non-productive trees and leave the fruit producers. Eventually the trees would grow back, and the player could repeat the process until the entire forest was full of fruit producers.

DevUpdate20141124

This solution was too well-engineered for a game set in the Paleolithic era, and it wasn’t very fun to constantly be cutting down trees but trying to avoid/remember the fruit producers. So now, food harvesting has changed. When the harvest button is clicked in the menu, all the potential hexes that can be harvested are marked on the map.

DevUpdate20141126g

Almost every tree and bush has a chance to produce fruit or seeds when it is harvested, and the type of produce varies depending on the species of plant. Some plants will produce nothing, and others will produce a random amount of food. The player won’t know what they’ll find until the harvest action is complete. They also won’t be able to tell which hexes will be fruit-bearing, so cutting down a whole forest will mean the loss of potential harvest locations.

DevUpdate20141126gb

After a certain amount of time you can harvest the plant again, unless it’s been cut down or died of old age.

By |November 25th, 2014|GameDev|0 Comments