Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Entropy Amplifier AI Bugs  (Read 360 times)

SafariJohn

  • Admiral
  • *****
  • Posts: 3023
    • View Profile
Entropy Amplifier AI Bugs
« on: October 05, 2022, 06:36:11 AM »

I did a copy of Entropy Amplifier with doubled range and the entropyamplifier AI seemed to think it still had vanilla range. It would not use it even though it was well within range. If I am right, this would also happen with vanilla EA when used with System Expertise.

Other bug is, if the player ship is on autopilot, Entropy Amplifier will frequently target fighters over bigger ships.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24126
    • View Profile
Re: Entropy Amplifier AI Bugs
« Reply #1 on: October 05, 2022, 08:25:00 AM »

Ah, sorry - that system's AI is kinda hardcoded, using this method from EntropyAmplifierStats:

public static float getMaxRange(ShipAPI ship) {
   return ship.getMutableStats().getSystemRangeBonus().computeEffective(RANGE);
}


Are you sure about the "targeting fighters" bit? I'm not seeing it, and in the code it explicitly checks that the target is not a fighter.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3023
    • View Profile
Re: Entropy Amplifier AI Bugs
« Reply #2 on: October 05, 2022, 11:27:15 AM »

Are you sure about the "targeting fighters" bit? I'm not seeing it, and in the code it explicitly checks that the target is not a fighter.

Maybe that was just my naive substitute AI - line 149 of EntropyAmplifierStats was causing it to target fighters. I switched HullSize to FRIGATE in my script which fixed that.
Code: java
target = Misc.findClosestShipEnemyOf(ship, ship.getMouseTarget(), HullSize.FIGHTER, range, true);


Ah, sorry - that system's AI is kinda hardcoded, using this method from EntropyAmplifierStats:

public static float getMaxRange(ShipAPI ship) {
   return ship.getMutableStats().getSystemRangeBonus().computeEffective(RANGE);
}

I can't imagine it calls EntropyAmplifierStats' method instead of the system's script's method. My script is the same except RANGE = 3000, yet the AI did not take advantage of the extra range.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24126
    • View Profile
Re: Entropy Amplifier AI Bugs
« Reply #3 on: October 05, 2022, 11:40:11 AM »

I can't imagine it calls EntropyAmplifierStats' method instead of the system's script's method.

That's exactly what it does. It's a static method so it's not like it's being provided by an interface that the stats script implements and that the AI would know to call. (That's probably how it *ought* to be implemented if it was intended to be more generally useful, but alas. I think some other system AI's - the mine one comes to mind? - do work that way, though...)
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3023
    • View Profile
Re: Entropy Amplifier AI Bugs
« Reply #4 on: October 05, 2022, 11:52:18 AM »

blargh, was rushing through stuff to do an alpha release and didn't notice that was a static method. Guess I could have answered most of this myself by taking a little more time.

For your entertainment, here is the AI script I whipped up. Peak artificial intelligence:

Spoiler
Code: java
public class Roider_SystemSpammerAI implements ShipSystemAIScript {
    private ShipAPI ship;
    private ShipSystemAPI system;
    private ShipSystemStatsScriptAdvanced script;

    private IntervalUtil interval;

    @Override
    public void init(ShipAPI ship, ShipSystemAPI system, ShipwideAIFlags flags, CombatEngineAPI engine) {
        this.ship = ship;
        this.system = system;
        this.script = (ShipSystemStatsScriptAdvanced) system.getSpecAPI().getStatsScript();

        interval = new IntervalUtil(0.08f, 0.12f);
    }

    @Override
    public void advance(float amount, Vector2f missileDangerDir, Vector2f collisionDangerDir, ShipAPI target) {
        interval.advance(amount);

        if (interval.intervalElapsed()) {
            if (!ship.isAlive()) return;

            if (system.getState() == ShipSystemAPI.SystemState.IDLE
                        && script.isUsable(system, ship)) {
                ship.useSystem();
            }
        }
    }

}
[close]
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24126
    • View Profile
Re: Entropy Amplifier AI Bugs
« Reply #5 on: October 05, 2022, 12:01:32 PM »

Hahah, nice.

"Our top-level AI guarantees maximum system uptime!!!"
Logged