Questions about multiple allied teams & the AI...

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
User avatar
Coaxke
Posts: 127
Joined: June 7th, 2007, 5:08 pm
Location: United States

Questions about multiple allied teams & the AI...

Post by Coaxke »

In a 4 player scenario I'm making, each player has one AI opponent he/she must defeat to win the game. The 4 players are not on the same team, and the 4 AI players must only be able to attack the rival human player it is assigned to.

Examples:

-Human player 1's rival is AI player 5, so AI player 5 must only attack player 1
-Human player 2's rival is AI player 6, so AI player 6 must only attack player 2, but AI player 6's units can not get distracted and attack units belonging to any other player

This is complicated because the human players are enemies too, and each have their own AI to do war with. How can I make this possible?
Please click here to apply for a Computer-Aided Enrichment Center program. Message me if you need help following the simple, on-screen instructions.

Projects I'm currently working on:
  • Warlords
  • WesCiv (delayed)
  • WesCol (delayed)

User avatar
solsword
Code Contributor
Posts: 291
Joined: January 12th, 2009, 10:21 pm
Location: Santa Cruz, CA
Contact:

Re: Questions about multiple allied teams & the AI...

Post by solsword »

I'm pretty sure that this isn't possible without writing a custom AI. Right now, teams are mutually-exclusive sets of sides. This means that "allied to" is transitive and reflexive. Another way to say that is that if side X is allied to side Y, and side Y is allied to side Z, then side X is allied to side Z (and of course, if side X is allied to side Y, then side Y is allied to side X). Since "allied to" is the only way of preventing sides from attacking each other short of writing a custom AI (or magical hacks, which may or may not work, that I'll get to in a moment), you're stuck. In your scenario, you want it to be the case that, for example, player 5 doesn't attack player 6, and player 5 doesn't attack player 2 (since player 5 should attack only player 1). By the transitive and reflexive properties of "doesn't attack" (which is the same as "allied to"), we can deduce that player 5 doesn't attack player 6 (which I assume is not desired).

Now, the potential black magics.

First way of doing this that I thought of would be to set the values for the various sides that the AI assigns (all possible using the various sub-tags of the [ai] tag), so that, for example, side 5 can attack whoever it wants, but views side 1's units as 10x more juicy than those of any other side. However, I've not had tremendous luck with using priorities to control the AI. Another, and possibly easier (or at least, more likely to work) method, would be to switch alliances every turn, so that they were correct for the current player. So for example, during each AI turn, that AI would be allied with all of the other players *except* the player that they were supposed to attack, but during the player's turn, all sides would appear hostile (or whatever). Depending on your exact setup, I think that this should work.
The Knights of the Silver Spire campaign.

http://www.cs.hmc.edu/~pmawhorter - my website.

Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?

User avatar
Coaxke
Posts: 127
Joined: June 7th, 2007, 5:08 pm
Location: United States

Re: Questions about multiple allied teams & the AI...

Post by Coaxke »

solsword wrote: First way of doing this that I thought of would be to set the values for the various sides that the AI assigns (all possible using the various sub-tags of the [ai] tag), so that, for example, side 5 can attack whoever it wants, but views side 1's units as 10x more juicy than those of any other side. However, I've not had tremendous luck with using priorities to control the AI.
This was my original idea, but I too didn't think that it would be very reliable.
solsword wrote: Another, and possibly easier (or at least, more likely to work) method, would be to switch alliances every turn, so that they were correct for the current player. So for example, during each AI turn, that AI would be allied with all of the other players *except* the player that they were supposed to attack, but during the player's turn, all sides would appear hostile (or whatever). Depending on your exact setup, I think that this should work.
This is a good idea :hmm:
Please click here to apply for a Computer-Aided Enrichment Center program. Message me if you need help following the simple, on-screen instructions.

Projects I'm currently working on:
  • Warlords
  • WesCiv (delayed)
  • WesCol (delayed)

zaimoni
Posts: 281
Joined: January 27th, 2005, 7:00 am
Location: Linn Valley, KS U.S.A.
Contact:

Re: Questions about multiple allied teams & the AI...

Post by zaimoni »

Coaxke wrote:In a 4 player scenario I'm making, each player has one AI opponent he/she must defeat to win the game. The 4 players are not on the same team, and the 4 AI players must only be able to attack the rival human player it is assigned to. ....
1.6.x: team-swapping as mentioned by solsword.

1.7.x: If the wiki is accurate, just have four teams and put each AI side on three of the teams. The AI should go after the one player it doesn't share a team with.

User avatar
Coaxke
Posts: 127
Joined: June 7th, 2007, 5:08 pm
Location: United States

Re: Questions about multiple allied teams & the AI...

Post by Coaxke »

Link to the wiki page, please?
Please click here to apply for a Computer-Aided Enrichment Center program. Message me if you need help following the simple, on-screen instructions.

Projects I'm currently working on:
  • Warlords
  • WesCiv (delayed)
  • WesCol (delayed)

zaimoni
Posts: 281
Joined: January 27th, 2005, 7:00 am
Location: Linn Valley, KS U.S.A.
Contact:

Re: Questions about multiple allied teams & the AI...

Post by zaimoni »

Coaxke wrote:Link to the wiki page, please?
It's in the documentation for the side tag.

Post Reply