Author Topic: AI line of sight bug  (Read 8975 times)

Pug

  • Guest
AI line of sight bug
« on: 5 April 2007, 02:09:35 »
Discovered this while playing with a new spell.

Meteor is a heavy duty arch mage spell with a long range, the idea being for the Arch mage to provide long range fire support rather than risking his expensive hide going into close combat. (Well, that plus I liked the special effects while playing with the particle engine, and wanted to use them).

The problem is he will happily attack targets neither he nor any unit on my side can see - they just need to be within the spell range, not visual range.

Any chance of this being fixed in the next version? Admittedly fire support is an anachronism in Glest, but it's not locked into this genre, and it could be useful.

Thanks - Pug
« Last Edit: 1 January 1970, 00:00:00 by Pug »

Wolwen

  • Guest
(No subject)
« Reply #1 on: 5 April 2007, 16:07:56 »
i think that's good, you know, when those units get into visual range of your other units, they already have their hp decreased by the archmage, making it easier for you.

what could be done is so that those units appear once attacked.
« Last Edit: 1 January 1970, 00:00:00 by Wolwen »

Pug

  • Guest
(No subject)
« Reply #2 on: 6 April 2007, 00:43:45 »
Well, the problem is the unit will attack enemies that aren't in any units visual range. It attacks units that should be obscured under fog of war rules.

Which makes it a cheat and a bug, rather than a tactic. Attacking at long range that other units can see is a tactic. Attacking units that none of your units should be aware of is a bug - <G>.

Pug
« Last Edit: 1 January 1970, 00:00:00 by Pug »

Wolwen

  • Guest
(No subject)
« Reply #3 on: 6 April 2007, 02:46:58 »
that's because the fog of war is just a black thing put on top of everything, kind of a cloud, you know.
so for the computer it still seems as there is no fog cause it's orientated with objects(kind of a bat sonar), and i remember this same thing happening in both age of empires I and II, so i guess it's nothing at all, else microsoft wouldn't leave it on aoeII.

just ignore.
« Last Edit: 1 January 1970, 00:00:00 by Wolwen »

Pug

  • Guest
(No subject)
« Reply #4 on: 6 April 2007, 11:29:46 »
Well, you can't really just ignore - it breaks the functionality of the sight function. A unit shouldn't be able to shoot at something it can't see.

To put it differently - a spell with a range of 1024, will be able to kill any unit, on any map, even with a sight range of 5, because it's using the larger of sight or range, not the lesser of the two.

By the same token, if you and the AI have the same units, it's going to attack/destroy you without your having any chance to respond, because it can kill you based on it's ranged attacks, without bothering to go to the trouble of finding you.

It's a Bug. I can understand if the team doesn't want to fix it - I'm not a programmer myself, but I suspect it's not a trivial fix, particularly if you want to allow indirect fire (an attack on someone that is visible, but not visible to the unit attacking).

But it's definitely a bug, and needs to be annotated and treated as such - as it stands, for sight to be meaningful the attack range *cannot* exceed the line of sight. Seems so obvious to me that it's a bug that I'm not entirely sure why you don't seem to want to recognize it as such.

Apologies - Pug
« Last Edit: 1 January 1970, 00:00:00 by Pug »

Wolwen

  • Guest
(No subject)
« Reply #5 on: 6 April 2007, 12:49:32 »
well...

did i say to you that the fog of war is like a cloud that roams in the sky to block the vision of someone that would be higher(the player) ?

well, just because your right under a cloud, that doesn't mean you're invisible.

it's a bug yeah, but it's not a bug that should be removed, it adds a bit of randomness to battles, you never know who might be behind you.

and anyways, anything goes on wars...
« Last Edit: 1 January 1970, 00:00:00 by Wolwen »

theotherhiveking

  • Guest
(No subject)
« Reply #6 on: 6 April 2007, 13:36:51 »
IT IS A BUG THE ARCH MAGES AREN'T GOING TO WASTE THEIR MAGIC INTO INVISIBLE OBJETIVES!!  IT'S LIKE IN WAR SOLDIERS ANEN'T GOING TO WASTE MISSILES SHOTTING AT THE DESSERT SAYING "MAYBE WE CAN IT SOMETHING, LET'S TRY"
« Last Edit: 1 January 1970, 00:00:00 by theotherhiveking »

Wolwen

  • Guest
