Author Topic: [not valid] AI should respond to attacks on an ally  (Read 1414 times)

sojourner

  • Guest
[not valid] AI should respond to attacks on an ally
« on: 29 April 2011, 18:45:05 »
AI players belonging to the same team should respond to the attack alarm.

Rationale:
    A human player is allowed to see his ally's locations and he can make a choice to help out the AI units under attack if it helps the team's cause. Similarly the AI units must respond to the attack alarm if the attacked unit is an ally (AI or human).

Pros:
* Game play is now more consistent - it will now appear as if the AI can also see the mini map just a human player can.
* Allies must respond to any units in distress

Cons:
* A human player can just laze around while AI does all the work (however, when I made the code change and played, the opposite AI team is, as you might expect, doubly powerful so to speak... so it appears to even out rather well).

Here is my code change to achieve this:
Index: source/glest_game/ai/ai.cpp
===================================================================
--- source/glest_game/ai/ai.cpp (revision 2152)
+++ source/glest_game/ai/ai.cpp (working copy)
@@ -625,7 +625,7 @@
                        if(map->isInside(pos) && map->isInsideSurface(map->toSurfCoords(pos))) {
                                if(pos != unitPos) {
                                        Unit *adjacentUnit = map->getCell(pos)->getUnit(unit->getCurrField());
-                                       if(adjacentUnit != NULL && adjacentUnit->getFactionIndex() == unit->getFactionIndex()) {
+                                       if(adjacentUnit != NULL && aiInterface->isAlly(adjacentUnit) /*Sojo: adjacentUnit->getFactionIndex() == unit->getFactionIndex()*/) {
                                                if(adjacentUnit->getType()->isMobile() && adjacentUnit->getPath() != NULL) {
                                                        //signalAdjacentUnits.push_back(adjacentUnit);
                                                        float dist = unitPos.dist(adjacentUnit->getPos());

« Last Edit: 14 May 2011, 15:20:27 by sojourner »

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: AI should respond to attacks on an ally
« Reply #1 on: 1 May 2011, 18:17:19 »
+1

ultifd

  • Airship
  • ********
  • Posts: 4,443
  • The Glest Video Guy :) The one and only. :P
    • View Profile
    • My Youtube Channel
Re: AI should respond to attacks on an ally
« Reply #2 on: 3 May 2011, 07:26:45 »
Well, it sounds good, but the AI seems so hard/improved now already...  :-X Now we have to imagine it to be even better which is kinda  :look:

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: AI should respond to attacks on an ally
« Reply #3 on: 3 May 2011, 07:54:02 »
Don't think you tested this, this code you changed has nothing to do with AI attacking.

sojourner

  • Guest
Re: AI should respond to attacks on an ally
« Reply #4 on: 3 May 2011, 14:32:21 »
@ultifd,
This change will come into picture only in a team situation. If you have an AI ally, it would come to your help...

@softcoder,
Ok. I made the change because I felt let down by my AI ally :) Let me toggle the code ON and OFF and see the difference once more. I could have sworn that it made a big difference -- unless the AI already responds to the alarm when none of its own units are near the center of action, I am sure this helps -- I will admit that it doesn't always help, but I thought that is because other parameters like "home base is secure?" and "are there minimum number of units available?" come into play.

The change was done because, from the flow of the control I thought this routine helps the AI to select its nearby units and send to the site where it is under attack/required. So I thought I was just expanding the range of units that the AI is interested in. I will check it out and get back.

sojourner

  • Guest
Re: AI should respond to attacks on an ally
« Reply #5 on: 3 May 2011, 15:26:44 »
@Softcoder, Sorry about that. Guess I was a bit too zealous...

That code I suppose will move allies 'out of the way' (unblock units?).

Do tell me, does the feature request/suggestion even make sense ? Is it really a missing feature? I am not sure any more.

1) Does AI respond to a human ally under attack (away from any of the AI's units' sight range)?
2) Does AI  player 1 respond to an AI ally under attack (again, away from any of the AI player 1's units' sight range?)
« Last Edit: 3 May 2011, 16:10:18 by sojourner »

ultifd

  • Airship
  • ********
  • Posts: 4,443
  • The Glest Video Guy :) The one and only. :P
    • View Profile
    • My Youtube Channel
Re: AI should respond to attacks on an ally
« Reply #6 on: 3 May 2011, 21:59:54 »
@ultifd,
This change will come into picture only in a team situation. If you have an AI ally, it would come to your help...
Oh, ok. Usually they do help though, but not always. Especially if you have more than one AI ally.

 

anything