Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2   Go Down

Author Topic: Limit the "vision" of AI?  (Read 1206 times)

0 Members and 1 Guest are viewing this topic.

Wing Walker

  • member
  • Offline Offline
  • Posts: 298
Limit the "vision" of AI?
« on: April 22, 2023, 12:18:55 PM »

Is there a way to limit the "vision" of enemy AI aircraft to a shorter range?

I like big dogfights.

But the challenge is you have no idea who is who until you make a pass at them, or see them shoot.

Meanwhile the enemy A/C know you are enemy so far out you only see a little speck.

Would be nice to be able to change their reaction to something more real.

Logged

FL2070

  • Modder
  • member
  • Offline Offline
  • Posts: 1194
  • FAC #87
Re: Limit the "vision" of AI?
« Reply #1 on: April 22, 2023, 12:24:47 PM »

Ah, if only... the AI has been chasing the player across the map, tens of kilometers out of sight, for the past twenty years... if a mod could be made that fixes that, I would declare its creator the greatest IL-2 modder of all time.
Logged
On average, the average average averages, averagely, the average average of all averages.

Mick

  • Modder
  • member
  • Offline Offline
  • Posts: 5335
Re: Limit the "vision" of AI?
« Reply #2 on: April 22, 2023, 03:09:44 PM »