(No subject)
« Reply #7 on: 6 April 2007, 14:00:35 »
man, please don't shout. a whole post in upper case ? no thanks, we can read in lower case.

it is a bug, i didn't say the opposite, what i want to say is: do you think that if anyone cared about this bug, wouldn't somebody have complained a long time ago ? and if anybody cared, don't you think it would be already fixed ?

anyway, just increase the archmage's sight.
« Last Edit: 1 January 1970, 00:00:00 by Wolwen »

Pug

  • Guest
(No subject)
« Reply #8 on: 6 April 2007, 23:57:26 »
I agree there's no need to shout, but I still am completely not understanding your point, to a point that I have to assume one of us is completely misinterpreting what the other is saying.

I get the impression you don't think I understand fog of war. Yes, I know it's an overlay over the map - I understand that. That overlay is supposed to simulate the fact that there is information that our troops can see (Their line of site) and information neither they nor we (as their 'commanders') have - the area that is blacked out (when we have no information) or grayed out (Where we have no current information).

That is the problem I'm having here, and somehow not communicating to you. That fog of war simulates lack of information, but if a unit has a range that extends beyond where it's sight counters the fog of war, it's ai will react to information it should not have access to.

It's not firing into the unknown at random - the unit launches specific attacks based on the location of units it should not have knowledge of.

Now, that's not a game breaking bug. Simply keeping the attack range under the line of sight range for a unit avoids the issue entirely. It is however a bug that puts severe limits on things that *could* be done within the scope of the game - two I can think of right off hand are:

A)  that you can't make an attack that is pure line of sight for a unit - because the line of sight on an attack can vary as you gain levels, but the range is fixed, so you can't set the range above line of sight to allow it to increase as visual range increases, without dealing with this bug.

B) You can't implement any kind of indirect fire capability like an artillery strike, because to do so means that, by definition, you must have a range larger than the line of sight for the unit - otherwise it's direct fire.

But no, we're not talking about detecting invisible units or anything - we're talking about the fact that fog-of-war is supposed to simulate the sum total of all the knowledge available to our units, and that a unit with a range in excess of line of sight acts on information above and beyond the limit that fog-of-war should impose.

Am I making this clear?

Pug
« Last Edit: 1 January 1970, 00:00:00 by Pug »

Wolwen

  • Guest
(No subject)
« Reply #9 on: 7 April 2007, 00:16:21 »
well, the actual engine just puts a semi-transparent black image over everything to look like a fog, but for the ai it means nothing, so the units can still see what's under it, anyways, commanders don't go to battles, they don't see what's going on, but the soldiers are there and can see whats really there. since for the ai it seems as there's no fog of war, there's no way to turn this out, the better solution would be to either ioncrease the unit's sight, decrease attack range, or turn off the fog, as to see everything.
« Last Edit: 1 January 1970, 00:00:00 by Wolwen »

hailstone

  • GAE Team
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
(No subject)
« Reply #10 on: 7 April 2007, 06:13:34 »
What about two values for line of sight? One for commander and one for unit.
« Last Edit: 1 January 1970, 00:00:00 by hailstone »
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

Pug

  • Guest
(No subject)
« Reply #11 on: 7 April 2007, 14:13:29 »
Wolwen, I concede, I've watched you post before, and you are not a foolish person. But somewhere here we have a disconnect and I'm really not understanding where.


Somewhere we are fundamentally making different assumptions about what the line of sight is.

Assumption A) The unit's line-of-sight is the range of things that unit 'X' can see and react to. If he can see an enemy unit, he can react to it , if he can't see it, he can't react to it.

Assumption B) the area not covered by fog-of-war is the sum total of the line-of-sight of all units. The player, as our 'commander', gets to see the total of all the things his or her units can see individually. It may be implemented as an overlay, but what it's actually supposed to be showing is the sum total of all information the units have.

I'm calling these assumptions, but they match the definition of line-of-sight and fog-of-war in every RTS or wargame I've ever played, computerized or tabletop.

By definition, an enemy unit covered by the fog-of-war is not in the line-of-sight of any friendly units. It's not that your units can see it, but you can't, it's that your units can not see it.

Therefore, if your unit attacks a unit that is covered by the fog-of-war, then your unit is reacting to a unit it should not be able to detect. It is 'seeing' a unit it cannot by definition see.

In this case, the problem is that a unit 'sees' every unit within the range of any attack it has, regardless of whether it or any allied unit should be able to detect it under the definition of line-of-sight or fog-of-war.

