Recognizing the numbers of units for AI purposes.
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Recognizing the numbers of units for AI purposes.
Hi,
I am going through the wiki and tutorials, but it still goes a little bit over my head.
Is there a reliable way of recognizing a hex that neighbours with a specific number of units? E.g., define a filter which only includes hexes that have no units on them, but two red and one blue in radius of 1?
Thanks.
I am going through the wiki and tutorials, but it still goes a little bit over my head.
Is there a reliable way of recognizing a hex that neighbours with a specific number of units? E.g., define a filter which only includes hexes that have no units on them, but two red and one blue in radius of 1?
Thanks.
- Spannerbag
- Posts: 556
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Recognizing the numbers of units for AI purposes.
Hi,BajMic wrote: ↑August 12th, 2023, 7:47 pm Hi,
I am going through the wiki and tutorials, but it still goes a little bit over my head.
Is there a reliable way of recognizing a hex that neighbours with a specific number of units? E.g., define a filter which only includes hexes that have no units on them, but two red and one blue in radius of 1?
Thanks.
If I understand correctly, you want to find all empty hexes (no unit stationed on it) that have precisely 2 red and one blue units adjacent to it (radius=1).
It would be helpful to know the context for this filter; is it going to be used in a moveto event or to count the number of such locations or something else?
Anyway, assuming you simply want to filter those locations for some reason then I *think* something like this might work (assuming red is side 1 and blue is side 2, if not change the side numbers below accordingly):
Code: Select all
[filter_location]
[not] # Ensures hex is unoccupied
[filter]
[/filter]
[/not]
[filter_adjacent_location]
[filter]
side=1 # Assumes red=side 1
[/filter]
count=2
[/filter_adjacent_location]
[filter_adjacent_location]
[filter]
side=2 # Assumes blue=side 2
[/filter]
count=1
[/filter_adjacent_location]
[/filter_location]
Also other folk may well come up with better suggestions but hopefully this will give you a starting point?
Anyway, hope this helps!
Cheers,
-- Spannerbag
Re: Recognizing the numbers of units for AI purposes.
Yes. This is what I needed, thank you. I am trying to tailor-script the scenario AI to play more human-like.
Can I use the "count" parameter in standard location filters as well? I only used it in conditional tags so far.
Can I use the "count" parameter in standard location filters as well? I only used it in conditional tags so far.
- Celtic_Minstrel
- Developer
- Posts: 2274
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Recognizing the numbers of units for AI purposes.
It can be used in either
[filter_adjacent]
or [filter_adjacent_location]
. That means it's not available directly in a standard location filter; but [filter_adjacent_location]
is part of a standard location filter, so pretty close.