... and not only that, but smart AI can also see through clouds and at night ...  :-[ :-X
Logged

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 5713
Re: Limit the "vision" of AI?
« Reply #3 on: April 23, 2023, 04:53:04 PM »

In VisCheck.class we have the following, which is a basic first check on detectability at a distance. It's further modified by other factors.

Code: [Select]
    private static boolean commonCheck(Aircraft aircraft, Aircraft aircraft1, float f, float f1, float f2, float f3, float f4)
    {
        dist = (float)aircraft.pos.getAbsPoint().distance(aircraft1.pos.getAbsPoint());
        float f5 = aircraft1.FM.Wingspan / 2.0F;
        float f6 = (float)Math.atan2(f5, dist) / f5;
        if(f6 < 0.00015F)
            return false;

Assuming the threshold of 0.00015 is radians, that's 0.5 arcminute, or 1 arcminute (1/60 degree). It's a reasonable value for detecting a dark object against a light background when the contrast is sufficiently high.

If we wanted to apply a tighter constraint on detection distance across the board, we might start here by increasing the threshold value. For instance, doubling to 0.0003 would halve the basic detection distance. Of course, this should be carefully considered in conjunction with other visibility factors.

But what we really want to examine is the distance at which the AI can distinguish foe from friend. I'll see what I can find...
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 5713
Re: Limit the "vision" of AI?
« Reply #4 on: April 23, 2023, 05:21:39 PM »

In the same class, for the following method variable "f" is the AI skill. Note how it's used to increment variable envLighting by 150 for each step in AI skill, on this line:

        envLighting += f * 150F;

I interpret envLighting as a measure of how well a plane can be seen, sort of a surrogate for contrast.

Note also how Main.cur().dotRangeFoe.dot() is used separately for calculating envLighting under the conditions of Sun and Moon lighting. This suggests a role is played by the dot range parameter?

Code: [Select]
    private static boolean checkAmbientPos(Point3d point3d, Point3d point3d1, Aircraft aircraft, Actor actor, float f, boolean flag)
    {
        envLighting = com.maddox.il2.ai.World.Sun().lightAtAlt((float)point3d1.z);
        float f1 = (float)(point3d.z * -1.2960000276507344E-005D);
        tmpVGr2.set(tmpVGr1);
        tmpVGr2.normalize();
        if(tmpVGr2.z >= (double)f1)
            envLighting += 0.05F;
        if(com.maddox.il2.ai.World.Sun().ToSun.z > 0.0F)
        {
            envLighting *= 0.7F * (float)Main.cur().dotRangeFoe.dot();
            return (double)envLighting > tmpVGr1.length();
        }
        boolean flag1 = false;
        Aircraft aircraft1 = null;
        if(actor instanceof Aircraft)
            aircraft1 = (Aircraft)actor;
        if(aircraft1 != null && (aircraft1.FM.CT.bAntiColLights || aircraft1.FM.AS.bLandingLightOn || aircraft1.FM.AS.bNavLightsOn || aircraft1.FM.AS.astateTankStates[0] > 4 || aircraft1.FM.AS.astateTankStates[1] > 4 || aircraft1.FM.AS.astateTankStates[2] > 4 || aircraft1.FM.AS.astateTankStates[3] > 4 || isShooting(aircraft1) || aircraft1.FM.AS.astateEngineStates[0] > 3 || aircraft1.FM.AS.astateEngineStates[1] > 3 || aircraft1.FM.AS.astateEngineStates[2] > 3 || aircraft1.FM.AS.astateEngineStates[3] > 3 || aircraft1.tmSearchlighted != 0L && Time.current() - aircraft1.tmSearchlighted < 1000L))
        {
            envLighting = 6000F;
            flag1 = true;
        }
        if(!flag1)
        {
            Vmoon.set(com.maddox.il2.ai.World.Sun().ToMoon);
            Vlight.set(com.maddox.il2.ai.World.Sun().ToLight);
            double d = v_1.dot(Vmoon);
            double d1 = v_1.dot(Vlight);
            d = Math.abs(d);
            d1 = Math.abs(d1);
            envLighting *= 2500F;
            if(d > 0.96599999999999997D || d1 > 0.96599999999999997D)
                envLighting = 0.5F * (float)Main.cur().dotRangeFoe.dot();
        }
        envLighting += f * 150F;
        if(flag)
        {
            if(Mission.isSingle() && aircraft != null && aircraft1 != null && (aircraft1.FM instanceof Maneuver) && (aircraft.FM instanceof Maneuver))
            {
                AirGroup airgroup = ((Maneuver)aircraft1.FM).Group;
                AirGroup airgroup1 = ((Maneuver)aircraft.FM).Group;
                if(airgroup1 != null && airgroup != null && !AirGroupList.groupInList(airgroup1.enemies[0], airgroup))
                    envLighting *= 0.5F;
            }
            return (double)World.Rnd().nextFloat(0.0F, envLighting) > tmpVGr1.length();
        } else
        {
            return (double)envLighting > tmpVGr1.length();
        }
    }


This portion below is interesting, as it suggests to this Java monkey that if both aircraft are maneuvering, the envLighting value is halved, which impacts the visibility distance threshold.

Code: [Select]
        if(flag)
        {
            if(Mission.isSingle() && aircraft != null && aircraft1 != null && (aircraft1.FM instanceof Maneuver) && (aircraft.FM instanceof Maneuver))
            {
                AirGroup airgroup = ((Maneuver)aircraft1.FM).Group;
                AirGroup airgroup1 = ((Maneuver)aircraft.FM).Group;
                if(airgroup1 != null && airgroup != null && !AirGroupList.groupInList(airgroup1.enemies[0], airgroup))
                    envLighting *= 0.5F;
            }
            return (double)World.Rnd().nextFloat(0.0F, envLighting) > tmpVGr1.length();
        } else
        {
            return (double)envLighting > tmpVGr1.length();
        }
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 5713
Re: Limit the "vision" of AI?
« Reply #5 on: April 23, 2023, 08:36:55 PM »

In my first post I was too quick in determining the visibility threshold. For the algorithm as it is, for a plane having a 10m wingspan, the threshold result of 0.00015 corresponds to a distance of about 6.7km. This seems to accord with the point at which one's flight members call out bandits under good conditions in daytime.

It seems to me that this might prove to be a fruitful place to bring down the distance, by increasing the threshold condition. If I can successfully compile an altered class and try it out, I'll be back with a result...
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 5713
Re: Limit the "vision" of AI?
« Reply #6 on: April 23, 2023, 09:01:24 PM »

Well, I increased the threshold value by a factor of 2 (from 0.00015 to 0.0003), and indeed, the distance at which my flight called out the bogies was reduced to the expected nearer distance of about 3-1/3km.

Is this the kind of reduction we would want across the board, as a new baseline? I would expect it to have an impact on the rate of engagements, and would likely have a bad, or at least unintended, impact on existing missions.

In any event, this seems to be an area for exploration for those who would find such changes useful.
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

Mick

  • Modder
  • member
  • Offline Offline
  • Posts: 5335
Re: Limit the "vision" of AI?
« Reply #7 on: April 24, 2023, 03:59:10 AM »

... I certainly am one of those who would find such changes useful ...  ;)

You currently hardly can't compete against AI, simply because they can see at night like in plain day time, can spot you through clouds, never overheat their engine, are impossible to catch up if you are taking off after one of them (unless you engage the "Auto" switch ...) etc ...  :-X
Logged

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 5713
Re: Limit the "vision" of AI?
« Reply #8 on: April 24, 2023, 04:47:34 AM »

In that same VisCheck.class there is a very specific invocation of a method for each of clouds and darkness. I've not examined them in depth, but it seems that there is a check done for the imposition of a cloud. As for nighttime, it takes the Sun's elevation into account, and my own impression during play is that indeed as twilight deepens the AI ability to see does deteriorate.
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

Frankiek

  • SAS Team
  • member
  • Offline Offline
  • Posts: 2448
Re: Limit the "vision" of AI?
« Reply #9 on: April 24, 2023, 05:22:02 AM »

In the old days of 409 and 410 we had AI tweaking that reduced AI capacity to see through clouds and at night, no sniper gunners,  engines suffered from overheating and other things it seems to me that this work came to a stop when the new AI from TD 4.12 was introduced and all these mods become incompatible. We could maybe revisit these codes and verify if there is something that could be  used/adapted 
Logged

Mick

  • Modder
  • member
  • Offline Offline
  • Posts: 5335
Re: Limit the "vision" of AI?
« Reply #10 on: April 24, 2023, 07:33:30 AM »

... you're right, I forgot the AI sniper gunners, and AI pilots are aces in the art of deflection shooting too...  :-X

Well, if the situation could be reverted somewhat back, what an improvement this would be ...!  8)
Logged

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23718
  • Taking a timeout
    • STFU
Re: Limit the "vision" of AI?
« Reply #11 on: April 24, 2023, 08:17:43 AM »

Sniper gunners are a 4.10 (and earlier) thing (and have been eliminated in Ultrapack).
"See through clouds" and "see at night" are a 4.11 (and earlier) thing (and have been eliminated in Ultrapack).

This portion below is interesting, as it suggests to this Java monkey that if both aircraft are maneuvering

"aircraft.FM instanceof Maneuver" just tells whether an aircraft is AI (or player on autopilot to the same effect).

]cheers[
Mike
Logged
Don't split your mentality without thinking twice.
Pages: [1] 2   Go Up
 

Page created in 0.048 seconds with 24 queries.