Either this is a bug, or your definition of line-of-sight and fog-of-war is at odds with every wargame RTS I've ever seen, from Avalon hill to World of Warcraft.

You seem determined that this is not a bug but is a feature somehow. But if you're going to try to insist this isn't a bug, you're going to have to explain how those definitions of line-of-sight and fog-of-war are wrong. Because as far as *I* am concerned, units shooting enemy units they can't see is a bug, and anything about how units can see things the commander can't see or anything like that is just a really weird point-of-view I've never heard proclaimed before.

I respect your opinion, but please read this all the way through and explain how my definitions of line-of-sight and fog-of-war are wrong before you insist this isn't a bug. Not that the fog-of-war is just an overlay implemented by the GUI - we all know that, but saying it's not a bug because the fog-of-war is just a gui overlay is saying it's not a bug because that's the way the program is coded - by that definition there's no such thing as a bug, because it's always the way the program is coded.

Pug
« Last Edit: 1 January 1970, 00:00:00 by Pug »

Wolwen

  • Guest
(No subject)
« Reply #12 on: 7 April 2007, 14:49:20 »
i'm not saying it is not a bug, nor it's a feature, i'm saying that the way the actual engine is coded doesn't support any solution to this exept those i presented before.
« Last Edit: 1 January 1970, 00:00:00 by Wolwen »

Pug

  • Guest
(No subject)
« Reply #13 on: 8 April 2007, 11:11:20 »
Quote from: "Wolwen"
i'm not saying it is not a bug, nor it's a feature, i'm saying that the way the actual engine is coded doesn't support any solution to this exept those i presented before.


To be honest, I just don't know how to respond to that.

It's a bug. Moreover, it is a bug that limits the functionality and expandability of the game.

Therefore it would seem logical upon seeing a forum concisely labeled "Bug Report" to post the information there. I'm not saying I would expect it to be fixed in the next five minutes, or even the next revision, but the response "That's the way the engine is coded, can't be fixed" is, well, odd.

Oh well - it has the potential to be a really cool game, but I'm rapidly hitting my point of diminishing returns  in terms of putting energy into it. I've got other stuff I can be doing.

Pug
« Last Edit: 1 January 1970, 00:00:00 by Pug »

hailstone

  • GAE Team
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
(No subject)
« Reply #14 on: 9 April 2007, 13:48:10 »
In world.cpp:
Code: [Select]
//computes the fog of war texture, contained in the minimap
void World::computeFow(){
...
//fire
for(int i=0; i<getFactionCount(); ++i){
for(int j=0; j<getFaction(i)->getUnitCount(); ++j){
Unit *unit= getFaction(i)->getUnit(j);

//fire
ParticleSystem *fire= unit->getFire();
if(fire!=NULL){
fire->setActive(map.getSurfaceCell(Map::toSurfCoords(unit->getPos()))->isVisible(thisTeamIndex));
}
}
}
...

If it's not to do with that it would be something that needs to be changed in that file or unit_updater.cpp:
Code: [Select]
// ==================== updateAttack ====================

void UnitUpdater::updateAttack(Unit *unit){

Command *command= unit->getCurrCommand();
    const AttackCommandType *act= static_cast<const AttackCommandType*>(command->getCommandType());
Unit *target= NULL;

//if found
    if(attackableOnRange(unit, &target, act->getAttackSkillType())){
if(unit->getEp()>=act->getAttackSkillType()->getEpCost()){
unit->setCurrSkill(act->getAttackSkillType());
unit->setTarget(target);
}
else{
unit->setCurrSkill(scStop);
}
    }
    else{
//compute target pos
Vec2i pos;
if(command->getUnit()!=NULL){
pos= command->getUnit()->getCenteredPos();
}
else if(attackableOnSight(unit, &target, act->getAttackSkillType())){
pos= target->getPos();
}
else{
pos= command->getPos();
}

//if unit arrives destPos order has ended
        switch (pathFinder.findPath(unit, pos)){
        case PathFinder::tsOnTheWay:
            unit->setCurrSkill(act->getMoveSkillType());
            break;  
case PathFinder::tsBlocked:
if(unit->getPath()->isBlocked()){
unit->finishCommand();
}
break;
default:
unit->finishCommand();
}
    }
}
« Last Edit: 1 January 1970, 00:00:00 by hailstone »
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/