• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[AI] Make AI Build Walls But not in Random?

Status
Not open for further replies.
Level 5
Joined
May 8, 2009
Messages
87
Make AI Build Walls But not in Random?

And not by using regions pre-made in the map.
Ect by default to do that.(<<<ignore that if you dint understand what i said)

What i want is to make the AI to Build Walls around its main base In Square formation. and the ability to set the range of the walls between the main base(castle,necropolis,tree of life ect) and the walls.
Is any way to do that?

Thanks and no answers with no answers :thumbs_up:
 
There is a way, but you'd have to build your own AI. You would not need to use regions, and I don't recommend using regions for this anyways. Sadly, this sort of AI would require a very experienced coder. I doubt anyone would help you code this, so you'd like have to learn coding yourself so that you can code it yourself :\. You would also need to learn about AI. For this sort of AI, I'd personally do a genetic algorithm with a behavior tree. The conditions of the behavior tree would be based on calculating the possibility of a move. The moves themselves would come from the genetic algorithm. The scores... you'll have to figure those out yourself.

Sadly, JASS is ill suited to AI. You really need function pointers to do AI well, and JASS doesn't really have that. You could definitely do this pretty easily in Galaxy though, but Galaxy has its own problems.

edit
Ofc, if you were only interested in just building a wall, that is rather easy. You could determine how long a line is from point A to B using an IsPathable lib. From there, you just build along that line based on the collision of the buildings (GetUnitCollision). You could use the general wc3 I suppose and give it a command to build and have the custom script build a wall, but I wouldn't recommend that. It's much better and smarter to use a behavior tree with tasks for this.
 
Well, what I would suggest is two methods: One would be (when an AI is meant to build a wall) select all existing walls it owns in a unit group, find a location next to it (any 90 degree angle should work I should imagine) and tell it to build it next to it by a given distance (depends on the size of the wall) and that would work, but regardless they would not build proper walls but rather randomly long and randomly directional walls, unless you put in limiters and controls (i.e. a "has a wall been build next to this one already" sort of boolean variable)

A second method I could suggest would be using a sort of hub-system in that the lines between walls are automatically build once you build hubs, thus all you need to do is find all the corners you want the AI to build these hubs on (prehaps a given distance from a centre point like a main building) and have all the walls automatically built, through a similar method to the above, just doing it constantly with set facing angles/directions/lengths/etc. Calculated when the hub is built.

While both of these methods are impractical, they're the most practical to which I could suggest for a WC3 AI controlled by Gui triggering. Without going to behavioural trees and all sorts of complex mathematics to work out when/where/etc. it should be building things.
 
Even with triggers, it is extremely difficult to tell an AI to build in a uniform line, like walls coz you need to check every angle/pathable/buildable and it needs a timer to check if that builder has reached the build site and has done his order to build, then stop the timer or remove the builder from the builder group...
 
Even with triggers, it is extremely difficult to tell an AI to build in a uniform line, like walls coz you need to check every angle/pathable/buildable and it needs a timer to check if that builder has reached the build site and has done his order to build, then stop the timer or remove the builder from the builder group...

Nah, building the actual wall is easy. The other stuff would be up to the AI, and that is super easy using a Behavior Tree since it does exactly what you said in a simple and intuitive manner. The genetic algorithm would also determine the shape of the wall, and really, you wouldn't even need a genetic algorithm ;o. You could analyze the terrain around the base to determine where to build a wall ; ). The best candidates have the lowest widths, meaning least gold used. Use a priority queue for that.
 
Level 5
Joined
May 8, 2009
Messages
87
Nestharus you make it sound more difficult from what i expected lol.
but i trust your knowledge.
sadly all that vjass staff is not my thing,but i will give a try. anyway i will follow your instructions and hope for the best (do right what you say)

Thanks for your attention.
+1 for all
 
Level 7
Joined
Apr 5, 2011
Messages
245
Look here:
attachment.php

White - pathable, grey - non-pathable and that red square - our town hall. So, if we want to protect ourselves we should paint over that white passage on the right hand of town.

Universal method to do this is to draw a circle. As we know circle can have any size in Universe (Meta-Universe), so it can contain all our base. And sphere has the largest square with static perimeter among all figures while the base is usually built in a free piece of space. So, we have a circle with some radius:
attachment.php

As we see, it shows our wall perfectly except that blue point southward of town. It can be removed easily by checking neighbour points on making closed-loop figure. So, that 2 grey points can do this, and blue one is not needed. Removed.
edit
Forgot about other "blue points", just too lazy to change something. Do with them the same.


Then we should make an entrance. Just choose 2 (or 1 and make our "300") closest segments like this:
attachment.php


Saying with JASS terms, we have 2 boolean tables: first - terrain pathing table (0 - non-pathable, 1 - pathable), second - wall prediction table (0 - no wall prediction, 1 - wall prediction). Then we make 3rd table multiplying 1st and 2nd, remove "blue points", make entrance and gratz! We have wall-protected town. :thumbs_up:

Just make an algorithm choosing the best radius. And remember: not wall is built for towers, but towers for wall, so you don't need to think much about towers while making the wall.

edit
If you don't like walls similar to piece of circle, you can modify them easily by checking (with table with no entrance) your move on close-loop (or just on touch all neighbours if it's not outer, so bottom part of wall at illustration may become sharp vertical). (But rememeber: each line is the piece of infinite circle existing in the centre of Meta-Universe) Circle is just a way to define main shape.
 

Attachments

  • map1.jpg
    map1.jpg
    1.1 KB · Views: 211
  • map2.jpg
    map2.jpg
    2.1 KB · Views: 192
  • map3.jpg
    map3.jpg
    1.3 KB · Views: 191
Last edited:
Status
Not open for further replies.
Top