Page 27 of 65
Re: Her Imperial Majesty's Space Navy
Posted: Sat Feb 01, 2014 9:36 am
by Smivs
Gimi wrote:It would be great if someone picks this up. I have some pretty strong views on how the Navy should work and behave, but I don't have the skills to compile the OXP. So if you can, please go for it pleb.
@ Gimi, I hope that you can continue to be involved in this project, if not as 'Project Leader then as 'Executive Consultant' as I feel it is your insight and knowledge that will make this project ultimately successful. Your input should make it feel more authentic, and I hope that (time permitting) you can continue to play a leading role.
Gimi wrote:
There are quite a few who have offered to contribute. I do believe that Griff gave me permission to use his models.
Originally, Griff and Smivs versions were suggested, or a weird hybrid of both styles perhaps, but events have moved on since then - the 'core' ships are scheduled for replacement with the Griff/Solo set, and it might therefore make more sense to base the HIMSN ships on these alone.
This would simplify things a lot, and although the future is hard to predict my feeling is that the replacement shipset market is going to shrink massively when the new default ships come in. With more players using the default ships, the need to accommodate OXP shipsets will reduce, and in any case the Griff/Solo ships are sufficiently close enough in style and appearance to most of the current shipsets they will not look out of place in any Ooniverse.
Re: Her Imperial Majesty's Space Navy
Posted: Sat Feb 01, 2014 11:11 am
by cim
Gimi wrote:Navy Sidewinder:
Beam or Military laser
4 hard head missiles.
Military shielding
Extra energy unit
and so on....
That - especially with the Military laser - has firepower and shields superior to a standard Thargoid warship compressed into something the approximate size of two of the warship's drone fighters. You'd have to make the Thargoids significantly more powerful than they are in core to keep them a threat that required such a navy to handle.
Gimi wrote:It's pretty easy to write the rules in plain language, but I imagine implementing them is pretty hard.
The discussions regarding AI in this thread were one of the main motivations for developing the new 1.79 AI model.
Very roughly, the CSP could be done as:
Code: Select all
this.aiStarted = function() {
var ai = new worldScripts["oolite-libPriorityAI"].PriorityAIController(this.ship);
ai.setCommunicationsRole("himsn-csp"); // lets them have their own comms chatter
ai.setWaypointGenerator(
this.waypointsHomeBasePatrol // non-standard
);
ai.setPriorities([
{
condition: ai.conditionLosingCombat,
behaviour: ai.behaviourFleeCombat,
reconsider: 5
},
{
condition: ai.conditionInCombat,
configuration: ai.configurationAcquireCombatTarget,
behaviour: ai.behaviourDestroyCurrentTarget,
reconsider: 5
},
{
preconfiguration: ai.configurationCheckScanner,
condition: this.conditionScannerContainsAttackerOfGuardedShip, // non-standard
configuration: ai.configurationAcquireScannedTarget,
behaviour: ai.behaviourDestroyCurrentTarget,
reconsider: 5
},
{
condition: this.conditionScannerContainsHostileIntruder, // non-standard
configuration: ai.configurationAcquireScannedTarget,
behaviour: ai.behaviourDestroyCurrentTarget,
reconsider: 10
},
{
condition: this.conditionScannerContainsFriendlyIntruder, // non-standard
truebranch: [
{
condition: this.conditionPatrolIsGuardingScannedTarget, // non-standard
configuration: ai.configurationAcquireScannedTarget,
behaviour: ai.behaviourGuardTarget,
reconsider: 10
},
{
condition: this.conditionPatrolShouldBeGuardingScannedTarget, // non-standard
configuration: this.configurationStartGuardingScannedTarget, // non-standard
behaviour: ai.behaviourGuardTarget,
reconsider: 10
}
]
},
{
condition: this.conditionHomeBaseIntact, // non-standard
truebranch: [
{
condition: ai.conditionHasWaypoint,
configuration: ai.configurationSetDestinationToWaypoint,
behaviour: ai.behaviourApproachDestination,
reconsider: 30
},
{
condition: ai.conditionPatrolIsOver,
truebranch: [
{
condition: ai.conditionHasSelectedStation,
truebranch: [
{
condition: ai.conditionSelectedStationNearby,
configuration: ai.configurationSetSelectedStationForDocking,
behaviour: ai.behaviourDockWithStation,
reconsider: 30
},
{
configuration: ai.configurationSetDestinationToSelectedStation,
behaviour: ai.behaviourApproachDestination,
reconsider: 30
}
]
falsebranch: [
{
configuration: this.configurationSelectHomeBaseAsSelectedStation, // non-standard
behaviour: ai.behaviourReconsider
}
]
}
]
},
/* No patrol route set up. Make one */
{
configuration: ai.configurationSetWaypoint,
behaviour: ai.behaviourApproachDestination,
reconsider: 30
}
],
},
{
condition: ai.conditionFriendlyStationExists,
truebranch: ai.templateReturnToBase(),
falsebranch: ai.templateWitchspaceJumpAnywhere()
}
]
A number of non-standard AI extensions would also need to be written, mostly quite short ones. I've noted where they're needed, and this could obviously be extended for more complex behaviours from the CSP. (If you want them in groups of two, probably easiest is to have one lead, and one escort with a slightly modified escort AI)
Set the naval station's allegiance to "restricted" and all ships except those specifically written to go there will not go near it, which might make things easier.
Pleb wrote:And 7 or 8 Regional HQ's, one per galactic sector (galaxy), and again not sure where those should go.
The core missions suggest Xeer (G1) and Birera (G3) as two of them.
Re: Her Imperial Majesty's Space Navy
Posted: Sat Feb 01, 2014 1:04 pm
by Cody
What Smivs said two posts above!
Re: Her Imperial Majesty's Space Navy
Posted: Sat Feb 01, 2014 1:13 pm
by Pleb
With regards to the new javascript AI (this I'm quite new to, but after skim reading through the tutorials I now know more than I did before - still using the tutorials heavily though!), would the this.waypointsHomeBasePatrol
work similarly to the function ai.waypointsStationPatrol
? So if the patrol ships were in the same group as the station, they would patrol around that station?
Re: Her Imperial Majesty's Space Navy
Posted: Sat Feb 01, 2014 1:30 pm
by cim
Pleb wrote:With regards to the new javascript AI (this I'm quite new to, but after skim reading through the tutorials I now know more than I did before - still using the tutorials heavily though!), would the this.waypointsHomeBasePatrol
work similarly to the function ai.waypointsStationPatrol
? So if the patrol ships were in the same group as the station, they would patrol around that station?
Making the station the patrol ships' group leader is probably the easiest way to get them to know which station to patrol, I think, for short-range patrols. For long-range patrols you'd probably want to use
ai.setParameter
to save their home station and make one of the patrol members the group leader, so that they act more independently and don't abandon their patrol to rush back over several hundred kilometres the moment the station is attacked.
Re: Her Imperial Majesty's Space Navy
Posted: Sat Feb 01, 2014 3:52 pm
by Switeck
Gimi wrote:Navy Sidewinder:
Beam or Military laser
4 hard head missiles.
The original Sidewinders lacked both missiles and cargo space, so unless HIMSN Sidewinders are considerably larger they won't have any either.
HIMSN Asps would probably almost always carry 1 Hardhead missile, since HIMSN was probably the ones to research/develop Hardhead missiles in the first place. An Asp might carry a q-bomb on rare occasion for a special mission.
If HIMSN "needs" a bomber-type ship that carries multiple missiles, there's always Cobra 3's and Boa 2 Light Cruisers.
Almost any HIMSN ship probably comes standard with an Escape Pod. Good help is so hard to find, so it pays to keep them alive!
Edit: removed Gal. Navy and replaced with HIMSN!
(Her Imperial Majesty's Space Navy)
Re: Her Imperial Majesty's Space Navy
Posted: Sat Feb 01, 2014 4:10 pm
by Cody
<grins> You mean HIMSN, yes?
Re: Her Imperial Majesty's Space Navy
Posted: Sat Feb 01, 2014 8:54 pm
by Switeck
yes, I probably should start using that abbreviation to keep from getting them mixed up.
Re: Her Imperial Majesty's Space Navy
Posted: Mon Feb 03, 2014 3:24 am
by Pleb
Okay, I'm presently using both Gimi's description of how the CSP AI should work, and using cim's example AI from above, and effectively creating the new/extra functions cim has listed in the example. Once I have a working prototype I will post something up.
Re: Her Imperial Majesty's Space Navy
Posted: Thu Feb 06, 2014 11:54 pm
by Pleb
Quick question for anyone who understands the new javascript AI, I'm trying to use the
checkScannerWithPredicate
function, but am not getting anywhere with it. I have the following:
Code: Select all
var ai = new worldScripts["oolite-libPriorityAI"].PriorityAIController(this.ship);
return ai.checkScannerWithPredicate(function(s) {
return (s.bounty > 50 || s.isThargoid) && s.scanClass != "CLASS_CARGO" && s.scanClass != "CLASS_ROCK" && s.scanClass != "CLASS_BUOY";
});
But this doesn't work...
Re: Her Imperial Majesty's Space Navy
Posted: Fri Feb 07, 2014 7:47 am
by cim
Pleb wrote:Quick question for anyone who understands the new javascript AI, I'm trying to use the
checkScannerWithPredicate
function, but am not getting anywhere with it. I have the following:
Code: Select all
var ai = new worldScripts["oolite-libPriorityAI"].PriorityAIController(this.ship);
return ai.checkScannerWithPredicate(function(s) {
return (s.bounty > 50 || s.isThargoid) && s.scanClass != "CLASS_CARGO" && s.scanClass != "CLASS_ROCK" && s.scanClass != "CLASS_BUOY";
});
But this doesn't work...
Remember that you must call
ai.configurationCheckScanner
to load the scanner data before doing any
checkScannerWithPredicate
calls. (You can do multiple predicate checks from a single data load). The syntax looks fine, otherwise.
Re: Her Imperial Majesty's Space Navy
Posted: Fri Feb 07, 2014 9:46 am
by Pleb
Still not working... I have this in the
ai.setPriorities
section/function:
Code: Select all
{
preconfiguration: ai.configurationCheckScanner,
condition: this.conditionScannerContainsHostileIntruder,
configuration: ai.configurationAcquireScannedTarget,
behaviour: ai.behaviourDestroyCurrentTarget,
reconsider: 10
},
And I'm using this as the
this.conditionScannerContainsHostileIntruder
function:
Code: Select all
this.conditionScannerContainsHostileIntruder = function()
{
var ai = new worldScripts["oolite-libPriorityAI"].PriorityAIController(this.ship);
return ai.checkScannerWithPredicate(function(s) {
return (s.bounty > 50 || s.isThargoid) && s.scanClass != "CLASS_CARGO" && s.scanClass != "CLASS_ROCK" && s.scanClass != "CLASS_BUOY";
});
}
However if I fly near the patrol with a fugitive legal status they ignore me (until I shoot at them, obviously). But as far as I can see they should be shooting at me once I fly near them.
Re: Her Imperial Majesty's Space Navy
Posted: Fri Feb 07, 2014 10:45 am
by Pleb
Okay not sure why but I think I've found the culprit - I tried to make a manual, simpler version of the
checkScannerWithPredicate
function, but this still didn't work. So I kept adding log variables until I got an error, and now I've found one. Using this function:
Code: Select all
this.conditionScannerContainsHostileIntruder = function()
{
var ai = new worldScripts["oolite-libPriorityAI"].PriorityAIController(this.ship);
var scanner_results = this.ship.checkScanner(true);
for (var i = 0 ; i < scanner_results.length ; i++)
{
var s = scanner_results[i];
if (s.bounty > 50 || s.isThargoid)
{
log(this.name, "target found");
ai.setParameter("oolite_scanResultSpecific",this.ship.target)
var target = ai.getParameter("oolite_scanResultSpecific");
log(this.name, target.name);
return true;
}
else
{
log(this.name, "nothing");
return false;
}
}
}
This should now report in the log 'nothing' if nothing is found (which it does) and 'target found' if it finds a target that is a thargoid or fugitive (which it also does). I have then added a log bit to also add the name of the target that is its in the
oolite_scanResultSpecific
parameter, and here is where the error occurs:
Code: Select all
10:35:55.964 [oolite-libPriorityAI]: nothing
10:36:38.571 [oolite-libPriorityAI]: nothing
10:36:39.590 [oolite-libPriorityAI]: nothing
10:36:41.227 [oolite-libPriorityAI]: nothing
10:36:41.345 [oolite-libPriorityAI]: target found
10:36:41.359 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (himsn-csp.js 0.1): TypeError: target is null
10:36:41.359 [script.javaScript.exception.unexpectedType]: ../AddOns/Her Imperial Majesty's Space Navy.oxp/AIs/himsn-csp.js, line 177.
Is it that maybe you can't set the
oolite_scanResultSpecific
parameter outside oolite-priorityai.js? Just to test that there wasn't a coding error on my part, I changed the
this.conditionScannerContainsHostileIntruder
function that's called for in the script to
ai.conditionScannerContainsFugitive
, which works but I really need to be able to define my own scanner conditions if this script is going to work the way I want it to...
EDIT: I fixed the error in the log:
Code: Select all
this.conditionScannerContainsHostileIntruder = function()
{
var ai = new worldScripts["oolite-libPriorityAI"].PriorityAIController(this.ship);
var scanner_results = this.ship.checkScanner(true);
for (var i = 0 ; i < scanner_results.length ; i++)
{
var s = scanner_results[i];
if (s.bounty > 50 || s.isThargoid)
{
log(this.name, "target found");
this.ship.target = s;
ai.setParameter("oolite_scanResultSpecific",this.ship.target)
var target = ai.getParameter("oolite_scanResultSpecific");
log(this.name, target.name);
return true;
}
else
{
log(this.name, "nothing");
return false;
}
}
}
And now the log reads:
Code: Select all
11:31:36.026 [oolite-libPriorityAI]: nothing
11:31:38.349 [oolite-libPriorityAI]: nothing
11:31:43.813 [oolite-libPriorityAI]: nothing
11:31:44.882 [oolite-libPriorityAI]: nothing
11:31:45.518 [oolite-libPriorityAI]: target found
11:31:45.518 [oolite-libPriorityAI]: Cobra Mark III
11:31:45.634 [oolite-libPriorityAI]: target found
11:31:45.634 [oolite-libPriorityAI]: Cobra Mark III
11:31:45.735 [oolite-libPriorityAI]: target found
11:31:45.736 [oolite-libPriorityAI]: Cobra Mark III
11:31:45.852 [oolite-libPriorityAI]: target found
11:31:45.853 [oolite-libPriorityAI]: Cobra Mark III
So it can see me, registers me in the
oolite_scanResultSpecific
parameter, but still nothing...
Re: Her Imperial Majesty's Space Navy
Posted: Fri Feb 07, 2014 5:42 pm
by cim
Pleb wrote:And I'm using this as the
this.conditionScannerContainsHostileIntruder
function:
Code: Select all
this.conditionScannerContainsHostileIntruder = function()
{
var ai = new worldScripts["oolite-libPriorityAI"].PriorityAIController(this.ship);
return ai.checkScannerWithPredicate(function(s) {
return (s.bounty > 50 || s.isThargoid) && s.scanClass != "CLASS_CARGO" && s.scanClass != "CLASS_ROCK" && s.scanClass != "CLASS_BUOY";
});
}
There is the problem. Rather than executing the
checkScannerWithPredicate
in the context of the ship's AI controller, you create a new AI controller for that function, and execute its
checkScannerWithPredicate
instead. This is likely to cause many problems, but most immediately it means that when
checkScannerWithPredicate
calls
setParameter
, it's setting the parameter on a different AI controller to the one you're wanting to read it.
The condition check (as with all other priority components) is executed in the context of the AI controller, so instead:
Code: Select all
// this "this" is the script that defines the function
this.conditionScannerContainsHostileIntruder = function()
{
// this "this" is the AI controller running the function
return this.checkScannerWithPredicate(function(s) {
return (s.bounty > 50 || s.isThargoid) && s.scanClass != "CLASS_CARGO" && s.scanClass != "CLASS_ROCK" && s.scanClass != "CLASS_BUOY";
});
}
should work.
Re: Her Imperial Majesty's Space Navy
Posted: Sat Feb 08, 2014 11:47 pm
by Pleb
Okay I've put together a little tester OXZ. This basically adds some HIMSN ships and a station to the Lave system (as it's easier to test here as you can just start a new game). There should be a station near the planet, that if you fly near and you are a fugitive, you will be warned and destroyed. If you target any HIMSN ship or station (including the buoy) you will be warned and destroyed. If you want to dock at the station, you will have to ask for clearance. Surrounding the station are some defense ships, who will patrol the station. If you ask to dock, they may move in nearer to keep an eye on you.
There are also three deep space patrols, one on each route (planet-witchpoint, witchpoint-sun, sun-planet) that will only engage fugitives and Thargoids. There is also a cruiser (this is Smivs's Thunder Child for the moment) and some support craft patrolling the witchpoint-planet route, that if you approach will warn you to back off. If you are a fugitive it will warn and destroy you.
All the models (except Smivs's Thunder Child) are the stock ones. This is essentially just a test to see if anyone can break the code or find any faults. Custom comms messages have been added as well to the ships.
Obviously a system would not be this populated with HIMSN ships and stations usually, this is just for testing purposes. And the station would not be this near to the planet - it just makes it easier for testing! I've tried to follow Gimi's instructions as best I can, and obviously the main framework for the AI script was kindly provided by cim.
Download Test OXZ
EDIT: I forgot to add another test in interstellar space, against the Thargoids! Next time...