AI Oddity

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

AI Oddity

Post by Thargoid »

I'm just writing some new AIs for WildShips (for a hauler with "escort" fuel sleds) and I've come upon something odd.

I've got the escorts using a custom AI, but when attacked they go to interceptAI.plist from the trunk (rev 5466). However when they exit that sub-AI, they end up in route1PatrolAI.plist rather than back where they should have been wildShips_solarEscortAI.plist.

I'm somewhat confused as to why this is happening, as that AI is not set/switched to in either interceptAI or the main escort custom AI (reproduced below). This AI is wildShips_solarEscortAI.plist, with the mother flying under wildShips_solarAI.plist (which takes them from the main station to the system Kiota solar station and then docks with it).

Can someone test this for me? I can make the updated version of wildShips available if needed, although it's still a WIP.

Code: Select all

{
	GLOBAL =
		{
		ENTER = ("setStateTo: BEGIN_BUSINESS");
		};
	
	"BEGIN_BUSINESS" =
		{
		"LAUNCHED OKAY" = ("setStateTo: CLEAR_STATION");
		ESCORTING = ("setDesiredRangeTo: 0.0", "setStateTo: FLYING_ESCORT");
		"NOT_ESCORTING" = ("switchAITo: wildShips_solarAI.plist");
		"ATTACKED" = (setTargetToPrimaryAggressor, "setStateTo: UNDER_ATTACK");
		"ATTACKER_MISSED" = (setTargetToPrimaryAggressor, "messageMother: ATTACKER_MISSED", "setStateTo: UNDER_ATTACK");
        "ATTACKED_BY_CLOAKED" = ("messageMother: ATTACKED_BY_CLOAKED"); 
		UPDATE = (escortCheckMother, "pauseAI: 7.5");
		};
	
	"CLEAR_STATION" = 
		{
		ENTER = (
			getWitchspaceEntryCoordinates, 
			setDestinationFromCoordinates, 
			"setDesiredRangeTo: 5000.0", 
			"setSpeedFactorTo: 0.50", 
			performFlyToRangeFromDestination,
			escortCheckMother
		);
		"DESIRED_RANGE_ACHIEVED" = ("setStateTo: LOOK_FOR_BUSINESS");
		"TARGET_FOUND" = (setTargetToFoundTarget, suggestEscort, "pauseAI: 1.0");
  		ESCORTING = ("setDesiredRangeTo: 0.0", "setStateTo: FLYING_ESCORT");
		"NOT_ESCORTING" = (scanForFormationLeader);
		"NOTHING_FOUND" = ("setSpeedFactorTo: 0.50", performFlyToRangeFromDestination);
		"ATTACKED" = (setTargetToPrimaryAggressor, "setStateTo: UNDER_ATTACK");
		"ATTACKER_MISSED" = (setTargetToPrimaryAggressor, "messageMother: ATTACKER_MISSED", "setStateTo: UNDER_ATTACK");
        "ATTACKED_BY_CLOAKED" = ("messageMother: ATTACKED_BY_CLOAKED"); 
		UPDATE = ("pauseAI: 15.0");
		};
	
	"LOOK_FOR_BUSINESS" =
		{
		ENTER = (scanForFormationLeader);
		RESTARTED = ("setStateTo: BEGIN_BUSINESS");
		"LAUNCHED OKAY" = ("setStateTo: CLEAR_STATION");
		"CASCADE_WEAPON_DETECTED" = ("setAITo: fleeQMineAI.plist");
		ESCORTING = ("setDesiredRangeTo: 0.0", "setStateTo: FLYING_ESCORT");
		"NOT_ESCORTING" = ("switchAITo: wildShips_solarAI.plist");
		"TARGET_FOUND" = (setTargetToFoundTarget, suggestEscort);
		"NOTHING_FOUND" = ("switchAITo: wildShips_solarAI.plist");
		"FRUSTRATED" = ("switchAITo: wildShips_solarAI.plist");
		"ATTACKED" = (setTargetToPrimaryAggressor, "setStateTo: UNDER_ATTACK");
		"ATTACKER_MISSED" = (setTargetToPrimaryAggressor, "messageMother: ATTACKER_MISSED", "setStateTo: UNDER_ATTACK");
        "ATTACKED_BY_CLOAKED" = ("messageMother: ATTACKED_BY_CLOAKED"); 
		UPDATE = ("pauseAI: 7.5", scanForFormationLeader);
		};
	
	"FLYING_ESCORT" =
		{
		ENTER = (performEscort);
		RESTARTED = ("setStateTo: FLYING_ESCORT");
		"GROUP_ATTACK_TARGET" = (setTargetToFoundTarget, "setAITo: interceptAI.plist");
		ESCORTING = ("setDesiredRangeTo: 0.0", performEscort);
		"INCOMING_MISSILE" = ("messageMother: INCOMING_MISSILE");
		"CASCADE_WEAPON_DETECTED" = ("setAITo: fleeQMineAI.plist");
		"ATTACKED" = (setTargetToPrimaryAggressor, "setStateTo: UNDER_ATTACK");
		"ATTACKER_MISSED" = (setTargetToPrimaryAggressor, "messageMother: ATTACKER_MISSED", "setStateTo: UNDER_ATTACK");
        "ATTACKED_BY_CLOAKED" = ("messageMother: ATTACKED_BY_CLOAKED"); 
		"NOT_ESCORTING" = ("setStateTo: LOOK_FOR_BUSINESS");
		"TARGET_LOST" = ("setStateTo: LOOK_FOR_BUSINESS");
		"TARGET_DESTROYED" = ("setStateTo: LOOK_FOR_BUSINESS");
		UPDATE = (escortCheckMother, "pauseAI: 15");
		};
		
	"UNDER_ATTACK" = 
		{
		ENTER = ("messageMother: ATTACKED", "messageMother: ESCORT_ATTACKED", "setSpeedFactorTo: 0.0", performIdle);
		"TARGET_DESTROYED" = (escortCheckMother); 
		"TARGET_LOST" = (escortCheckMother);
		ESCORTING = ("setDesiredRangeTo: 0.0", "setStateTo: FLYING_ESCORT");
		"NOT_ESCORTING" = ("setStateTo: LOOK_FOR_BUSINESS");
		EXIT = ("setSpeedFactorTo: 1.0");
		};
}
[/color]
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: AI Oddity

