Page 1 of 1

Custom AI

Posted: Mon Nov 20, 2006 8:24 am
by johnsmith
I'm working on a revised AI based on pirateAI.plist. In shipdata.plist I have the correct custom ai_type set, but whenever I come across these ships in space, their AI is pirateAI.plist, not my custom AI. Is that becuse they switch to other AIs like enteringPirateAI.plist, and then forget to return to the custom AI?

Second question is is there a way to refine attack modes? I'm thinking along the lines of:

Code: Select all

 <key>ATTACK_SHIP</key>
	<dict>
		<key>ENERGY_LOW</key>
		<array>
			<string>setStateTo: FLEE</string>
		</array>
		<key>ENTER</key>
		<array>
                <string>performAttack</string>
                <string>setSpeedFactorTo:1.5</string>
                <string>setDesiredRangeTo: 500.0</string>
                <string>setSpeedFactorTo:1</string>
                <string>rollD: 2</string>
                <string>ROLL_1= performAttack</string>
                <string>ROLL_2= setDestinationWithinTarget</string>
	</array>
		<key>ENTER WORMHOLE</key>
		<array>
			<string>setStateTo: ENTER_WORMHOLE</string>
		</array>
		<key>EXIT</key>
		<array/>
		<key>INCOMING_MISSILE</key>
		<array>
			<string>fightOrFleeMissile</string>
		</array>
		<key>TARGET_DESTROYED</key>
		<array>
			<string>setStateTo: COLLECT_LOOT</string>
		</array>
		<key>TARGET_LOST</key>
		<array>
			<string>setStateTo: COLLECT_LOOT</string>
		</array>
		<key>UPDATE</key>
		<array/>
	</dict>

This is meant to have the attack come in fast, slow to normal speed when close, then ram the target 50% of the time. Will it work?

Posted: Mon Nov 20, 2006 12:59 pm
by LittleBear
One the first one, once AI is switched (with a switchAIto) - pirate AI contains a few of these, yeah Oolite forgets the Custom AI and the ship becomes a trader in terms of behaviour (or wherever the AI was switched to).

Not sure about the setdestination within target bit. However, a switch to missileAI would work (although the ship could be ECMed!). If therefore you did a set state to CRASH, then define crash by copying in missileAI, but taking out the ECM=, that should do it.

Posted: Mon Nov 20, 2006 5:47 pm
by TGHC
I would think The Constrictor AI is similar to what you are trying to achieve, or possibly the Imperial Courier.

Posted: Mon Nov 20, 2006 11:07 pm
by johnsmith
Thanks for the tips guys. I ended up renaming the AI and clearing the cache, and it now does its thing. Can't get the tactics quite right yet, but it's getting there. Got rid of all the switchAIto stuff, so it remembers who it is.

I found some randomisation stuff in the hardMissileAI, which I'll try to incorporate so it doesn't get too predictable.

Couple of keywords I don't understand. Frustrated, and performTumble. Does anyone use these, and for what?

Constrictor didn't have it's own AI, it used pirateAI. Which is why it was so dissapointing to kill. Not sure about the Courier.

Posted: Tue Nov 21, 2006 4:44 am
by LittleBear
Not sure about "frustrated", but performtumble tells the ship just to wait where it is rolling left and right until a condition is met.

Posted: Tue Nov 21, 2006 4:53 am
by Judebert
Somewhere in the docs (we have got to reorganize that stuff; might have been a man page or AI comment) it says that FRUSTRATED happens when the AI has been trying to scoop something for more than 10 seconds.