Need help getting AI to perform tasks.

The place to post your WML questions and answers.

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.
Post Reply
Lunar2
Posts: 165
Joined: July 3rd, 2004, 1:17 am

Need help getting AI to perform tasks.

Post by Lunar2 »

Not sure if this is the right board, but here goes.

The following are things I've tried to do in WML for a campaign I'm working on, and failed:

1) Have a group of units spawned before the game starts focus on attacking a specific unit or group of units, rather than the enemy units nearest them. [target] does not seem to have much effect unless they can reach the target in 1 turn, and I want the start to be farther apart than that.

2) Have a unit follow another unit. Protect is not doing the job, because again, I want opposing teams to not start close enough that they are a threat. And making a ton of protects with varying radii is too unwieldy and still might not work.

3) A specific case of #2, having a group of units surround a leader whenever they are not attacking the enemy.

4) Getting leader_goal to work, I suppose the unit has to be a leader? I was hoping not...I'd like to command specific units to head to a destination w/o making them leaders, is this possible?
Last edited by Lunar2 on January 24th, 2006, 6:04 am, edited 1 time in total.
Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Location: An Earl's Roadstead

Re: Need help getting AI to perform tasks.

Post by Darth Fool »

Lunar2 wrote:Not sure if this is the right board, but here goes.

The following are things I've tried to do in WML for a campaign I'm working on, and failed:

1) Have a group of units spawned before the game starts focus on attacking a specific unit or group of units, rather than the enemy units nearest them. [target] does not seem to have much effect unless they can reach the target in 1 turn, and I want the start to be farther apart than that.

2) Have a unit follow another unit. Protect is not doing the job, because again, I want opposing teams to not start close enough that they are a threat. And making a ton of protects with varying radii is too unweildy and still might not work.

3) A specific case of #2, having a group of units surround a leader whenever they are not attacking the enemy.

4) Getting leader_goal to work, I suppose the unit has to be a leader? I was hoping not...I'd like to command specific units to head to a destination w/o making them leaders, is this possible?
These are all good things to be able to do. #2 can be done, sort of, by targeting your own unit that you want followed. I hope to make all 4 possible/easier to do when my AI is released into the wild.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Need help getting AI to perform tasks.

Post by zookeeper »

Lunar2 wrote:1) Have a group of units spawned before the game starts focus on attacking a specific unit or group of units, rather than the enemy units nearest them. [target] does not seem to have much effect unless they can reach the target in 1 turn, and I want the start to be farther apart than that.
If [target] doesn't work, I'm a bit short on ideas.
Lunar2 wrote:2) Have a unit follow another unit. Protect is not doing the job, because again, I want opposing teams to not start close enough that they are a threat. And making a ton of protects with varying radii is too unwieldy and still might not work.
I think you could do this by manually setting the AI unit's goto_x and goto_y before it's every turn to point to the unit he should follow. I'll test if this works in a little while, so I can post back the results.
Lunar2 wrote:3) A specific case of #2, having a group of units surround a leader whenever they are not attacking the enemy.
Their own leader or the enemy's? I suppose it would be possible to make them surround their own leader, or even the leader of the enemy. It will be very tricky though.
Lunar2 wrote:4) Getting leader_goal to work, I suppose the unit has to be a leader? I was hoping not...I'd like to command specific units to head to a destination w/o making them leaders, is this possible?
Again, manually setting the goto_x and goto_y attributes of a unit might do the job. As I said, I'll try if this works.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Ok, it seems that goto_x and goto_y can't be used to set paths for AI units. When they are set for player units, they are moved along the given path in the beginning of the player's turn, but this doesn't work for AI sides.

This pretty much disables all the ideas I had about making these things work. If you only need these for single campaign scenario(s), it'll probably be possible to do these in a hacky scenario-specific way (more or less). So if you want to, you can post some scenario code and describe how it should behave and I can try to figure something out.
Lunar2
Posts: 165
Joined: July 3rd, 2004, 1:17 am

Post by Lunar2 »

What I'm working on is eventually a 25 mission campaign, and they will all need all those features. Why? Langrisser is my inspiration, I'm making a remake of it. And I'm trying to mimic the battle system of that game with Wesnoth, which isn't that hard to do if I could just teach the AI.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Well, in that case I think your best bet is the new support for Python AI's.
Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Location: An Earl's Roadstead

Post by Darth Fool »

#2 and #3 can be done by targeting your own unit that with a high value. #1 Would be hard to tell if the AI is doing it. I would suggest using debug mode. You can see what the AI is thinking. The only way to do #4 currently is to have a unit be a leader. This is the first task that my new AI will fix, and it already can handle doing this, but I am overhauling the whole thing. The dfool AI will allow you to define for any set of units a target to move to. That target could be either a location on the map, or a position relative to another unit. I also plan on making it possible to essentially define a series of waypoints. If your campaign is really 25 scenarios long, all this should be accomplished well before you are done. Once movement with the Dfool AI is done, I will be moving on to more useful things like teaching it how to fight and recruit.
User avatar
Ranger M
Art Contributor
Posts: 1965
Joined: December 8th, 2005, 9:13 pm
Location: England

Post by Ranger M »

BTW what is the tmescale you are working on with your DFool AI? I am going to find it very useful in two of my current scenarios, and at least one new one.

Also how will new AI's be added? will there be a new WML tag?
Post Reply