Post by Eric Walch »

I'm somewhat confused as to why this is happening, as that AI is not set/switched to in either interceptAI or the main escort custom AI (reproduced below).
It is, but you just did not notice because it is not happening in your AI. :D The AI of mom does the trick. It is her command deployEscorts. Escorts should be dumb and should not take decisions on their own. Mom has the big picture between ships and should instruct whou can attack and who not. :D

That does not explain why they return to the wrong AI.
Last edited by Eric Walch on Fri Nov 02, 2012 9:18 pm, edited 1 time in total.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: AI Oddity

Post by Thargoid »

For completeness, this is the mother AI (wildShips_solarAI.plist).

There is no explicit deployEscorts command as this is set up as a hauler fleet, not a normal escort scenario. The fuel sleds are unarmed, and just designed to follow mum to the solar station (or from it to the main station).

Editted to add - I see a deployEscorts in traderInterceptAI.plist, but I still can't see any reason why the escorts end up in route1PatrolAI.plist?

Code: Select all

{
	GLOBAL =
	{
		ENTER = ("setStateTo: CLEAR_STATION");
	};

	"CLEAR_STATION" = {
		ENTER = (
			getWitchspaceEntryCoordinates, 
			setDestinationFromCoordinates, 
			"setDesiredRangeTo: 5000.0", 
			"setSpeedFactorTo: 0.50", 
			performFlyToRangeFromDestination
		);
        "ESCORT_ATTACKED" = (setTargetToPrimaryAggressor, groupAttackTarget);
		"GROUP_ATTACK_TARGET" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		"DESIRED_RANGE_ACHIEVED" = ("setStateTo: HEAD_FOR_SUN");
		UPDATE = ("pauseAI: 15.0");
		};
	
	"HEAD_FOR_SUN" = {
		ENTER = ("setCoordinates: sps 0 0 2.4", setDestinationFromCoordinates, checkCourseToDestination);
		"COURSE_OK" = ("setSpeedFactorTo: 1.0", checkAegis, "setDesiredRangeTo: 15000.0", performFlyToRangeFromDestination);
		"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
		"CLOSE_TO_SUN" = ("setStateTo: FIND_STATION");
		"DESIRED_RANGE_ACHIEVED" = ("setStateTo: FIND_STATION");
        "ESCORT_ATTACKED" = (setTargetToPrimaryAggressor, groupAttackTarget);
		ATTACKED = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		"GROUP_ATTACK_TARGET" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		"ATTACKER_MISSED" = (fightOrFleeHostiles, fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		FIGHTING = (setTargetToPrimaryAggressor, "setAITo: traderInterceptAI.plist");
		FLEEING = (setTargetToPrimaryAggressor, "setStateTo: FLEE_WITH_ESCORTS");
        "ATTACKED_BY_CLOAKED" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist", "setStateTo: FLEE_FOR_CLOAKED"); 
		"INCOMING_MISSILE" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist", "setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.5 2.0");
		"CASCADE_WEAPON_DETECTED" = ("setAITo: fleeQMineAI.plist");
        "EXITED WITCHSPACE" = ("switchAITo: route1traderAI.plist"); 
		"RESTARTED" = ("setCoordinates: sps 0 0 2.4", setDestinationFromCoordinates, checkCourseToDestination);
		UPDATE = ("setCoordinates: sps 0 0 2.4", setDestinationFromCoordinates, checkCourseToDestination, "pauseAI: 10.0");
	};
	
	"FLEE_FOR_CLOAKED" = {
        ENTER = (storeTarget,
			setDestinationToJinkPosition,
			"setDesiredRangeTo: 25600",
			performFlyToRangeFromDestination,
			"setSpeedFactorTo: 7"
		); 
        "DESIRED_RANGE_ACHIEVED" = ("setStateTo: HEAD_FOR_SUN"); 
        "INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE_WITH_ESCORTS"); 
		"CASCADE_WEAPON_DETECTED" = ("setAITo: fleeQMineAI.plist");
		"GROUP_ATTACK_TARGET" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		ATTACKED = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist"); 
        "ATTACKED_BY_CLOAKED" = (setDestinationToJinkPosition); 
        "TARGET_FOUND" = (setTargetToFoundTarget, fightOrFleeHostiles); 
        "ESCORT_ATTACKED" = (setTargetToPrimaryAggressor, groupAttackTarget);
		FIGHTING = (setTargetToPrimaryAggressor, fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		FLEEING = (setTargetToPrimaryAggressor, "setStateTo: FLEE_WITH_ESCORTS");
		DEPLOYING_ESCORTS = (setTargetToPrimaryAggressor, "setStateTo: FLEE_WITH_ESCORTS");
		RESTARTED = ("setStateTo: HEAD_FOR_SUN");
		UPDATE = (recallStoredTarget, "pauseAI: 2.0");
    }; 
		
	"FLEE_WITH_ESCORTS" = {
		ENTER = ("setDesiredRangeTo: 25600", performFlee); 
		ATTACKED = (scanForHostiles); 
		"TARGET_FOUND" = (setTargetToPrimaryAggressor, "rollD: 3");
		"ROLL_1" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		"ROLL_2" = ("setDesiredRangeTo: 25600", performFlee);
		"ROLL_3" = ("setDesiredRangeTo: 25600", performFlee);
		"GROUP_ATTACK_TARGET" = (scanForHostiles);
        "ESCORT_ATTACKED" = (setTargetToPrimaryAggressor, groupAttackTarget);
        "TARGET_CLOAKED" = ("setStateTo: FLEE_FOR_CLOAKED");
		"TARGET_LOST" = (performIdle, "setStateTo: HEAD_FOR_SUN"); 
		"TARGET_DESTROYED" = (performIdle, "setStateTo: HEAD_FOR_SUN"); 
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.25 0.75"); 
		"CASCADE_WEAPON_DETECTED" = ("setAITo: fleeQMineAI.plist");
		"REACHED_SAFETY" = (performIdle, "setStateTo: HEAD_FOR_SUN"); 
	}; 
	
	"FIND_STATION" = {
		ENTER = ("scanForNearestShipWithRole: wildShips_solar");
		TARGET_FOUND = (setTargetToFoundTarget, dockEscorts, "setAITo: dockingAI.plist");
		NOTHING_FOUND = ("setStateTo: HUNT_FOR_STATION"); 
        "ESCORT_ATTACKED" = (setTargetToPrimaryAggressor, groupAttackTarget);
		"GROUP_ATTACK_TARGET" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		ATTACKED = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		"ATTACKER_MISSED" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		FIGHTING = (setTargetToPrimaryAggressor, fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		FLEEING = (setTargetToPrimaryAggressor, "setStateTo: FLEE_WITH_ESCORTS");
        "ATTACKED_BY_CLOAKED" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist", "setStateTo: FLEE_FOR_CLOAKED"); 
		"INCOMING_MISSILE" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist", "setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.5 2.0");
		"CASCADE_WEAPON_DETECTED" = ("setAITo: fleeQMineAI.plist");
		"RESTARTED" = ("scanForNearestShipWithRole: wildShips_solar");
	};
	
	"HUNT_FOR_STATION" = {
		ENTER = ("setSpeedFactorTo: 0.5", "targetFirstBeaconWithCode: Kiota Solar Station");
		TARGET_FOUND = (setTargetToFoundTarget, "setStateTo: APPROACH_STATION");
		NOTHING_FOUND = (setTargetToNearestStation, "setStateTo: APPROACH_STATION"); 
        "ESCORT_ATTACKED" = (setTargetToPrimaryAggressor, groupAttackTarget);
		"GROUP_ATTACK_TARGET" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		ATTACKED = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		"ATTACKER_MISSED" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		FIGHTING = (setTargetToPrimaryAggressor, fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		FLEEING = (setTargetToPrimaryAggressor, "setStateTo: FLEE_WITH_ESCORTS");
        "ATTACKED_BY_CLOAKED" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist", "setStateTo: FLEE_FOR_CLOAKED"); 
		"INCOMING_MISSILE" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist", "setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.5 2.0");
		"CASCADE_WEAPON_DETECTED" = ("setAITo: fleeQMineAI.plist");
		"RESTARTED" = ("setSpeedFactorTo: 0.5", "targetFirstBeaconWithCode: Kiota Solar Station");
	};
	
	"APPROACH_STATION" = {
		ENTER = ("setSpeedFactorTo: 0.5", setDestinationToTarget, "setDesiredRangeTo: 10000");
		"DESIRED_RANGE_ACHIEVED" = (dockEscorts, "setAITo: dockingAI.plist");
	    "ESCORT_ATTACKED" = (setTargetToPrimaryAggressor, groupAttackTarget);
		"GROUP_ATTACK_TARGET" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		ATTACKED = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		"ATTACKER_MISSED" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		FIGHTING = (setTargetToPrimaryAggressor, fightOrFleeHostiles, "setAITo: traderInterceptAI.plist");
		FLEEING = (setTargetToPrimaryAggressor, "setStateTo: FLEE_WITH_ESCORTS");
        "ATTACKED_BY_CLOAKED" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist", "setStateTo: FLEE_FOR_CLOAKED"); 
		"INCOMING_MISSILE" = (fightOrFleeHostiles, "setAITo: traderInterceptAI.plist", "setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.5 2.0");
		"CASCADE_WEAPON_DETECTED" = ("setAITo: fleeQMineAI.plist");
		UPDATE = ("setDesiredRangeTo: 10000", "pauseAI: 5.0");
		"RESTARTED" = ("setSpeedFactorTo: 0.5", "setStateTo: FIND_STATION");
	};
}
[/color]
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: AI Oddity

Post by Eric Walch »

Thargoid wrote:
There is no explicit deployEscorts command as this is set up as a hauler fleet,
Not directly but deployEscorts is also part of the fightOrFleeHostiles command. I think that deployEscorts was originally not intended to be an AI command of its own, seeing its location in the code.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: AI Oddity

Post by Thargoid »

Eric Walch wrote:
Thargoid wrote:
There is no explicit deployEscorts command as this is set up as a hauler fleet,
Not directly but deployEscorts is also part of the fightOrFleeHostiles command. I think that deployEscorts was originally not intended to be an AI command of its own, seeing its location in the code.
OK - as noted above it is also explicitly in traderInterceptAI.plist which the mother uses for attacking (as per the equivalent trunk AIs). However I still can't see any reason why the escorts end up in route1PatrolAI.plist.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: AI Oddity

Post by Eric Walch »

Me neither. This is one of the cases were you need the AI logging with reportAIMessages.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: AI Oddity

Post by cim »

Possible guesses:
- escorts are getting set to escortAI.plist somewhere (if launched from a station as an escort ship, or through the auto_ai map?) and then failing to find a formation leader, which sets them to route1patrol
- escorts have role "wingman" and get set to route1patrol automatically if they can't find a formation leader
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: AI Oddity

Post by Thargoid »

OK found it. Due to a script typo it was ending up in escortAI.plist rather than the custom one. Hence at various points it ended up taking a "new career" and so onto route1Patrol.

I hate it when that kind of glitch happens... :oops:
Post Reply