Autopilot AI

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

Post Reply
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2278
Joined: Tue Jan 02, 2007 12:38 pm

Autopilot AI

Post by Killer Wolf »

Would it be possible to have an AI for NPCs that would follow a patrol route? what i'm thinking of is a list of waypoints in an array, simply a position using whatever Oolite format (WSP etc) and a speed as a % of the ship's top speed, and a variable to loop or not, so the ship would stop at the end of the list, or be able to fly circuits etc. (Viper patrol around a planet, say).
. this could open stuff up for eye candy ship/mission OXPs ~ you could have ships heading out to a station etc on a path none of the existing AIs incorporate.
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Post by Switeck »

Total Patrol OXP sort-of does that for police Vipers:
http://wiki.alioth.net/index.php/Total_patrol_OXP
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Total patrol is only an extension of the usual police AI, so don't bother with it.

Instead have a look at cataclysm_militaryAI.plist from (you guessed it) Cataclysm.oxp. It is a patrol AI with 12 pre-defined waypoints, which sends ships along the lines between these waypoints, and randomly choose another waypoint to go to whenever they reached their destination. It also allows for them to break up course and attack, if necessary. It's basically exactly what you want. You only have to replace the waypoint co-ordinates with whatever suits you (SHIFT-F in game is your friend here; that's how I determined the co-ordinates in the AI).

Or you could have a look at the AI of the Tionisla Orbital Graveyard patrol ships. I guess it will be similar.
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2278
Joined: Tue Jan 02, 2007 12:38 pm

Post by Killer Wolf »

cheers Cmdr McLane, i'll have a look into that. it's not an immediate priority for me, but i thought it might be a useful thing for people who wanted to script missions, like an "intercept a pirate fleet" or "take a photo of a new secret ship on trials" type thing.
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: Autopilot AI

Post by Eric Walch »

Killer Wolf wrote:
Would it be possible to have an AI for NPCs that would follow a patrol route? what i'm thinking of is a list of waypoints in an array,
There are plenty AI scripts out there doing such things. From the older ones: Tianve.oxp or Tionisla Graveyard.oxp. Both have patrol ships along special routes. In this old stuff the route is hardcoded in the AI. Since 1.74 a JS script can also set coordinates. With JS it becomes possible to calculate coordinates. One example is the control ship in buoy repair.oxp. Its AI starts as:

Code: Select all

	GLOBAL = {
		ENTER = (switchLightsOff, "setStateTo: NEXT_COORDS", "pauseAI: 5.0");
	};
	"NEXT_COORDS" = {
		"APPROACH_COORDINATES" = (setDestinationFromCoordinates, "setStateTo: GO_TO_COORDS", switchLightsOff);
		"END_CONTROL" = ("setStateTo: EXIT_SYSTEM");
		UPDATE = ("sendScriptMessage: nextPosition", "setDesiredRangeTo: 10.0", "setSpeedTo: 0");
	};
	"GO_TO_COORDS" = {
		ENTER = (performFaceDestination);
		"FACING_DESTINATION" = ("setSpeedTo: 60", performFlyToRangeFromDestination);
		"DESIRED_RANGE_ACHIEVED" = (performStop, switchLightsOn, "setStateTo: GET_TARGET");
		"END_CONTROL" = ("setStateTo: EXIT_SYSTEM");
		ATTACKED = (setTargetToPrimaryAggressor, "setAITo: interceptAI.plist");
		RESTARTED = ("setStateTo: EXIT_SYSTEM");
		STOP = (performStop);
		"ENERGY_FULL" = (performFaceDestination);
	};
Its a bit of a copy of Oolites own planetPatrolAI and dockingAI. In "NEXT_COORDS" is a sendScriptMessage that calls a JS function that sets a destination from an array of coordinates. Every call it returns the next position within the array. When a new coordinate is set, the JS script returns APPROACH_COORDINATES to the AI, or when the last coordinate was reached, it returns END_CONTROL.

NB the current release sets coordinates on a more complex way that worked already with 1.72, but the next release will use the easy 1.74 way to set coordinates with JS.
Post Reply