• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Small AI problem.

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
731
In my current project I'm making an AI system and it's pretty much done now.
The basics:
The AI will build structures in random places of a specified region to defeat whatever the opponent has built.
Problem:
After a while they run out of space, and hence aren't able to build anymore which usually means that they lose.
Question:
How can I solve this problem? I was thinking of something like the buildings are removed from the game after a while or attempting to make them build in a more orderly fashion. Any ideas?
 
Level 7
Joined
Jul 3, 2011
Messages
251
Why would they lose from running out of space? Surely thats a good thing meaning their base is advanced? Unless you mean they need to destroy some structures for more advanced ones? Have some way to detect when an AI can build a better structure then make them kill the old ones.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
If buildings become redundant after construction (generally a sign of poor game design) you just need to detect when the AI is starting to run out of room (maybe if the AI starts to fail many placement itterations) and get it to allocate some units to garbage collection (they are ordered to attack a redundant building to "free" space.

If buildings are always useful, you will need to create a more advanced building layout system. Model the build area as a grid (which it is) and make every building have a certain grid size (remember to factor in movement space between buildings). You then proceede to fill in the grid with these blocks in an orderly fassion. Remember to factor in space being freed in the case that an enemy kills a building (so the AI can reuse the space).

Remember that rows or collumns might be the most efficient allocation of space. Avoid mixing stuff of different pathing types next to each other. Only production buildings need room for units to walk from and get to combat. Although support buildings (such as a human farm) do not need walk access, it is advisable to supply some to avoid the buggy case that someone snipes a building that can not be replaced unless other buildings are demolished.
 
Status
Not open for further replies.
Top