init
This commit is contained in:
335
platforms/brawler/alternatives/BrawlerScriptUtil.txt
Normal file
335
platforms/brawler/alternatives/BrawlerScriptUtil.txt
Normal file
@@ -0,0 +1,335 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
|
||||
#no other easy way in WSF to get relative NED position
|
||||
#here we calculate a rough approximation ourselves
|
||||
script Vec3 RelativePositionNED(WsfGeoPoint from, WsfGeoPoint to)
|
||||
double deg2ft = 364812.76313;
|
||||
Vec3 vec = Vec3.Construct( (to.Latitude() -from.Latitude() )*deg2ft,
|
||||
(to.Longitude()-from.Longitude())*deg2ft*MATH.Cos(from.Latitude()*MATH.RAD_PER_DEG()),
|
||||
-(to.Altitude() -from.Altitude() )*MATH.FT_PER_M());
|
||||
return vec;
|
||||
end_script
|
||||
|
||||
#replicates subroutine makecs(bxin,bzin,b)
|
||||
script Array<double> makecs(Vec3 bxin, Vec3 bzin)
|
||||
Array<double> b = Array<double>();
|
||||
Vec3 bx;
|
||||
Vec3 by;
|
||||
Vec3 bz;
|
||||
// Normalize bxin, store in bx
|
||||
bx = bxin.Normal();
|
||||
// Cross product of bzin and Normalized bxin, stored in by
|
||||
by = Vec3.Cross(bzin, bx);
|
||||
// Normalize by and evaluate the magnitude of original by
|
||||
if (by.Normalize() == 0.0)
|
||||
{
|
||||
// If the magnitude of by is zero, replace by with cross of bx and unit Z vector
|
||||
Vec3 unitZ = Vec3.Construct(0.0, 0.0, 1.0);
|
||||
by = Vec3.Cross(unitZ, bx);
|
||||
by.Normalize();
|
||||
}
|
||||
//cross product of bx and by stored in bz
|
||||
bz = Vec3.Cross(bx, by);
|
||||
|
||||
b[0] = bx.Get(0); // b(1,1) = bx(1)
|
||||
b[3] = bx.Get(1); // b(1,2) = bx(2)
|
||||
b[6] = bx.Get(2); // b(1,3) = bx(3)
|
||||
b[1] = by.Get(0); // b(2,1) = by(1)
|
||||
b[4] = by.Get(1); // b(2,2) = by(2)
|
||||
b[7] = by.Get(2); // b(2,3) = by(3)
|
||||
b[2] = bz.Get(0); // b(3,1) = bz(1)
|
||||
b[5] = bz.Get(1); // b(3,2) = bz(2)
|
||||
b[8] = bz.Get(2); // b(3,3) = bz(3)
|
||||
return b;
|
||||
end_script
|
||||
|
||||
#replicates subroutine makex(cxin,[return c])
|
||||
# EQUIVALENT TO MAKECS WHEN ARGUMENT BZIN = (0,0,1)
|
||||
script Array<double> makex(Vec3 cxin)
|
||||
Array<double> c = Array<double>();
|
||||
Vec3 unitZ = Vec3.Construct(0.0, 0.0, 1.0);
|
||||
c = makecs(cxin, unitZ);
|
||||
return c;
|
||||
end_script
|
||||
|
||||
#replicates subroutine makeh([return matrix], dir)
|
||||
#returns an array (rot) that represents a 3x3 rotation matrix
|
||||
#where rot[0] = matrix(1,1) and rot[1] == matrix(1,2)
|
||||
script Array<double> makeh(Vec3 dir)
|
||||
Array<double> rot = Array<double>();
|
||||
double temp = MATH.Sqrt(dir[0]*dir[0] + dir[1]*dir[1]);
|
||||
rot[0] = dir[0]/temp; #c(1,1) = cxin(1)/sngl(temp)
|
||||
rot[1] = dir[1]/temp; #c(1,2) = cxin(2)/sngl(temp)
|
||||
rot[2] = 0.0; #c(1,3) = 0.
|
||||
rot[3] = -rot[1]; #c(2,1) = -c(1,2)
|
||||
rot[4] = rot[0]; #c(2,2) = c(1,1)
|
||||
rot[5] = 0.0; #c(2,3) = 0.
|
||||
rot[6] = 0.0; #c(3,1) = 0.
|
||||
rot[7] = 0.0; #c(3,2) = 0.
|
||||
rot[8] = 1.0; #c(3,3) = 1.
|
||||
return rot;
|
||||
end_script
|
||||
|
||||
# replicates: subroutine vxfrmc(b,v, [return Vec3 vt],1)
|
||||
# "b" represents a 3x3 rotation matrix
|
||||
# where b[0] = matrix(1,1) and b[1] == matrix(1,2)
|
||||
script Vec3 vxfrmc1(Array<double> b, Vec3 v)
|
||||
#b = 3x3 rotation matrix where [0] = (1,1) and [1] == (1,2)
|
||||
double x = v[0]*b[0]+v[1]*b[1]+v[2]*b[2];
|
||||
double y = v[0]*b[3]+v[1]*b[4]+v[2]*b[5];
|
||||
double z = v[0]*b[6]+v[1]*b[7]+v[2]*b[8];
|
||||
Vec3 vt = Vec3.Construct(x,y,z);
|
||||
return vt;
|
||||
end_script
|
||||
|
||||
# replicates: subroutine vxfrmc(b,[return Vec3],vt,2)
|
||||
# "b" represents a 3x3 rotation matrix
|
||||
# where b[0] = matrix(1,1) and b[1] == matrix(1,2)
|
||||
script Vec3 vxfrmc2(Array<double> b, Vec3 vt)
|
||||
#b = 3x3 rotation matrix where [0] = (1,1) and [1] == (1,2)
|
||||
double x = vt[0]*b[0]+vt[1]*b[3]+vt[2]*b[6];
|
||||
double y = vt[0]*b[1]+vt[1]*b[4]+vt[2]*b[7];
|
||||
double z = vt[0]*b[2]+vt[1]*b[5]+vt[2]*b[8];
|
||||
Vec3 v = Vec3.Construct(x,y,z);
|
||||
return v;
|
||||
end_script
|
||||
|
||||
# replicates: subroutine rotx(chi,vin,[return vout])
|
||||
# FINDS VECTOR IN A FRAME ROTATED BY CHI ABOUT X-AXIS
|
||||
script Vec3 rotx(double chi, Vec3 vin)
|
||||
double cchi = (Math.Cos(chi * Math.DEG_PER_RAD())) * Math.RAD_PER_DEG();
|
||||
double schi = (Math.Sin(chi * Math.DEG_PER_RAD())) * Math.RAD_PER_DEG();
|
||||
Vec3 vout = Vec3.Construct(vin[0], (cchi*vin[1]+schi*vin[2]), (-schi*vin[1]+cchi*vin[2]));
|
||||
return vout;
|
||||
end_script
|
||||
|
||||
# replicates: subroutine rotv(chi,vaxis,vin,[return vout])
|
||||
# ROTATE VECTOR BY ANGLE ABOUT SPECIFIED AXIS
|
||||
#CIN CHI REAL - DESIRED ANGLE OF ROTATION (radians)
|
||||
#CIN VAXIS 3-VEC - AXIS OF ROTATION
|
||||
#CIN VIN 3-VEC - UNROTATED VECTOR
|
||||
#COUT VOUT 3-VEC - RESULT OF ROTATING VIN BY CHI ABOUT VAXIS
|
||||
script Vec3 rotv(double chi, Vec3 vaxis, Vec3 vin)
|
||||
Array<double> rot = Array<double>();
|
||||
if (vaxis[0]*vaxis[0] + vaxis[1]*vaxis[1] == 0.0)
|
||||
{
|
||||
Vec3 unitX = Vec3.Construct(1,0,0);
|
||||
rot = makecs(vaxis, unitX);
|
||||
}
|
||||
else
|
||||
{
|
||||
rot = makex(vaxis);
|
||||
}
|
||||
Vec3 vout = vxfrmc1(rot,vin);
|
||||
vout = rotx(-chi,vout);
|
||||
vout = vxfrmc2(rot,vout);
|
||||
return vout;
|
||||
end_script
|
||||
|
||||
# replicates: vmake(a,vin,vout)
|
||||
# a - desired vector norm
|
||||
# vector - vector to rescale
|
||||
script Vec3 vmake(double a, Vec3 vin)
|
||||
double b = a / vin.Magnitude();
|
||||
// TODO prevent div by zero?
|
||||
// b = a/sqrt(1.e-35 + vin(1)*vin(1) + vin(2)*vin(2) + vin(3)*vin(3))
|
||||
Vec3 vout = Vec3.Construct(b*vin.X(), b*vin.Y(), b*vin.Z());
|
||||
return vout;
|
||||
end_script
|
||||
|
||||
# replicates: subroutine ramp(xlo,xval,xhi)
|
||||
script double ramp(double xlo, double xval, double xhi)
|
||||
double rampVal = (xval-xlo) / (xhi-xlo);
|
||||
if(rampVal <= 0.0)
|
||||
{
|
||||
rampVal = 0.0;
|
||||
}
|
||||
if(rampVal >= 1.0)
|
||||
{
|
||||
rampVal = 1.0;
|
||||
}
|
||||
return rampVal;
|
||||
end_script
|
||||
|
||||
# replicates: subroutine border(z, z0)
|
||||
script double border(double z, double z0)
|
||||
double border = 0;
|
||||
if (z <= 0)
|
||||
{
|
||||
double t = (z / z0 - 1.0);
|
||||
border = 1.0 / (1.0 + (t * t));
|
||||
}
|
||||
else
|
||||
{
|
||||
double u = (z / z0 + 1.0) * (z / z0 + 1.0);
|
||||
border = u / (1 + u);
|
||||
}
|
||||
return border;
|
||||
end_script
|
||||
|
||||
# replicates: subroutine cauchy(z, z0)
|
||||
script double cauchy(double z, double z0)
|
||||
double t = (z / z0);
|
||||
return 1.0 / (1.0 + (t * t));
|
||||
end_script
|
||||
|
||||
|
||||
script Vec3 vorth(Vec3 a, Vec3 b)
|
||||
double x = (a[0]*b[0]+a[1]*b[1]+a[2]*b[2])/(b[0]*b[0]+b[1]*b[1]+b[2]*b[2]);
|
||||
Vec3 temp = b;
|
||||
temp.Scale(x);
|
||||
Vec3 c = Vec3.Subtract(a,temp);
|
||||
return c;
|
||||
end_script
|
||||
|
||||
|
||||
script bool HaveWeapon(WsfPlatform plat)
|
||||
for(int i=0; i<plat.WeaponCount(); i+=1)
|
||||
{
|
||||
if (plat.WeaponEntry(i).QuantityRemaining() >= 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
end_script
|
||||
|
||||
|
||||
script Vec3 unitv2(Vec3 a)
|
||||
double mag = MATH.Sqrt(a.X()*a.X() + a.Y()*a.Y());
|
||||
Vec3 val = Vec3.Construct(a.X()/mag, a.Y()/mag, 0.0);
|
||||
return val;
|
||||
end_script
|
||||
|
||||
|
||||
#replicates portion of desvvi that calculates "vuse" and "spduse"
|
||||
#function arguments:
|
||||
# vdes = normalized direction vector
|
||||
# spddes = speed in ft/sec
|
||||
#returns a vec in ft/sec
|
||||
script Vec3 desvvi(WsfBrawlerPlatform plat, Vec3 vdes, double spddes)
|
||||
bool lngtrn;
|
||||
Vec3 vuse = Vec3();
|
||||
double spduse;
|
||||
double cornrv = plat.CorneringVelocity(); //fps
|
||||
double grav = 32.17405; //fps
|
||||
double gmxsut = plat.MaxSustainedGs();
|
||||
|
||||
//C --external declarations
|
||||
# integer rspace
|
||||
# realdot,ramp,xlimit
|
||||
# real arccos
|
||||
//C --local declarations
|
||||
//real h(2),hdes(2);
|
||||
Vec3 h = Vec3();
|
||||
Vec3 hdes = Vec3();
|
||||
double d10 = 0.174533; //radians (10 deg)
|
||||
double s30 = 0.5;
|
||||
double s45 = 0.707107;
|
||||
double s15 = 0.258819;
|
||||
double dsemax,hnorm,csenow,senow;
|
||||
//real arcsin
|
||||
//C*ENDDEC
|
||||
vuse = unitv2(vdes);
|
||||
h = unitv2(plat.VelocityNED());
|
||||
|
||||
//C CURRENT HEADING COORDINATES:
|
||||
//C X = [ H(1),H(2)]
|
||||
//C Y = [-H(2),H(1)]
|
||||
//hdes(1) = vuse(1)*h(1)+vuse(2)*h(2)
|
||||
hdes.SetX(vuse.X()*h.X()+vuse.Y()*h.Y());
|
||||
|
||||
//C TO AVOID MESSING UP LATER ARCCOS(HDES(1)):
|
||||
if(MATH.Fabs(hdes.X()) > 1.0)
|
||||
{
|
||||
if(MATH.Fabs(hdes.X()) > 1.000001)
|
||||
{
|
||||
//call nabort('HDES(1) NORM');
|
||||
writeln("ABORT!!!! hdes(1) > 1.000001");
|
||||
return Vec3();
|
||||
}
|
||||
hdes.SetX(1.0);
|
||||
if (hdes.X() < 0)
|
||||
{
|
||||
hdes.SetX(-1.0);
|
||||
}
|
||||
}
|
||||
|
||||
hdes.SetY(-vuse.X()*h.Y()+vuse.Y()*h.X());
|
||||
csenow = plat.Speed()*MATH.FT_PER_M()+0.01;
|
||||
csenow = Vec3.Dot(vdes,plat.VelocityNED())/csenow;
|
||||
senow = MATH.ACos(csenow);
|
||||
double tproj3 = plat.ProjectedTimeDelta();
|
||||
dsemax = tproj3*(gmxsut*grav/cornrv);
|
||||
//C LNGTRN REQUIRES LARGE ERRORS IN BOTH MAGNITUDE AND HEADING
|
||||
lngtrn = MATH.ACos(hdes.X()) > dsemax && senow > 1.5*dsemax;
|
||||
if (!lngtrn)
|
||||
{
|
||||
//C
|
||||
//C SHORTER TURN:
|
||||
//C
|
||||
vuse = vdes;
|
||||
spduse = spddes;
|
||||
//goto 9999
|
||||
}
|
||||
else
|
||||
{
|
||||
//C
|
||||
//C LONGER TURN:
|
||||
//C
|
||||
if((plat.Speed()*MATH.FT_PER_M()) > 0.9*cornrv)
|
||||
{
|
||||
if((plat.Speed()*MATH.FT_PER_M()) < 1.1*cornrv)
|
||||
{
|
||||
//C HERE SPEED NEAR CORNER - MAINTAIN MODEST DIVE TO HELP MAINTAIN SPD
|
||||
vuse.SetZ(s15);
|
||||
}
|
||||
else
|
||||
{
|
||||
//C TOO FAST - PULL UP WHILE TURNING
|
||||
//format('DESVVI... TOO FAST, CORNER = ',f8.2,' MACH ',f5.1)
|
||||
vuse.SetZ(-s45*ramp(1.1*cornrv,plat.Speed()*MATH.FT_PER_M(),1.2*cornrv));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//C TOO SLOW - SET 30 DEG DIVE
|
||||
vuse.SetZ(s30);
|
||||
}
|
||||
|
||||
hnorm = MATH.Sqrt(1.0-vuse.Z()*vuse.Z());
|
||||
if(hdes.X() > 0.0)
|
||||
{
|
||||
//C RENORMALIZE HORIZONTAL FOR LESS THAN 90 DEG HEADING CHANGES
|
||||
vuse.SetX(vuse.X()*hnorm);
|
||||
vuse.SetY(vuse.Y()*hnorm);
|
||||
}
|
||||
else
|
||||
{
|
||||
//C SET UP 90 DEG HEADING CHANGE AND DO ROTATION BACK TO EARTH COORDINATES
|
||||
//C IMPLICIT IS HDES(1) = 0
|
||||
hdes.SetY(hnorm);
|
||||
if (hdes.Y() < 0)
|
||||
{
|
||||
hdes.SetY(-hnorm);
|
||||
}
|
||||
vuse.SetX(-h.Y()*hdes.Y());
|
||||
vuse.SetY(h.X()*hdes.Y());
|
||||
}
|
||||
spduse = cornrv;
|
||||
//goto 9999
|
||||
}
|
||||
//C
|
||||
//9999
|
||||
vuse.Normalize();
|
||||
vuse.Scale(spduse);
|
||||
return vuse;
|
||||
end_script
|
||||
23
platforms/brawler/alternatives/behavior_alt1514_point.txt
Normal file
23
platforms/brawler/alternatives/behavior_alt1514_point.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
|
||||
|
||||
behavior alt1514_point
|
||||
|
||||
precondition
|
||||
return 1.0;
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
extern int kturn;
|
||||
kturn = 0; //go straight at target
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
@@ -0,0 +1,26 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
|
||||
behavior alt1516_bvr_end_run_left
|
||||
|
||||
script_variables
|
||||
end_script_variables
|
||||
|
||||
precondition
|
||||
return 1.0;
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
extern int kturn;
|
||||
kturn = -1; //go left around target
|
||||
writeln_d("executed alt1516_bvr_end_run_left");
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
@@ -0,0 +1,22 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
|
||||
behavior alt1517_bvr_end_run_right
|
||||
|
||||
precondition
|
||||
return 1.0;
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
extern int kturn;
|
||||
kturn = 1; //go right around target
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
@@ -0,0 +1,112 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt31.f
|
||||
// Replicates the straight and level at max speed 3,1,1,1 alternative behavior
|
||||
|
||||
|
||||
behavior alt3111_straight_level_max_speed
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3111Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 1;
|
||||
int icall = 1;
|
||||
int lcall = 1;
|
||||
|
||||
Vec3 mDir0 = Vec3();
|
||||
double mGMX = 1.0;
|
||||
double mSpd0 = 3.0;
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3111_straight_level_max_speed, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3111Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
// ALL CONDITIONS PASS
|
||||
### Generate Maneuver Alternative
|
||||
# C STRAIGHT AND LEVEL AT MAX SPEED
|
||||
#10 iactn = 4
|
||||
# lenalt = lactn(iactn)
|
||||
# altdsc = indpk(3,1,1,1)
|
||||
# call xmit(2,vp(1,me),dir0)
|
||||
# dir0(3) = 0.
|
||||
# call vnorm(dir0,dir0)
|
||||
# gmx = gmxsu
|
||||
# spdmod = thrttl
|
||||
# spd0 = 3.
|
||||
# go to 800
|
||||
|
||||
mDir0 = PLATFORM.VelocityNED();
|
||||
mDir0.SetZ(0.0);
|
||||
mDir0.Normalize();
|
||||
mGMX = brawlerPlatform.MaxSustainedGs();
|
||||
mSpd0 = 3.0;
|
||||
|
||||
### Evaluate [Projected] Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithThrottle(mDir0, mGMX, mSpd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
brawlerPlatform.FlyVectorWithThrottle(mDir0, mGMX, mSpd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt31.f
|
||||
// Replicates the straight and level (current speed) 3,1,2,1 alternative behavior
|
||||
|
||||
behavior alt3121_straight_level
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3121Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 1;
|
||||
int icall = 2;
|
||||
int lcall = 1;
|
||||
|
||||
Vec3 mDir0;
|
||||
double mGMX = 1.0;
|
||||
double mSpd0;
|
||||
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3121_straight_levelt, T=", TIME_NOW);
|
||||
|
||||
|
||||
#writeln_d("T = ", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3121Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
// ALL CONDITIONS PASS
|
||||
### Generate Maneuver Alternative
|
||||
# C STRAIGHT-AND-LEVEL
|
||||
#20 iactn = 4
|
||||
# lenalt = lactn(iactn)
|
||||
# altdsc=indpk(3,1,2,1)
|
||||
# call xmit(2,vp(1,me),dir0)
|
||||
# dir0(3) = 0.
|
||||
# call vnorm(dir0,dir0)
|
||||
# gmx = gmxsu
|
||||
# spd0 = spdnow(me)
|
||||
# spdmod = desspd
|
||||
|
||||
mDir0 = PLATFORM.VelocityNED();
|
||||
mDir0.SetZ(0.0);
|
||||
mDir0.Normalize();
|
||||
mGMX = brawlerPlatform.MaxSustainedGs();
|
||||
mSpd0 = PLATFORM.Speed();
|
||||
|
||||
### Evaluate [Projected] Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithSpeed(mDir0, mGMX, mSpd0, ilevel, kalt, icall, lcall);
|
||||
writeln_d("T=", TIME_NOW, ", alt3121_straight_level = ", score);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
|
||||
writeln_d("3121_straight_level, dir0 = ", mDir0.ToString());
|
||||
## what was evaluated should be actually performed now
|
||||
brawlerPlatform.FlyVectorWithSpeed(mDir0, mGMX, mSpd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt32.f and captrn.f
|
||||
// Replicates the route maneuver 3,2,1,1 and cap turn 3,2,2,1 alternative behavior
|
||||
// This behavior will just fly the WSF platform route
|
||||
|
||||
behavior alt3211_route_maneuver
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3211Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 2;
|
||||
int icall = 1;
|
||||
int lcall = 1;
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3411_straight_flight, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3211Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() > 0)
|
||||
{
|
||||
// Fail if we should be pursuing a weapon task
|
||||
return Failure("pursuing WEAPON task");
|
||||
}
|
||||
|
||||
WsfRoute route = PLATFORM.Route();
|
||||
if (!route.IsValid() || route.Size() < 2)
|
||||
{
|
||||
// Fail if we do not have a valid route
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " invalid route");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
// Otherwise return a high score for this alternative
|
||||
// so it is picked and we just follow our route
|
||||
double score = 10.0;
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
PLATFORM.ReturnToRoute();
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt34.f
|
||||
// Replicates the 1v1 Offensive Maneuver 3,4,1,1 alternative behavior
|
||||
// Straight Flight
|
||||
//
|
||||
// Operates on nearest perceived threat to generate maneuver alternative
|
||||
|
||||
behavior alt3411_straight_flight
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
WsfLocalTrack targetTrack;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3411Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 4;
|
||||
int icall = 1;
|
||||
int lcall = 1;
|
||||
|
||||
double mLongRange = 5.0 * Math.M_PER_NM();
|
||||
|
||||
Vec3 dir0;
|
||||
double mGMX = 1.0;
|
||||
double mSpd0 = 3.0;
|
||||
|
||||
// ALSO NEED:
|
||||
// randomization to simulate imperfect decision making, valsig, read from MIND file, typically ~0.01
|
||||
// Production rule bias, used in scoring of alternative
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3411_straight_flight, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3411Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() <= 0)
|
||||
{
|
||||
return Failure("no weapon (target) tasks!");
|
||||
}
|
||||
WsfTask targetTask = tasks.Entry(0);
|
||||
targetTrack = PLATFORM.MasterTrackList().Find(targetTask.LocalTrackId());
|
||||
if (!targetTrack.IsValid())
|
||||
{
|
||||
return Failure("no target track!");
|
||||
}
|
||||
|
||||
// Get nearest hostile and check that range is less than max
|
||||
// alt34.f line 114
|
||||
WsfTrack nearestHostile = perception.NearestThreat();
|
||||
double rangeToNearest = 999999999; # default large value, in meters
|
||||
if (nearestHostile.IsValid() &&
|
||||
nearestHostile.LocationValid())
|
||||
{
|
||||
rangeToNearest = nearestHostile.SlantRangeTo(PLATFORM);
|
||||
}
|
||||
|
||||
if (!nearestHostile.IsValid())
|
||||
{
|
||||
writeln_d("nearest hostile not valid!");
|
||||
return Failure("no vaild hostiles closer than 5 nautical miles");
|
||||
}
|
||||
|
||||
if (rangeToNearest > mLongRange)
|
||||
{
|
||||
writeln_d("nearest hostile too far away! (", rangeToNearest," m)");
|
||||
return Failure("no vaild hostiles closer than 5 nautical miles");
|
||||
}
|
||||
|
||||
// ALL CONDITIONS PASS
|
||||
### Generate Maneuver Alternative
|
||||
# alt34.f line 115 - 121
|
||||
# iactn = 4
|
||||
# call vnorm(vp(1,me),dir0) - get a unit vector (dir0) of my current velocity vector
|
||||
# gmx = amin1(3.,gmxsu) - take the smaller of 3.0 and Maximum load possible at maximum thrust
|
||||
# spd0 = 3.
|
||||
# spdmod = thrttl (desspd = 1, thrttl = 2, desacc = 3)
|
||||
int iactn = 4;
|
||||
dir0 = PLATFORM.VelocityNED().Normal();
|
||||
mGMX = Math.Min(3.0, brawlerPlatform.MaxSustainedGs());
|
||||
mSpd0 = 3.0;
|
||||
int spdmod = 2; // thrttl
|
||||
|
||||
### Project and Evaluate (Score) Maneuver Alternative
|
||||
// Alternative is only projected tproj sec and then evaluated
|
||||
double alternativeScore = brawlerPlatform.EvaluateVectorWithThrottle(dir0, mGMX, mSpd0, ilevel, kalt, icall, lcall);
|
||||
writeln_d(PLATFORM.Name(), " behavior_alt3411_straight_flight score = ", alternativeScore, ", T=", TIME_NOW);
|
||||
|
||||
### Return Maneuver Alternative Score
|
||||
return alternativeScore;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
#writeln_d(PLATFORM.Name(), " executing behavior_alt3411_straight_flight, T=", TIME_NOW);
|
||||
brawlerPlatform.FlyVectorWithThrottle(dir0, mGMX, mSpd0);
|
||||
|
||||
# if (mDrawSteering == true)
|
||||
# {
|
||||
# mDraw.SetLayer("behavior_pursue_target");
|
||||
# mDraw.SetDuration(processor.UpdateInterval());
|
||||
# mDraw.SetColor(1.0, 0.5, 0.0);
|
||||
# mDraw.SetLineSize(1);
|
||||
# mDraw.BeginLines();
|
||||
# mDraw.Vertex(PLATFORM.Location());
|
||||
# mDraw.Vertex(mTargetPoint);
|
||||
# mDraw.End();
|
||||
# }
|
||||
#
|
||||
# string msg = write_str("pursue-target: ", targetTrack.TargetName(), " at speed ", (string)mTargetSpeed);
|
||||
# writeln_d(" T=", TIME_NOW, " ", PLATFORM.Name(), " ", msg);
|
||||
# FlyTarget( PLATFORM, mTargetPoint, mTargetSpeed);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt34.f -> alt342.f
|
||||
// Replicates the 3,4,2,1 alternative behavior
|
||||
// alt3421_roll_+15_pull
|
||||
|
||||
include_once BrawlerScriptUtil.txt
|
||||
|
||||
behavior alt3421_roll_15_pull
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3421Enabled = true;
|
||||
double mLongRange = 5.0 * Math.M_PER_NM();
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 4;
|
||||
int icall = 2;
|
||||
int lcall = 1;
|
||||
|
||||
Vec3 a0; # maneuver plane
|
||||
Vec3 dir0; # direction vector
|
||||
double gmx; # max Gs
|
||||
double spd0; # throttle setting
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
double grav = 32.17405;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition alt3421 roll_+15_pull, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3421Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
## alt 34.f line 97, & 140
|
||||
#lrange = rhst*ftnmi .gt. 5.0
|
||||
#if(lrange)goto 15
|
||||
|
||||
WsfTrack nearestHostile = perception.NearestThreat();
|
||||
double rangeToNearest = 999999999; # default large value, in meters
|
||||
if (nearestHostile.IsValid() &&
|
||||
nearestHostile.LocationValid())
|
||||
{
|
||||
rangeToNearest = nearestHostile.SlantRangeTo(PLATFORM);
|
||||
}
|
||||
|
||||
if (!nearestHostile.IsValid())
|
||||
{
|
||||
writeln_d("nearest hostile not valid!");
|
||||
return Failure("no vaild hostiles closer than 5 nautical miles");
|
||||
}
|
||||
|
||||
if (rangeToNearest > mLongRange)
|
||||
{
|
||||
writeln_d("nearest hostile too far away! (", rangeToNearest," m)");
|
||||
return Failure("no vaild hostiles closer than 5 nautical miles");
|
||||
}
|
||||
|
||||
##alt342.f line 99-112
|
||||
## GENERATE MAX TURNS IN MANEUVER PLANES ADJACENT TO PRESENT PLANE
|
||||
## ROLL +15 & PULL
|
||||
#iactn = 4
|
||||
#dir0(1) = 0.
|
||||
#dir0(2) = sd15
|
||||
#dir0(3) = -cd15
|
||||
#call vxfrmc(rwep,dir0,dir0,2)
|
||||
## DIR0 IS UNIT ACCELERATION VECTOR IN DESIRED MANEUVER PLANE
|
||||
#call manpln(dir0,gmxsu)
|
||||
|
||||
double sd15 = 0.2588190;
|
||||
double cd15 = 0.9659258;
|
||||
dir0 = Vec3.Construct(0.0, sd15, -cd15);
|
||||
dir0 = brawlerPlatform.ConvertWindtoNED(dir0);
|
||||
double gmxsu = brawlerPlatform.MaxTacticalGs();
|
||||
#call manpln(dir0,gmxsu)
|
||||
#manpln() - maneuver in plane: replicated in 6 lines below
|
||||
dir0 = vorth(dir0, PLATFORM.VelocityNED());
|
||||
dir0.Normalize();
|
||||
int iactn = 4;
|
||||
gmx = gmxsu;
|
||||
spd0 = 3.0;
|
||||
int spdmod = 2; //thrttl
|
||||
|
||||
### Project and Evaluate (Score) Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithThrottle(dir0, gmx, spd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
PLATFORM.FlyVectorWithThrottle(dir0, gmx, spd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
140
platforms/brawler/alternatives/behavior_alt3431_roll-15_pull.txt
Normal file
140
platforms/brawler/alternatives/behavior_alt3431_roll-15_pull.txt
Normal file
@@ -0,0 +1,140 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt34.f -> alt343.f
|
||||
// Replicates the 3,4,3,1 alternative behavior
|
||||
// alt3431_roll-15_pull
|
||||
|
||||
behavior alt3431_roll-15_pull
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3431Enabled = true;
|
||||
double mLongRange = 5.0 * Math.M_PER_NM();
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 4;
|
||||
int icall = 3;
|
||||
int lcall = 1;
|
||||
|
||||
Vec3 a0; # maneuver plane
|
||||
Vec3 dir0; # direction vector
|
||||
double gmx; # max Gs
|
||||
double spd0; # throttle setting
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
double grav = 32.17405;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition alt3431 roll-15_pull, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3431Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
## alt 34.f line 97, & 140
|
||||
#lrange = rhst*ftnmi .gt. 5.0
|
||||
#if(lrange)goto 15
|
||||
|
||||
WsfTrack nearestHostile = perception.NearestThreat();
|
||||
double rangeToNearest = 999999999; # default large value, in meters
|
||||
if (nearestHostile.IsValid() &&
|
||||
nearestHostile.LocationValid())
|
||||
{
|
||||
rangeToNearest = nearestHostile.SlantRangeTo(PLATFORM);
|
||||
}
|
||||
|
||||
if (!nearestHostile.IsValid())
|
||||
{
|
||||
writeln_d("nearest hostile not valid!");
|
||||
return Failure("no vaild hostiles closer than 5 nautical miles");
|
||||
}
|
||||
|
||||
if (rangeToNearest > mLongRange)
|
||||
{
|
||||
writeln_d("nearest hostile too far away! (", rangeToNearest," m)");
|
||||
return Failure("no vaild hostiles closer than 5 nautical miles");
|
||||
}
|
||||
|
||||
##alt343.f line 99-109
|
||||
## ROLL -15 & PULL
|
||||
#dir0(1) = 0.
|
||||
#dir0(2) = -sd15
|
||||
#dir0(3) = -cd15
|
||||
#call vxfrmc(rwep,dir0,dir0,2)
|
||||
## DIR0 IS UNIT ACCELERATION VECTOR IN DESIRED MANEUVER PLANE
|
||||
#call manpln(dir0,gmxsu)
|
||||
double sd15 = 0.2588190;
|
||||
double cd15 = 0.9659258;
|
||||
dir0 = Vec3.Construct(0.0, -sd15, -cd15);
|
||||
dir0 = brawlerPlatform.ConvertWindtoNED(dir0);
|
||||
double gmxsu = brawlerPlatform.MaxTacticalGs();
|
||||
#call manpln(dir0,gmxsu)
|
||||
#manpln() - maneuver in plane: replicated in 6 lines below
|
||||
dir0 = vorth(dir0, PLATFORM.VelocityNED());
|
||||
dir0.Normalize();
|
||||
int iactn = 4;
|
||||
gmx = gmxsu;
|
||||
spd0 = 3.0;
|
||||
int spdmod = 2; //thrttl
|
||||
|
||||
### Project and Evaluate (Score) Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithThrottle(dir0, gmx, spd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
PLATFORM.FlyVectorWithThrottle(dir0, gmx, spd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
331
platforms/brawler/alternatives/behavior_alt3441_tail_attack.txt
Normal file
331
platforms/brawler/alternatives/behavior_alt3441_tail_attack.txt
Normal file
@@ -0,0 +1,331 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt34.f -> alt344.f
|
||||
// Replicates the 3,4,4,1 alternative behavior
|
||||
// alt3441_tail_attack
|
||||
|
||||
include_once BrawlerScriptUtil.txt
|
||||
|
||||
behavior alt3441_tail_attack
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
WsfLocalTrack targetTrack;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3441Enabled = true;
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 4;
|
||||
int icall = 4;
|
||||
int lcall = 1;
|
||||
|
||||
Vec3 a0; # maneuver plane
|
||||
Vec3 dir0; # direction vector
|
||||
double gmx; # max Gs
|
||||
double spd0; # speed or throttle setting (depending on spdmod)
|
||||
int spdmod;
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
double grav = 32.17405;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
|
||||
#when talatk() is done:
|
||||
# dir0 is normalized
|
||||
# spd0 is in units of ft/sec (or set to 3.0 for throttle mode)
|
||||
script void talatk()
|
||||
writeln_d("alt3441 tail attack: talatk");
|
||||
# # local declarations
|
||||
# integer jacid
|
||||
# real t,pres,dens,vs,pr,dr,xcarot(3),vcarot(3)
|
||||
# real xprj(3),vprj(3),rhprj(3,3),dlag,dlagn,dlagun,vtemp(3)
|
||||
# real dxtail(3),aprj(3),ause(3),dt,spdwtd,x_tgt(3)
|
||||
# data dlagn/5000./,dlagun/1000./
|
||||
# # ENDDEC
|
||||
# # SET TARGET POSITION BEHIND TARGET A/C A DISTANCE DLAG
|
||||
# jacid = iacidt(iac)
|
||||
# dlag=dlagn
|
||||
# if(.not.noaim) dlag= (ppmrmn+ppmrmx)/2.
|
||||
# if(mslpp.eq.nummis+1) dlag= dlagun
|
||||
# # GET POSITION OF AC 5 SECONDS IN FUTURE:
|
||||
# dt = 5.
|
||||
# #if (xp(3,iac).ge.trkr_neg_alt) call nabort('talatk...tgt more than /par/trkr_neg_alt feet below ground')
|
||||
# call xmit3(xp(1,iac),x_tgt)
|
||||
# if (x_tgt(3).ge.0.) x_tgt(3) = -1.0
|
||||
# call atmos(-x_tgt(3),t,pres,dens,vs,pr,dr)
|
||||
# call a_lim(x_tgt,vp(1,iac),ap(1,iac),dt,casmin(iac)/sqrt(dr),ause)
|
||||
# call projw(x_tgt,vp(1,iac),ause,dt,xprj,vprj,aprj,rhprj)
|
||||
# call vmake(-dlag,vprj,vtemp)
|
||||
# call vsum(x_tgt,vtemp,dxtail)
|
||||
# call vsub(dxtail,xp(1,me),dxtail)
|
||||
# call vecinc(vp(1,iac),0.5/tproj3,dxtail,dir0)
|
||||
# spd0 = xmag(dir0)
|
||||
# spdmod = desspd
|
||||
# spdwtd = spdnow(me)+almax*tproj3*1.1
|
||||
# if (spd0 .gt. spdwtd)
|
||||
# {
|
||||
# spd0 = 3.
|
||||
# spdmod = thrttl
|
||||
# }
|
||||
# call vnorm(dir0,dir0)
|
||||
|
||||
|
||||
|
||||
|
||||
double dlagn = 5000.0;
|
||||
double dlagun = 1000.0;
|
||||
double dlag = dlagn;
|
||||
|
||||
## check if we have a weapon task - it shouldn't reach this point if we didn't
|
||||
#if(.not.noaim) dlag= (ppmrmn+ppmrmx)/2.
|
||||
## check if we have a weapon, otherwise close at gun range
|
||||
#if(mslpp.eq.nummis+1) dlag= dlagun
|
||||
if (!HaveWeapon(PLATFORM))
|
||||
{
|
||||
dlag = dlagun;
|
||||
}
|
||||
|
||||
# GET POSITION OF AC 5 SECONDS IN FUTURE:
|
||||
double dt = 5.0;
|
||||
#if (xp(3,iac).ge.trkr_neg_alt) call nabort('talatk...tgt more than /par/trkr_neg_alt feet below ground')
|
||||
|
||||
# call xmit3(xp(1,iac),x_tgt)
|
||||
|
||||
# ##LBM - dont do projection for now
|
||||
# if (x_tgt(3).ge.0.) x_tgt(3) = -1.0
|
||||
# call atmos(-x_tgt(3),t,pres,dens,vs,pr,dr)
|
||||
# call a_lim(x_tgt,vp(1,iac),ap(1,iac),dt,casmin(iac)/sqrt(dr),ause)
|
||||
# call projw(x_tgt,vp(1,iac),ause,dt,xprj,vprj,aprj,rhprj)
|
||||
|
||||
//LBM - not able to perceive target's acceleration
|
||||
//assume target's velocity after dt is same as now
|
||||
|
||||
//LBM - convert everything to feet when calculating against BRAWLER constants
|
||||
// convert back to meters to call WSF commands
|
||||
Vec3 vprj = targetTrack.VelocityNED();
|
||||
Vec3 vtemp = vprj.Normal();
|
||||
vtemp.Scale(-dlag);
|
||||
# Vec3 x_tgt; //target position
|
||||
# Vec3 xp; //my position
|
||||
# Vec3 dxtail = Vec3.Add(x_tgt,vtemp); #adding vtemp is not accounted for in the line below
|
||||
# dxtail = Vec3.Subtract(dxtail,xp);
|
||||
Vec3 dx = RelativePositionNED(PLATFORM.Location(), targetTrack.CurrentLocation());
|
||||
dx.Scale(MATH.FT_PER_M());
|
||||
Vec3 dxtail = Vec3.Add(dx,vtemp);
|
||||
|
||||
Vec3 vpt = targetTrack.VelocityNED();
|
||||
vpt.Scale(MATH.FT_PER_M());
|
||||
dxtail.Scale(0.5/brawlerPlatform.ProjectedTimeDelta());
|
||||
dir0 = Vec3.Add(vpt,dxtail);
|
||||
spd0 = dir0.Magnitude(); #ft/sec
|
||||
spdmod = 1; //(desspd = 1, thrttl = 2, desacc = 3)
|
||||
#double almax = brawlerPlatform.MaxForwardAccelWithGravity() * MATH.M_PER_FT();
|
||||
double almax = brawlerPlatform.MaxForwardAccelWithGravity(); #ft/sec^2
|
||||
double spdwtd = PLATFORM.Speed()*MATH.FT_PER_M() + almax * brawlerPlatform.ProjectedTimeDelta() * 1.1;
|
||||
if (spd0 > spdwtd)
|
||||
{
|
||||
spd0 = 3.0;
|
||||
spdmod = 2; //(desspd = 1, thrttl = 2, desacc = 3)
|
||||
}
|
||||
dir0.Normalize();
|
||||
end_script
|
||||
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition alt3441 tail_attack, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3441Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() <= 0)
|
||||
{
|
||||
writeln_d("no weapon (target) tasks!");
|
||||
return Failure("no weapon (target) tasks!");
|
||||
}
|
||||
WsfTask targetTask = tasks.Entry(0);
|
||||
targetTrack = PLATFORM.MasterTrackList().Find(targetTask.LocalTrackId());
|
||||
if (!targetTrack.IsValid())
|
||||
{
|
||||
writeln_d("no target track!");
|
||||
return Failure("no target track!");
|
||||
}
|
||||
if (!targetTrack.VelocityValid())
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " target track does not have valid velocity!");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
##alt344.f line 172 - 224
|
||||
int iactn = 4;
|
||||
# GENERATE TURNS IN MANEUVER PLANE CONTAINING LOS TO OPPONENT
|
||||
Vec3 dxpme = RelativePositionNED(PLATFORM.Location(),targetTrack.CurrentLocation());
|
||||
Vec3 vp = PLATFORM.VelocityNED();
|
||||
Vec3 vp_iac = targetTrack.VelocityNED();
|
||||
bool bhndme = (Vec3.Dot(dxpme,vp) < 0.0);
|
||||
bool bhndhm = (Vec3.Dot(dxpme,vp_iac) > 0.0);
|
||||
|
||||
if (bhndme && bhndhm)
|
||||
{
|
||||
# BEHIND EACH OTHER: WANT COURSE REVERSAL
|
||||
# USE TAIL ATTACK FOR NOW
|
||||
talatk();
|
||||
}
|
||||
else if (bhndme && !bhndhm)
|
||||
{
|
||||
# HE'S ON MY TAIL!: NO TAIL ATTACK ALTERNATIVE GENERATED
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " HE IS ON MY TAIL! NO TAIL ATTACK!");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
else if (!bhndme && bhndhm)
|
||||
{
|
||||
# I'M ON HIS TAIL!: GENERATE TAIL ATTACK
|
||||
talatk();
|
||||
}
|
||||
else if (!bhndme && !bhndhm)
|
||||
{
|
||||
# NOSE TO NOSE: PLAN INTERCEPT
|
||||
#call aimpt(xp(1,me),spdnow(me),xp(1,iac),vp(1,iac),spdnow(iac),daimpt,lsoln);
|
||||
WsfWaypoint aimptWP = WsfWaypoint();
|
||||
double intTime = PLATFORM.InterceptLocation3D(targetTrack, aimptWP);
|
||||
#if (lsoln)
|
||||
if (intTime > 0)
|
||||
{
|
||||
WsfGeoPoint daimpt = aimptWP.Location();
|
||||
#call vsub(daimpt,xp(1,me),dxaim);
|
||||
Vec3 dxaim = RelativePositionNED(PLATFORM.Location(), daimpt); #NED coordinates
|
||||
dir0 = dxaim.Normal();
|
||||
spd0 = 3.0;
|
||||
spdmod = 2; //(desspd = 1, thrttl = 2, desacc = 3)
|
||||
}
|
||||
else
|
||||
{
|
||||
//return Failure("ERROR: intercept somehow not possible, even though head to head with target!");
|
||||
# ASSUME OVERSHOOT, SO TRY A TAIL ATTACK
|
||||
talatk();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//call nabort('AL344...UNKNOWN GEOMETRY');
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " ...UNKNOWN GEOMETRY");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
//lmore = .true.
|
||||
double gmxsu = brawlerPlatform.MaxTacticalGs();
|
||||
gmx = gmxsu;
|
||||
|
||||
### Project and Evaluate (Score) Maneuver Alternative
|
||||
double score = 0;
|
||||
if (spdmod == 2)
|
||||
{
|
||||
score = brawlerPlatform.EvaluateVectorWithThrottle(dir0, gmx, spd0, ilevel, kalt, icall, lcall);
|
||||
}
|
||||
else
|
||||
{
|
||||
score = brawlerPlatform.EvaluateVectorWithSpeed(dir0, gmx, spd0 * MATH.M_PER_FT(), ilevel, kalt, icall, lcall);
|
||||
}
|
||||
writeln_d("T=", TIME_NOW, ", 3441_tail_attack = ", score);
|
||||
|
||||
writeln_d("raw = ", brawlerPlatform.RawManeuverValueComponent("offensive"),
|
||||
", ", brawlerPlatform.RawManeuverValueComponent("low speed recovery"),
|
||||
", ", brawlerPlatform.RawManeuverValueComponent("defensive"),
|
||||
", ", brawlerPlatform.RawManeuverValueComponent("illumination"),
|
||||
", ", brawlerPlatform.RawManeuverValueComponent("missile evasion"),
|
||||
", ", brawlerPlatform.RawManeuverValueComponent("missile aiming"));
|
||||
|
||||
writeln_d("component = ", brawlerPlatform.ManeuverValueComponent("offensive"),
|
||||
", ", brawlerPlatform.ManeuverValueComponent("low speed recovery"),
|
||||
", ", brawlerPlatform.ManeuverValueComponent("defensive"),
|
||||
", ", brawlerPlatform.ManeuverValueComponent("illumination"),
|
||||
", ", brawlerPlatform.ManeuverValueComponent("missile evasion"),
|
||||
", ", brawlerPlatform.ManeuverValueComponent("missile aiming"));
|
||||
|
||||
writeln_d("tunnel = ", brawlerPlatform.TunnelVisionMultiplier("offensive"),
|
||||
", ", brawlerPlatform.TunnelVisionMultiplier("low speed recovery"),
|
||||
", ", brawlerPlatform.TunnelVisionMultiplier("defensive"),
|
||||
", ", brawlerPlatform.TunnelVisionMultiplier("illumination"),
|
||||
", ", brawlerPlatform.TunnelVisionMultiplier("missile evasion"),
|
||||
", ", brawlerPlatform.TunnelVisionMultiplier("missile aiming"));
|
||||
|
||||
writeln_d("bias = ", brawlerPlatform.InherentBiasFaults("aggressiveness"),
|
||||
", ", brawlerPlatform.InherentBiasFaults("mutual support"),
|
||||
", ", brawlerPlatform.InherentBiasFaults("airspeed maintenance"));
|
||||
|
||||
writeln_d("mult = ", brawlerPlatform.OffensiveMultiplier(),
|
||||
", ", brawlerPlatform.DefensiveMultiplier());
|
||||
|
||||
if (targetTrack.Target().IsValid())
|
||||
{
|
||||
writeln_d("engage = ", brawlerPlatform.LastEngagementValue(targetTrack.Target()));
|
||||
}
|
||||
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
writeln_d("3441_tail_attack");
|
||||
## what was evaluated should be actually performed now
|
||||
if (spdmod == 2)
|
||||
{
|
||||
PLATFORM.FlyVectorWithThrottle(dir0, gmx, spd0);
|
||||
}
|
||||
else
|
||||
{
|
||||
PLATFORM.FlyVectorWithSpeed(dir0, gmx, spd0 * MATH.M_PER_FT());
|
||||
}
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt34.f -> alt345.f
|
||||
// Replicates the 3,4,5,1 alternative behavior
|
||||
// alt3451_pull_gmax_sust
|
||||
|
||||
include_once BrawlerScriptUtil.txt
|
||||
|
||||
behavior alt3451_pull_gmax_sust
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3451Enabled = true;
|
||||
bool mCheckRollOverTopValue = true; #this alternative assumes a different one has already evaluated and flown (to set the roll over the top value)
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 4;
|
||||
int icall = 5;
|
||||
int lcall = 1;
|
||||
|
||||
Vec3 a0; # maneuver plane
|
||||
Vec3 dir0; # direction vector
|
||||
double gmx; # max Gs
|
||||
double spd0; # throttle setting
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
double grav = 32.17405;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition alt3451 pull_gmax_sust, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3451Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
##alt34.f line 160 //filter out this alternative?
|
||||
double valrot = brawlerPlatform.RollOverTopValue();
|
||||
if(mCheckRollOverTopValue == true && valrot == 0.0)
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " valrot == 0");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
##alt345.f line 104 - 119
|
||||
#iactn = 4
|
||||
#call makeh(vp(1,me),rot)
|
||||
#dir0(1) = 0.001
|
||||
#dir0(2) = 0.0
|
||||
#dir0(3) = -1.000
|
||||
#call vxfrmc(rot,dir0,dir0,2)
|
||||
#call vnorm(dir0,dir0)
|
||||
#gmx = gmxsu
|
||||
#spd0 = 3.
|
||||
#spdmod = thrttl
|
||||
|
||||
int iactn = 4;
|
||||
Vec3 vp = PLATFORM.VelocityNED();
|
||||
Array<double> rot = makeh(vp);
|
||||
dir0 = Vec3.Construct(0.001, 0.0, -1.0);
|
||||
dir0 = vxfrmc2(rot, dir0);
|
||||
dir0.Normalize();
|
||||
double gmxsu = brawlerPlatform.MaxTacticalGs();
|
||||
gmx = gmxsu;
|
||||
spd0 = 3.0;
|
||||
int spdmod = 2; //thrttl // spdmod = thrttl (desspd = 1, thrttl = 2, desacc = 3)
|
||||
|
||||
### Project and Evaluate (Score) Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithThrottle(dir0, gmx, spd0, ilevel, kalt, icall, lcall);
|
||||
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
PLATFORM.FlyVectorWithThrottle(dir0, gmx, spd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt34.f -> alt347.f
|
||||
// Replicates the 3,4,7,1 alternative behavior
|
||||
// alt3471_slow_current_dir
|
||||
|
||||
behavior alt3471_slow_current_dir
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3471Enabled = true;
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 4;
|
||||
int icall = 7;
|
||||
int lcall = 1;
|
||||
|
||||
Vec3 a0; # maneuver plane
|
||||
Vec3 dir0; # direction vector
|
||||
double gmx; # max Gs
|
||||
double spd0; # throttle setting
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
double grav = 32.17405;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition alt3471 slow_current_dir, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3471Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
##alt347.f line 108 //initialize value
|
||||
#call vnorm(vp(1,me),myvdir)
|
||||
##alt347.f line 124 - 134
|
||||
#iactn=4
|
||||
#call xmit(3,myvdir,dir0)
|
||||
#gmx=amin1(3.,gmxsu)
|
||||
#spd0=spdnow(me)+almin*tproj3*1.1
|
||||
#spd0 = amax1(200.,spd0)
|
||||
#spdmod = desspd
|
||||
|
||||
Vec3 myvdir = PLATFORM.VelocityNED().Normal();
|
||||
int iactn = 4;
|
||||
dir0 = myvdir;
|
||||
double gmxsu = brawlerPlatform.MaxTacticalGs();
|
||||
gmx = MATH.Min(3.0,gmxsu);
|
||||
double almin = brawlerPlatform.MinForwardAccelWithGravity(); #ft/sec^2
|
||||
spd0 = PLATFORM.Speed() * MATH.FT_PER_M() + almin * brawlerPlatform.ProjectedTimeDelta() * 1.1;
|
||||
spd0 = MATH.Max(200.0, spd0);
|
||||
spd0 *= MATH.M_PER_FT();
|
||||
int spdmod = 1; //desspd // spdmod = thrttl (desspd = 1, thrttl = 2, desacc = 3)
|
||||
|
||||
### Project and Evaluate (Score) Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithSpeed(dir0, gmx, spd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
PLATFORM.FlyVectorWithSpeed(dir0, gmx, spd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt34.f -> alt347.f
|
||||
// Replicates the 3,4,7,2 alternative behavior
|
||||
// alt3472_slow_pull_right
|
||||
|
||||
behavior alt3472_slow_pull_right
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3472Enabled = true;
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 4;
|
||||
int icall = 7;
|
||||
int lcall = 2;
|
||||
|
||||
Vec3 a0; # maneuver plane
|
||||
Vec3 dir0; # direction vector
|
||||
double gmx; # max Gs
|
||||
double spd0; # throttle setting
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
double grav = 32.17405;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition alt3472 slow_pull_right, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3472Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
##alt347.f line 108 //initialize value
|
||||
#call vnorm(vp(1,me),myvdir)
|
||||
##alt347.f line 135 - 148
|
||||
#iactn=4
|
||||
#acc0(1)=0.
|
||||
#acc0(2)=sroll
|
||||
#acc0(3)=-croll
|
||||
#call vxfrmc(rwep,dir0,acc0,2)
|
||||
#gmx=gmxsu
|
||||
#spd0=spdnow(me)+almin*tproj3*1.1
|
||||
#spd0 = amax1(200.,spd0)
|
||||
#spdmod = desspd
|
||||
|
||||
Vec3 myvdir = PLATFORM.VelocityNED().Normal();
|
||||
int iactn = 4;
|
||||
double sroll = 0.2588190; //sin of roll angle (15 deg)
|
||||
double croll = 0.9659258; //cos of roll angle (15 deg)
|
||||
Vec3 acc0 = Vec3.Construct(0.0, sroll, -croll);
|
||||
dir0 = brawlerPlatform.ConvertWindtoNED(acc0);
|
||||
double gmxsu = brawlerPlatform.MaxTacticalGs();
|
||||
gmx = gmxsu;
|
||||
double almin = brawlerPlatform.MinForwardAccelWithGravity();
|
||||
spd0 = PLATFORM.Speed() * MATH.FT_PER_M() + almin * brawlerPlatform.ProjectedTimeDelta() * 1.1;
|
||||
spd0 = MATH.Max(200.0, spd0);
|
||||
spd0 *= MATH.M_PER_FT();
|
||||
int spdmod = 1; //desspd // spdmod = thrttl (desspd = 1, thrttl = 2, desacc = 3)
|
||||
|
||||
### Project and Evaluate (Score) Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithSpeed(dir0, gmx, spd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
PLATFORM.FlyVectorWithSpeed(dir0, gmx, spd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt34.f -> alt347.f
|
||||
// Replicates the 3,4,7,3 alternative behavior
|
||||
// alt3473_slow_pull_left
|
||||
|
||||
behavior alt3473_slow_pull_left
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3473Enabled = true;
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 4;
|
||||
int icall = 7;
|
||||
int lcall = 3;
|
||||
|
||||
Vec3 a0; # maneuver plane
|
||||
Vec3 dir0; # direction vector
|
||||
double gmx; # max Gs
|
||||
double spd0; # throttle setting
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
double grav = 32.17405;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition alt3473 slow_pull_left, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3473Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
##alt347.f line 108 //initialize value
|
||||
#call vnorm(vp(1,me),myvdir)
|
||||
##alt347.f line 150 - 163
|
||||
#iactn=4
|
||||
#acc0(1)=0.
|
||||
#acc0(2)=-sroll
|
||||
#acc0(3)=-croll
|
||||
#call vxfrmc(rwep,dir0,acc0,2)
|
||||
#gmx=gmxsu
|
||||
#spd0=spdnow(me)+almin*tproj3*1.1
|
||||
#spd0 = amax1(200.,spd0)
|
||||
#spdmod = desspd
|
||||
|
||||
Vec3 myvdir = PLATFORM.VelocityNED().Normal();
|
||||
int iactn = 4;
|
||||
double sroll = 0.2588190; //sin of roll angle (15 deg)
|
||||
double croll = 0.9659258; //cos of roll angle (15 deg)
|
||||
Vec3 acc0 = Vec3.Construct(0.0, -sroll, -croll);
|
||||
dir0 = brawlerPlatform.ConvertWindtoNED(acc0);
|
||||
double gmxsu = brawlerPlatform.MaxTacticalGs();
|
||||
gmx = gmxsu;
|
||||
double almin = brawlerPlatform.MinForwardAccelWithGravity();
|
||||
spd0 = PLATFORM.Speed() * MATH.FT_PER_M() + almin * brawlerPlatform.ProjectedTimeDelta() * 1.1;
|
||||
spd0 = MATH.Max(200.0, spd0);
|
||||
spd0 *= MATH.M_PER_FT();
|
||||
int spdmod = 1; //desspd // spdmod = thrttl (desspd = 1, thrttl = 2, desacc = 3)
|
||||
|
||||
### Project and Evaluate (Score) Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithSpeed(dir0, gmx, spd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
PLATFORM.FlyVectorWithSpeed(dir0, gmx, spd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt34.f -> alt347.f
|
||||
// Replicates the 3,4,7,4 alternative behavior
|
||||
// alt3474_slow_pull_current_plane
|
||||
|
||||
behavior alt3474_slow_pull_current_plane
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3474Enabled = true;
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 4;
|
||||
int icall = 7;
|
||||
int lcall = 4;
|
||||
|
||||
Vec3 a0; # maneuver plane
|
||||
double gmx; # max Gs
|
||||
double spd0; # throttle setting
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
double grav = 32.17405;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition alt3474 slow_pull_current_plane, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3474Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
##alt347.f line 108 //initialize value
|
||||
#call vnorm(vp(1,me),myvdir)
|
||||
##alt347.f line 165 - 183
|
||||
#if(xmag(ap(1,me)).lt.0.1)then
|
||||
# //FAIL
|
||||
#endif
|
||||
#iactn=3
|
||||
#call cross(myvdir,ap(1,me),a0)
|
||||
#call vnorm(a0,a0)
|
||||
#gmx = gmxsu*grav
|
||||
#--spd0 is a throttle setting under the NEW iactn=3 format
|
||||
#spd0 = -1.0
|
||||
|
||||
Vec3 myvdir = PLATFORM.VelocityNED().Normal();
|
||||
Vec3 ap = PLATFORM.AccelerationNED(); //meters/sec^2
|
||||
ap.Scale(Math.FT_PER_M()); //convert to feet/sec^2
|
||||
if(ap.Magnitude() < 0.1)
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " acceleration not high enough to clearly define a maneuever plane!");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
int iactn = 3;
|
||||
a0 = Vec3.Cross(myvdir, ap).Normal();
|
||||
double gmxsu = brawlerPlatform.MaxTacticalGs();
|
||||
gmx = gmxsu*grav;
|
||||
#--spd0 is a throttle setting under the NEW iactn=3 format
|
||||
#spd0 = -1.0; //this means 100% thrust reversal setting
|
||||
spd0 = 1.0; //NO thrust reversal in brawler -> -1 gets converted to 1 (mil power)
|
||||
|
||||
### Project and Evaluate (Score) Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateTurnInPlaneWithThrottle(a0, gmx, spd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
PLATFORM.PullGsInPlaneWithThrottle(a0, gmx, spd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
207
platforms/brawler/alternatives/behavior_alt3511_break_right.txt
Normal file
207
platforms/brawler/alternatives/behavior_alt3511_break_right.txt
Normal file
@@ -0,0 +1,207 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt35.f
|
||||
// Replicates the 1v1 Defensive Maneuver 3,5,1,1 alternative behavior
|
||||
// Defensive right break turn
|
||||
// Operates on nearest perceived threat to generate maneuver alternative
|
||||
|
||||
include_once BrawlerScriptUtil.txt
|
||||
|
||||
behavior alt3511_break_right
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3511Enabled = true;
|
||||
bool mCheckRange = true;
|
||||
bool mCheckBoresight = true;
|
||||
bool mCheckClosingSpeed = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 5;
|
||||
int icall = 1;
|
||||
int lcall = 1;
|
||||
|
||||
// Maneuver Alternative flight values
|
||||
Vec3 mDir0;
|
||||
double mGMX = 1.0;
|
||||
double mSpd0 = 3.0;
|
||||
|
||||
// ALSO NEED:
|
||||
// randomization to simulate imperfect desision making, valsig, read from MIND file, typically ~0.01
|
||||
// Production rule bias, used in socring of alternative
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3511_break_right, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3511Enabled)
|
||||
{
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() <= 0)
|
||||
{
|
||||
return Failure("no weapon (hostile) tasks!");
|
||||
}
|
||||
WsfTask targetTask = tasks.Entry(0);
|
||||
WsfLocalTrack hostile = PLATFORM.MasterTrackList().Find(targetTask.LocalTrackId());
|
||||
if (!hostile.IsValid())
|
||||
{
|
||||
return Failure("no hostile track!");
|
||||
}
|
||||
|
||||
//TODO - change this script so it doesn't use a truth method?
|
||||
if (hostile.TargetKilled())
|
||||
{
|
||||
return Failure("hostile was destroyed!");
|
||||
}
|
||||
|
||||
// alt35.f line 136 - 140
|
||||
//if the predicted range (rngun) between me and threat greater then 2 nautical miles, skip
|
||||
double projectionTime = TIME_NOW + brawlerPlatform.ProjectedTimeDelta();
|
||||
WsfGeoPoint projectedHostileLocation = hostile.LocationAtTime(projectionTime);
|
||||
double rangeToHostile = PLATFORM.SlantRangeTo(projectedHostileLocation);
|
||||
if (mCheckRange == true && rangeToHostile > 2.0 * Math.M_PER_NM())
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " nearest hostile further than 2 nautical miles");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
//if the off-bore angle between threat and me is greater than pi/2, skip
|
||||
if (mCheckBoresight == true && brawlerPlatform.OffBoresightAngle(hostile.Target(), PLATFORM) > Math.PI_OVER_2())
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " Boresight angle between hostile and me greater than Pi/2");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
//if the off-bore angle between me and the threat is less than pi/2 check more conditions
|
||||
if (mCheckBoresight == true && brawlerPlatform.OffBoresightAngle(PLATFORM, hostile.Target()) < Math.PI_OVER_2())
|
||||
{
|
||||
//if the predicted range rate (rngrun) of the threat is greater then zero, skip
|
||||
if (mCheckClosingSpeed == true && PLATFORM.ClosingSpeedOf(hostile) > 0)
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " Hostile is not closing");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
//if the predicted range minus the range rate * 2 is greater than 3000, skip
|
||||
if (mCheckRange == true && rangeToHostile * Math.FT_PER_M() - (PLATFORM.ClosingSpeedOf(hostile) * 3.28084 * 2.0) > 3000.0)
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " Hostile further than 3000 ft within 2 seconds");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// ALL CONDITIONS PASS
|
||||
### Generate Maneuver Alternative
|
||||
// alt35.f line 141 - 153
|
||||
# fill dir0 with values from dxpme(1,iac)
|
||||
# vxfrmc(rwep,dir0,dir0,1) - transforms vectors as specified by an orientation matrix
|
||||
# dir0(1) = 0
|
||||
# vxfrmc(rwep,dir0,dir0,2)
|
||||
# if(-xp(3,me).lt.5000.) dir0(3) = amin1(0.,dir0(3))
|
||||
# vnorm(dir0,dir0)
|
||||
# gmx = gmxin+(2.-gmxin)*ramp(1.,rngun(iac)*ftnmi,2.)
|
||||
# iactn = 4
|
||||
# lenalt = lactn(iactn)
|
||||
# altdsc = altpk(3,5,icall,1,iacidt(iac),0)
|
||||
# spd0 = 3.
|
||||
# spdmod = thrttl
|
||||
|
||||
mDir0 = RelativePositionNED(PLATFORM.Location(), projectedHostileLocation);
|
||||
mDir0 = brawlerPlatform.ConvertNEDtoWind(mDir0);
|
||||
mDir0.SetX(0.0);
|
||||
mDir0 = brawlerPlatform.ConvertWindtoNED(mDir0);
|
||||
if (PLATFORM.Altitude() < 5000.0 * Math.M_PER_FT())
|
||||
{
|
||||
mDir0.SetZ( Math.Min(0.0, mDir0.Z()) );
|
||||
}
|
||||
mDir0.Normalize();
|
||||
mGMX = brawlerPlatform.MaxAvailableGs() + (2.0 - brawlerPlatform.MaxAvailableGs()) *
|
||||
ramp(1.0, rangeToHostile * Math.M_PER_NM(), 2.0);
|
||||
mSpd0 = 3.0;
|
||||
|
||||
### Evaluate (Score) Maneuver Alternative
|
||||
double alternativeScore = brawlerPlatform.EvaluateVectorWithThrottle(mDir0, mGMX, mSpd0, ilevel, kalt, icall, lcall);
|
||||
|
||||
### Return Maneuver Alternative Score
|
||||
return alternativeScore;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
writeln_d(PLATFORM.Name(), " executing behavior_alt3511_break_right, T=", TIME_NOW);
|
||||
// Fly this alternative
|
||||
brawlerPlatform.FlyVectorWithThrottle(mDir0, mGMX, mSpd0);
|
||||
|
||||
# if (mDrawSteering == true)
|
||||
# {
|
||||
# mDraw.SetLayer("behavior_pursue_target");
|
||||
# mDraw.SetDuration(processor.UpdateInterval());
|
||||
# mDraw.SetColor(1.0, 0.5, 0.0);
|
||||
# mDraw.SetLineSize(1);
|
||||
# mDraw.BeginLines();
|
||||
# mDraw.Vertex(PLATFORM.Location());
|
||||
# mDraw.Vertex(mTargetPoint);
|
||||
# mDraw.End();
|
||||
# }
|
||||
#
|
||||
# string msg = write_str("pursue-target: ", targetTrack.TargetName(), " at speed ", (string)mTargetSpeed);
|
||||
# writeln_d(" T=", TIME_NOW, " ", PLATFORM.Name(), " ", msg);
|
||||
# FlyTarget( PLATFORM, mTargetPoint, mTargetSpeed);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
210
platforms/brawler/alternatives/behavior_alt3531_break_left.txt
Normal file
210
platforms/brawler/alternatives/behavior_alt3531_break_left.txt
Normal file
@@ -0,0 +1,210 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt35.f
|
||||
// Replicates the 1v1 Defensive Maneuver 3,5,3,1 alternative behavior
|
||||
// Defensive left break turn
|
||||
// Operates on nearest perceived threat to generate maneuver alternative
|
||||
|
||||
include_once BrawlerScriptUtil.txt
|
||||
|
||||
behavior alt3531_break_left
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3531Enabled = true;
|
||||
bool mCheckRange = true;
|
||||
bool mCheckBoresight = true;
|
||||
bool mCheckClosingSpeed = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 5;
|
||||
int icall = 3;
|
||||
int lcall = 1;
|
||||
|
||||
// Maneuver Alternative flight values
|
||||
Vec3 mDir0;
|
||||
double mGMX = 1.0;
|
||||
double mSpd0 = 3.0;
|
||||
|
||||
// ALSO NEED:
|
||||
// randomization to simulate imperfect desision making, valsig, read from MIND file, typically ~0.01
|
||||
// Production rule bias, used in socring of alternative
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3531_break_left, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3531Enabled)
|
||||
{
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() <= 0)
|
||||
{
|
||||
return Failure("no weapon (hostile) tasks!");
|
||||
}
|
||||
WsfTask targetTask = tasks.Entry(0);
|
||||
WsfLocalTrack hostile = PLATFORM.MasterTrackList().Find(targetTask.LocalTrackId());
|
||||
if (!hostile.IsValid())
|
||||
{
|
||||
return Failure("no hostile track!");
|
||||
}
|
||||
|
||||
//TODO - change this script so it doesn't use a truth method?
|
||||
if (hostile.TargetKilled())
|
||||
{
|
||||
return Failure("hostile was destroyed!");
|
||||
}
|
||||
|
||||
// alt35.f line 184 - 188
|
||||
# if(rngun(iac)*ftnmi .gt. 2.) go to 205
|
||||
# if(obang(iac,me) .gt. hafpi) go to 205
|
||||
# if(obang(me,iac).gt.hafpi) go to 232
|
||||
# if(rngrun(iac) .gt. 0.) go to 205
|
||||
# if(rngun(iac)-rngrun(iac)*2. .gt. 3000.) go to 205
|
||||
//if the predicted range (rngun) between me and threat greater then 2 nautical miles, skip
|
||||
double projectionTime = TIME_NOW + brawlerPlatform.ProjectedTimeDelta();
|
||||
WsfGeoPoint projectedHostileLocation = hostile.LocationAtTime(projectionTime);
|
||||
double rangeToHostile = PLATFORM.SlantRangeTo(projectedHostileLocation);
|
||||
if (mCheckRange == true && rangeToHostile > 2.0 * Math.M_PER_NM())
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " nearest hostile further than 2 nautical miles");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
//if the off-bore angle between threat and me is greater than pi/2, skip
|
||||
if (mCheckBoresight == true && brawlerPlatform.OffBoresightAngle(hostile.Target(), PLATFORM) > Math.PI_OVER_2())
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " Boresight angle between hostile and me greater than Pi/2");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
//if the off-bore angle between me and the threat is less than pi/2 check more conditions
|
||||
if (mCheckBoresight == true && brawlerPlatform.OffBoresightAngle(PLATFORM, hostile.Target()) < Math.PI_OVER_2())
|
||||
{
|
||||
//if the predicted range rate (rngrun) of the threat is greater then zero, skip
|
||||
if (mCheckClosingSpeed == true && PLATFORM.ClosingSpeedOf(hostile) > 0)
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " Hostile is not closing");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
//if the predicted range minus the range rate * 2 is greater than 3000, skip
|
||||
if (mCheckRange == true && rangeToHostile * Math.FT_PER_M() - (PLATFORM.ClosingSpeedOf(hostile) * 3.28084 * 2.0) > 3000.0)
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " Hostile further than 3000 ft within 2 seconds");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// ALL CONDITIONS PASS
|
||||
### Generate Maneuver Alternative
|
||||
// alt35.f line 189 - 201
|
||||
#232 continue
|
||||
# call xmit(3,dxp(1,me,iac),dir0)
|
||||
# call vxfrmc(rwep,dir0,dir0,1)
|
||||
# dir0(1) = 0.
|
||||
# call vxfrmc(rwep,dir0,dir0,2)
|
||||
# if(-xp(3,me).lt.5000.) dir0(3) = amin1(0.,dir0(3))
|
||||
# call vnorm(dir0,dir0)
|
||||
# gmx = gmxin+(2.-gmxin)*ramp(1.,rngun(iac)*ftnmi,2.)
|
||||
# iactn = 4
|
||||
# lenalt = lactn(iactn)
|
||||
# altdsc = altpk(3,5,icall,1,iacidt(iac),0)
|
||||
# spd0 = 3.
|
||||
# spdmod = thrttl
|
||||
mDir0 = RelativePositionNED(PLATFORM.Location(), projectedHostileLocation);
|
||||
mDir0 = brawlerPlatform.ConvertNEDtoWind(mDir0);
|
||||
mDir0.SetX(0.0);
|
||||
mDir0 = brawlerPlatform.ConvertWindtoNED(mDir0);
|
||||
if (PLATFORM.Altitude() < 5000.0 * Math.M_PER_FT())
|
||||
{
|
||||
mDir0.SetZ( Math.Min(0.0, mDir0.Z()) );
|
||||
}
|
||||
mDir0.Normalize();
|
||||
mGMX = brawlerPlatform.MaxAvailableGs() + (2.0 - brawlerPlatform.MaxAvailableGs()) *
|
||||
ramp(1.0, rangeToHostile * Math.M_PER_NM(), 2.0);
|
||||
mSpd0 = 3.0;
|
||||
|
||||
### Evaluate (Score) Maneuver Alternative
|
||||
double alternativeScore = brawlerPlatform.EvaluateVectorWithThrottle(mDir0, mGMX, mSpd0, ilevel, kalt, icall, lcall);
|
||||
|
||||
### Return Maneuver Alternative Score
|
||||
return alternativeScore;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
writeln_d(PLATFORM.Name(), " executing behavior_alt3531_break_left, T=", TIME_NOW);
|
||||
// Fly this alternative
|
||||
brawlerPlatform.FlyVectorWithThrottle(mDir0, mGMX, mSpd0);
|
||||
|
||||
# if (mDrawSteering == true)
|
||||
# {
|
||||
# mDraw.SetLayer("behavior_pursue_target");
|
||||
# mDraw.SetDuration(processor.UpdateInterval());
|
||||
# mDraw.SetColor(1.0, 0.5, 0.0);
|
||||
# mDraw.SetLineSize(1);
|
||||
# mDraw.BeginLines();
|
||||
# mDraw.Vertex(PLATFORM.Location());
|
||||
# mDraw.Vertex(mTargetPoint);
|
||||
# mDraw.End();
|
||||
# }
|
||||
#
|
||||
# string msg = write_str("pursue-target: ", targetTrack.TargetName(), " at speed ", (string)mTargetSpeed);
|
||||
# writeln_d(" T=", TIME_NOW, " ", PLATFORM.Name(), " ", msg);
|
||||
# FlyTarget( PLATFORM, mTargetPoint, mTargetSpeed);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
156
platforms/brawler/alternatives/behavior_alt3551_run_away.txt
Normal file
156
platforms/brawler/alternatives/behavior_alt3551_run_away.txt
Normal file
@@ -0,0 +1,156 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt35.f
|
||||
// Replicates the 1v1 Defensive Maneuver 3,5,5,1 alternative behavior
|
||||
// RUN AWAY!
|
||||
|
||||
include_once BrawlerScriptUtil.txt
|
||||
|
||||
behavior alt3551_run_away
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3551Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 5;
|
||||
int icall = 5;
|
||||
int lcall = 1;
|
||||
|
||||
// Maneuver Alternative flight values
|
||||
Vec3 mDir0 = Vec3();
|
||||
double mGMX = 1.0;
|
||||
double mSpd0 = 3.0;
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3551_run_away, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3551Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() <= 0)
|
||||
{
|
||||
writeln_d("no weapon (hostile) tasks!");
|
||||
return Failure("no weapon (hostile) tasks!");
|
||||
}
|
||||
WsfTask targetTask = tasks.Entry(0);
|
||||
WsfLocalTrack hostile = PLATFORM.MasterTrackList().Find(targetTask.LocalTrackId());
|
||||
if (!hostile.IsValid())
|
||||
{
|
||||
writeln_d("no hostile track!");
|
||||
return Failure("no hostile track!");
|
||||
}
|
||||
|
||||
//TODO - change this script so it doesn't use a truth method?
|
||||
if (hostile.TargetKilled())
|
||||
{
|
||||
writeln_d("hostile was destroyed!");
|
||||
return Failure("hostile was destroyed!");
|
||||
}
|
||||
|
||||
// alt35.f line 233 - 234
|
||||
# rrunmn = 5.*ramp(twopi,obang(iac,me)+obang(me,iac),0.)
|
||||
# if(rngun(iac)*ftnmi .lt. rrunmn) go to 205
|
||||
double obang_hostile_me = brawlerPlatform.OffBoresightAngle(hostile.Target(), PLATFORM);
|
||||
double obang_me_hostile = brawlerPlatform.OffBoresightAngle(PLATFORM, hostile.Target());
|
||||
double rrunmn = 5.0 * ramp(Math.TWO_PI(), obang_hostile_me + obang_me_hostile, 0.0);
|
||||
|
||||
double projectionTime = TIME_NOW + brawlerPlatform.ProjectedTimeDelta();
|
||||
WsfGeoPoint projectedHostileLocation = hostile.LocationAtTime(projectionTime);
|
||||
double rangeToHostile = PLATFORM.SlantRangeTo(projectedHostileLocation);
|
||||
|
||||
if (rangeToHostile * Math.M_PER_NM() < rrunmn)
|
||||
{
|
||||
// Hostile too far
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " range to hostile < minimum range to run");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
// ALL CONDITIONS PASS
|
||||
### Generate Maneuver Alternative
|
||||
// alt35.f line 235 - 243
|
||||
#245 continue
|
||||
# iactn = 4
|
||||
# call vmult(-1.,dxeuan(1,iac),dir0)
|
||||
# lenalt = lactn(iactn)
|
||||
# altdsc = altpk(3,5,icall,1,iacidt(iac),0)
|
||||
# dir0(3) = 0.
|
||||
# gmx = gmxsu
|
||||
# spd0 = 3.
|
||||
# spdmod = thrttl
|
||||
|
||||
Vec3 dxeuan = RelativePositionNED(PLATFORM.Location(), projectedHostileLocation);
|
||||
mDir0.SetX(dxeuan.X() * -1.0);
|
||||
mDir0.SetY(dxeuan.Y() * -1.0);
|
||||
mDir0.SetZ(0.0);
|
||||
mGMX = brawlerPlatform.MaxSustainedGs();
|
||||
mSpd0 = 3.0;
|
||||
|
||||
### Evaluate [Projected] Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithThrottle(mDir0, mGMX, mSpd0, ilevel, kalt, icall, lcall);
|
||||
writeln_d("mDir0 = ", mDir0.ToString(), ", mGMX = ", mGMX, ", mSpd0 = ", mSpd0, ", score = ", score, ", my speed = ", PLATFORM.Speed());
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
brawlerPlatform.FlyVectorWithThrottle(mDir0, mGMX, mSpd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt35.f
|
||||
// Replicates the force overshoot 3,5,6,1 alternative behavior
|
||||
|
||||
behavior alt3561_force_overshoot
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3561Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 5;
|
||||
int icall = 6;
|
||||
int lcall = 1;
|
||||
|
||||
// Maneuver Alternative flight values
|
||||
Vec3 mDir0;
|
||||
double mGMX = 1.0;
|
||||
double mSpd0 = 3.0;
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3561_force_overshoot, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3561Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() <= 0)
|
||||
{
|
||||
return Failure("no weapon (hostile) tasks!");
|
||||
}
|
||||
WsfTask targetTask = tasks.Entry(0);
|
||||
WsfLocalTrack hostile = PLATFORM.MasterTrackList().Find(targetTask.LocalTrackId());
|
||||
if (!hostile.IsValid())
|
||||
{
|
||||
return Failure("no hostile track!");
|
||||
//TODO also validate location / veloctiy
|
||||
}
|
||||
|
||||
// alt35.f line 247
|
||||
# if(rngun(iac).gt.3000.) go to 205
|
||||
double projectionTime = TIME_NOW + brawlerPlatform.ProjectedTimeDelta();
|
||||
WsfGeoPoint projectedHostileLocation = hostile.LocationAtTime(projectionTime);
|
||||
double rangeToHostile = PLATFORM.SlantRangeTo(projectedHostileLocation);
|
||||
|
||||
if (rangeToHostile > 3000 * Math.FT_PER_M())
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " hostile range greater than 3000 ft");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
// ALL CONDITIONS PASS
|
||||
### Generate Maneuver Alternative
|
||||
// alt35.f line 249 - 256
|
||||
# iactn = 4
|
||||
# lenalt = lactn(iactn)
|
||||
# altdsc = altpk(3,5,icall,1,iacidt(iac),0)
|
||||
# call cros1(vp(1,me),vp(1,iac),dir0)
|
||||
# if(dir0(3).gt.0.) call vmult(-1.,dir0,dir0)
|
||||
# gmx = amin1(5.,gmxin)
|
||||
# spd0 = spdnow(me)+almin*tproj3*1.1
|
||||
# spdmod = desspd
|
||||
Vec3 myVdir = PLATFORM.VelocityNED();
|
||||
Vec3 tgtVdir = hostile.VelocityNED();
|
||||
mDir0 = Vec3.Cross(myVdir, tgtVdir);
|
||||
mDir0.Normalize();
|
||||
if (mDir0.Z() > 0)
|
||||
{
|
||||
mDir0.Scale(-1.0);
|
||||
}
|
||||
mGMX = Math.Min(5.0, brawlerPlatform.MaxAvailableGs());
|
||||
double almin = brawlerPlatform.MinForwardAccelWithGravity();
|
||||
mSpd0 = PLATFORM.Speed() * MATH.FT_PER_M() + almin * brawlerPlatform.ProjectedTimeDelta() * 1.1;
|
||||
mSpd0 *= MATH.M_PER_FT();
|
||||
|
||||
### Evaluate [Projected] Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithSpeed(mDir0, mGMX, mSpd0, ilevel, kalt, icall, lcall);
|
||||
writeln_d("T=", TIME_NOW, ", 3561_force_overshoot = ", score);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
writeln_d("3561_force_overshoot");
|
||||
## what was evaluated should be actually performed now
|
||||
brawlerPlatform.FlyVectorWithSpeed(mDir0, mGMX, mSpd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt35.f
|
||||
// Replicates the negative velocity 3,5,8,1 alternative behavior
|
||||
|
||||
include_once BrawlerScriptUtil.txt
|
||||
|
||||
behavior alt3581_negative_velocity
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3581Enabled = true;
|
||||
bool mCheckBoresight = true;
|
||||
bool mCheckRange = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 5;
|
||||
int icall = 8;
|
||||
int lcall = 1;
|
||||
|
||||
// Maneuver Alternative flight values
|
||||
Vec3 mDir0;
|
||||
double mGMX = 1.0;
|
||||
double mSpd0 = 3.0;
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3581_negative_velocity, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3581Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() <= 0)
|
||||
{
|
||||
return Failure("no weapon (hostile) tasks!");
|
||||
}
|
||||
WsfTask targetTask = tasks.Entry(0);
|
||||
WsfLocalTrack hostile = PLATFORM.MasterTrackList().Find(targetTask.LocalTrackId());
|
||||
if (!hostile.IsValid())
|
||||
{
|
||||
return Failure("no hostile track!");
|
||||
}
|
||||
|
||||
//TODO - change this script so it doesn't use a truth method?
|
||||
if (hostile.TargetKilled())
|
||||
{
|
||||
return Failure("hostile was destroyed!");
|
||||
}
|
||||
|
||||
// alt35.f line 282 - 285
|
||||
# if(spdut(iac).eq.0.0)goto 205
|
||||
# if(obang(iac,me).gt.hafpi) go to 205
|
||||
# rrunmn = 5.*ramp(twopi,obang(iac,me)+obang(me,iac),0.) <- same as 3551
|
||||
# if(rngun(iac)*ftnmi .gt. rrunmn+1.) go to 205
|
||||
|
||||
if (!hostile.VelocityValid() || (hostile.Speed()*MATH.FT_PER_M()) < 1)
|
||||
{
|
||||
// If we don't have valid velocity or spoed is effectively zero
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " hostile has invalid or no speed");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
double obang_hostile_me = brawlerPlatform.OffBoresightAngle(hostile.Target(), PLATFORM);
|
||||
double obang_me_hostile = brawlerPlatform.OffBoresightAngle(PLATFORM, hostile.Target());
|
||||
|
||||
if (mCheckBoresight == true && obang_hostile_me > Math.PI_OVER_2())
|
||||
{
|
||||
// Not ahead of hostile
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " off boresight angle hostile to me > Pi/2");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
double rrunmn = 5.0 * ramp(Math.TWO_PI(), obang_hostile_me + obang_me_hostile, 0.0);
|
||||
double projectionTime = TIME_NOW + brawlerPlatform.ProjectedTimeDelta();
|
||||
WsfGeoPoint projectedHostileLocation = hostile.LocationAtTime(projectionTime);
|
||||
double rangeToHostile = PLATFORM.SlantRangeTo(projectedHostileLocation);
|
||||
if (mCheckRange == true && rangeToHostile * Math.M_PER_NM() < rrunmn + 1.0)
|
||||
{
|
||||
// Hostile too far
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " range to hostile < minimum range to run");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
// ALL CONDITIONS PASS
|
||||
### Generate Maneuver Alternative
|
||||
// alt35.f line 286 - 292
|
||||
# iactn = 4
|
||||
# lenalt = lactn(iactn)
|
||||
# altdsc = altpk(3,5,icall,1,iacidt(iac),0)
|
||||
# call vmake(-1.,veut(1,iac),dir0)
|
||||
# gmx = gmxsu
|
||||
# spd0 = 3.
|
||||
# spdmod = thrttl
|
||||
mDir0 = vmake(-1.0, hostile.VelocityNED());
|
||||
mGMX = brawlerPlatform.MaxSustainedGs();
|
||||
mSpd0 = 3.0;
|
||||
|
||||
### Evaluate [Projected] Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithThrottle(mDir0, mGMX, mSpd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
brawlerPlatform.FlyVectorWithThrottle(mDir0, mGMX, mSpd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
153
platforms/brawler/alternatives/behavior_alt3611_fly_vector.txt
Normal file
153
platforms/brawler/alternatives/behavior_alt3611_fly_vector.txt
Normal file
@@ -0,0 +1,153 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// converted from BRAWLER v7.5 alt36.f
|
||||
// Replicates the blah blah 3,6,1,1 alternative behavior
|
||||
// blah blah
|
||||
// alt3611_fly_vector
|
||||
|
||||
behavior alt3611_fly_vector
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
WsfLocalTrack targetTrack;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3611Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 6;
|
||||
int icall = 1;
|
||||
int lcall = 1;
|
||||
|
||||
double mMaxSustainedG = 2.0;
|
||||
|
||||
double mLongRange = 5.0 * Math.M_PER_NM();
|
||||
|
||||
Vec3 dir0;
|
||||
double gmx = 1.0;
|
||||
double spd0 = 3.0;
|
||||
|
||||
// ALSO NEED:
|
||||
// randomization to simulate imperfect decision making, valsig, read from MIND file, typically ~0.01
|
||||
// Production rule bias, used in scoring of alternative
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt33841_aim_missile_typ4, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
### check if alternative should even be considered?
|
||||
|
||||
if (!mAlternative3611Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() <= 0)
|
||||
{
|
||||
return Failure("no weapon (target) tasks!");
|
||||
}
|
||||
WsfTask targetTask = tasks.Entry(0);
|
||||
targetTrack = PLATFORM.MasterTrackList().Find(targetTask.LocalTrackId());
|
||||
if (!targetTrack.IsValid())
|
||||
{
|
||||
return Failure("no target track!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern Vec3 vecfpp;
|
||||
extern double valfpp;
|
||||
extern double sflypp;
|
||||
#alt36()
|
||||
#iactn = 4
|
||||
#set_gmx()
|
||||
Vec3 vv = vecfpp.Normal();
|
||||
dir0 = desvvi(brawlerPlatform, vv, sflypp);
|
||||
spd0 = dir0.Magnitude();
|
||||
dir0.Normalize();
|
||||
|
||||
//spdmod = desspd;
|
||||
//call indupk(altd1,tac_ilevel,tac_kalt,tac_icall,tac_lcall);
|
||||
//if (tac_kalt.ne.8 .or. tac_icall.ne.2) then
|
||||
if ((PLATFORM.Speed()*MATH.FT_PER_M()) <= spd0+100.0)
|
||||
{
|
||||
double gmxsut = brawlerPlatform.MaxSustainedGs();
|
||||
double gmxsu = brawlerPlatform.MaxTacticalGs();
|
||||
double wt = ramp(spd0 - 100.0, PLATFORM.Speed()*MATH.FT_PER_M(),spd0+100.0);
|
||||
gmx = wt*MATH.Max(2.0,MATH.Max(gmxsut,gmxsu)) + (1.0-wt)*MATH.Min(gmxsut,gmxsu);
|
||||
gmx = MATH.Max(gmx,2.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
gmx = brawlerPlatform.MaxAvailableGs(); #gmxin;
|
||||
}
|
||||
//else
|
||||
#LBM - not doing GCI drag tactic (1,8,2,1) right now
|
||||
//...
|
||||
//endif
|
||||
spd0 *= MATH.M_PER_FT();
|
||||
double score = brawlerPlatform.EvaluateVectorWithSpeed(dir0, gmx, spd0, ilevel, kalt, icall, lcall);
|
||||
writeln_d("alt3611_fly_vector score = ", score);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
brawlerPlatform.FlyVectorWithSpeed(dir0, gmx, spd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt38.f
|
||||
// Replicates the blah blah 3,8,4,1 alternative behavior
|
||||
// blah blah
|
||||
//alt3841_aim_missile_typ4
|
||||
|
||||
//LBM - NOTE: using typ4 because it uses maneuver type 4 (instead of type 9)
|
||||
// according to notes in BRAWLER, this is the replacement for typ1
|
||||
// especially for certain sims because of stability problems
|
||||
|
||||
behavior alt3841_aim_missile_typ4
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
WsfLocalTrack targetTrack;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3841Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 8;
|
||||
int icall = 4;
|
||||
int lcall = 1;
|
||||
|
||||
double mMaxSustainedG = 2.0;
|
||||
|
||||
double mLongRange = 5.0 * Math.M_PER_NM();
|
||||
|
||||
Vec3 dir0;
|
||||
double gmx = 1.0;
|
||||
double spd0 = 3.0;
|
||||
|
||||
// ALSO NEED:
|
||||
// randomization to simulate imperfect decision making, valsig, read from MIND file, typically ~0.01
|
||||
// Production rule bias, used in scoring of alternative
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt33841_aim_missile_typ4, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
### check if alternative should even be considered?
|
||||
|
||||
if (!mAlternative3841Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() <= 0)
|
||||
{
|
||||
return Failure("no weapon (target) tasks!");
|
||||
}
|
||||
WsfTask targetTask = tasks.Entry(0);
|
||||
targetTrack = PLATFORM.MasterTrackList().Find(targetTask.LocalTrackId());
|
||||
if (!targetTrack.IsValid())
|
||||
{
|
||||
return Failure("no target track!");
|
||||
}
|
||||
|
||||
bool alt_ctrl = false; //see ali38()
|
||||
bool msl_loft = false; //see line 147 (no productions rules right now)
|
||||
|
||||
## alt38.f : lines 136 - 150
|
||||
#if (noaim) go to 980
|
||||
#if (mslpp .ge. nummis+1) then
|
||||
if (!HaveWeapon(PLATFORM))
|
||||
{
|
||||
# SKIP ALT_CTRL DETERMINATION IF SELECTED WEAPON IS A GUN
|
||||
alt_ctrl = false;
|
||||
msl_loft = false;
|
||||
//go to 900
|
||||
}
|
||||
else
|
||||
{
|
||||
#call gmisld(ppmptr,1) #TODO
|
||||
# Call special handler to see if desire missile loft
|
||||
#call pcode(23) #TODO
|
||||
# Loft missile if ready and pr_loft is set
|
||||
#msl_loft = (ready && pr_loft); #TODO
|
||||
}
|
||||
|
||||
## alt38.f : lines 227 - 253
|
||||
# generate aim_missile_typ4 unless alt_ctrl = T.
|
||||
if (alt_ctrl)
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " alt_ctrl is true, do not do aim_missile_typ4 behavior");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
# generate aim_missile_typ1 if pointing in direction of aimpoint
|
||||
#LBM - not doing vectored flight right now
|
||||
# if (valfpp > 0.0)
|
||||
# {
|
||||
# double theta = sepa(dxeuan(1,ppmiac),vecfpp);
|
||||
# if (theta > 0.8*zeta_lim)
|
||||
# {
|
||||
# return Failure("not pointing in right direction, do not do aim_missile_typ4 behavior");
|
||||
# }
|
||||
# }
|
||||
|
||||
#LBM - not a manned sim, dont even check, right now
|
||||
#if (simltr != mansim) goto 900
|
||||
# This is a replacement for icall=1 maneuver, for manned simulators
|
||||
# Use a type 4 maneuver to avoid stability problems with type
|
||||
# 9 maneuver at WSSC:
|
||||
int iactn = 4;
|
||||
Vec3 ppmapt; //calculated from mlsenv() -> envgeo() -> aimpt()
|
||||
|
||||
WsfWaypoint aimptWP = WsfWaypoint();
|
||||
double weaponSpeedFtSec = 3349.35; //(mach 3) ft/sec
|
||||
double intTime = PLATFORM.InterceptLocation3D(targetTrack, aimptWP, weaponSpeedFtSec, 5.0);
|
||||
if (intTime < 0)
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " missile intercept not possible!");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
#call vdir(xp(1,me),ppmapt,desdir);
|
||||
Vec3 desdir = RelativePositionNED(PLATFORM.Location(), aimptWP.Location());
|
||||
desdir.Normalize();
|
||||
double spddes = PLATFORM.Speed()*MATH.FT_PER_M(); //from ali38() -> slow_aim is never set, so use current speed
|
||||
#call des1v1(desdir,spddes,dir0,spd0,lngtrn,semin,sewid);
|
||||
spd0 = spddes; //from des1v1 (direct copy, duh)
|
||||
dir0 = desdir; //from des1v1 (direct copy, duh)
|
||||
int spdmod = 1; //(desspd = 1, thrttl = 2, desacc = 3)
|
||||
if ((PLATFORM.Speed()*MATH.FT_PER_M()) <= spd0+100.0)
|
||||
{
|
||||
double gmxsut = brawlerPlatform.MaxSustainedGs();
|
||||
double gmxsu = brawlerPlatform.MaxTacticalGs();
|
||||
double wt = ramp(spd0-100.0, PLATFORM.Speed()*MATH.FT_PER_M(), spd0+100.0);
|
||||
gmx = wt*MATH.Max(2.0,MATH.Max(gmxsut,gmxsu)) + (1.0-wt)*MATH.Min(gmxsut,gmxsu);
|
||||
gmx = MATH.Max(gmx,2.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
gmx = brawlerPlatform.MaxAvailableGs(); #gmxin
|
||||
}
|
||||
spd0 *= MATH.M_PER_FT();
|
||||
|
||||
|
||||
### Evaluate [Projected] Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithSpeed(dir0, gmx, spd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
brawlerPlatform.FlyVectorWithSpeed(dir0, gmx, spd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt39.f
|
||||
// Replicates the evade missile 3,9,1,1 alternative behavior
|
||||
// GENERATES MISSILE EVASION MANEUVER
|
||||
|
||||
|
||||
behavior alt3911_evade_missile
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfThreatProcessor threatProc;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3911Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 9;
|
||||
int icall = 1;
|
||||
int lcall = 1;
|
||||
|
||||
// Maneuver Alternative flight values
|
||||
Vec3 mDir0 = Vec3();
|
||||
double mGMX = 1.0;
|
||||
double mSpd0 = 3.0;
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
threatProc = (WsfThreatProcessor)PLATFORM.Processor("incoming_threats");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3911_straight_flight, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3911Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
WsfTrack threat = threatProc.NearestThreat();
|
||||
if (!threat.IsValid())
|
||||
{
|
||||
// This check equivalent to noneed in alt39.f
|
||||
writeln_d("no incoming missiles");
|
||||
return Failure("no incoming missiles");
|
||||
}
|
||||
|
||||
// ALL CONDITIONS PASS
|
||||
### Generate Maneuver Alternative
|
||||
# iactn = 4
|
||||
# lenalt = lactn(iactn)
|
||||
# altdsc = altpk(3,9,1,1,0,0)
|
||||
# call xmit(3,direv,dir0)
|
||||
# gmx = gmxin
|
||||
# spd0 = throtm(iacid) <- limits throttle to 2 if there are IR missiles coming at me
|
||||
# spdmod = thrttl
|
||||
|
||||
// Get stored evasion direction vector
|
||||
//Vec3 direvd = brawlerPlatform.EvasionDirection();
|
||||
Vec3 direvd = brawlerPlatform.EvasionDirection();
|
||||
mDir0 = direvd;
|
||||
mGMX = brawlerPlatform.MaxAvailableGs();
|
||||
mSpd0 = 2; // Always 2 for now
|
||||
|
||||
### Evaluate [Projected] Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithThrottle(mDir0, mGMX, mSpd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
brawlerPlatform.FlyVectorWithThrottle(mDir0, mGMX, mSpd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt3a.f
|
||||
// Replicates the low speed recover 3,A,1,1 alternative behavior
|
||||
|
||||
include_once BrawlerScriptUtil.txt
|
||||
|
||||
behavior alt3A11_low_speed_recover
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3A11Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 10;
|
||||
int icall = 1;
|
||||
int lcall = 1;
|
||||
|
||||
// Maneuver Alternative flight values
|
||||
Vec3 mDir0 = Vec3();
|
||||
double mGMX = 1.0;
|
||||
double mSpd0 = 3.0;
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3411_straight_flight, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3A11Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
if (!brawlerPlatform.SlowFlight())
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " not in slow flight");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
// ALL CONDITIONS PASS
|
||||
### Generate Maneuver Alternative
|
||||
# C ALTERNATIVE 1: "ALMOST" STRAIGHT DOWN
|
||||
#20 continue
|
||||
#C --SET DIR0 ALMOST STRAIGHT DOWN, BUT SLIGHLY IN THE DIRECTION
|
||||
#C --OF MY CURRENT VELOCITY
|
||||
# call xmit3(unitz,dir0)
|
||||
# call vcross(vp(1,me),unitz,vtemp)
|
||||
# call rotv(2.0*rad,vtemp,dir0,dir0)
|
||||
# go to 990
|
||||
#990 submor = .true.
|
||||
# iactn = 4
|
||||
# lenalt = lactn(iactn)
|
||||
# altdsc = altpk(3,10,icall,1,0,0)
|
||||
#C --SET TO HIGHEST THROTTLE SETTING FOR MAX SPEED
|
||||
# spd0 = 3.
|
||||
# spdmod = thrttl
|
||||
# call srch(dragvl,ndatbl,acmasp*grav,index,xx) <- search drag versus lift table for aircraft mass * gravity
|
||||
# if(index.ne.0) go to 995
|
||||
# index = ndatbl
|
||||
# xx = 0.0
|
||||
#995 continue
|
||||
# gmx = gmxin*(index-xx-1.0)/(ndatbl-1.0)
|
||||
# gmx = amax1(gmx,1.5)
|
||||
# gmx = 1.5+(gmx-1.5)*ramp(.5,vp(3,me)/spdnow(me),0.)
|
||||
|
||||
mDir0 = Vec3.Construct(0, 0, 1);
|
||||
Vec3 vtemp = Vec3.Cross(PLATFORM.VelocityNED(), mDir0);
|
||||
double rad = Math.PI()/180.0;
|
||||
mDir0 = rotv(2.0*rad, vtemp, mDir0);
|
||||
|
||||
mSpd0 = 3;
|
||||
|
||||
mGMX = brawlerPlatform.MaxAvailableGs(); // TODO add drag v lift
|
||||
mGMX = Math.Max(mGMX, 1.5);
|
||||
Vec3 vp = PLATFORM.VelocityNED();
|
||||
double speed = PLATFORM.Speed() * Math.FT_PER_M(); // Speed in f/sec
|
||||
mGMX = 1.5 + (mGMX - 1.5) * ramp(0.5, (vp[2] * Math.FT_PER_M()/speed), 0.0);
|
||||
|
||||
### Evaluate [Projected] Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithThrottle(mDir0, mGMX, mSpd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
brawlerPlatform.FlyVectorWithThrottle(mDir0, mGMX, mSpd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt3a.f
|
||||
// Replicates the low speed recover right 45 deg 3,A,2,1 alternative behavior
|
||||
|
||||
behavior alt3A21_low_speed_recover_right45
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3A21Enabled = false;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 10;
|
||||
int icall = 2;
|
||||
int lcall = 1;
|
||||
|
||||
// Maneuver Alternative flight values
|
||||
Vec3 mDir0 = Vec3();
|
||||
double mGMX = 1.0;
|
||||
double mSpd0 = 3.0;
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
// Magic numbers from alt3a.f
|
||||
double sd45 = 0.7071068;
|
||||
double cd45 = 0.7071068;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3411_straight_flight, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3A21Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
if (!brawlerPlatform.SlowFlight())
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " not in slow flight");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
// ALL CONDITIONS PASS
|
||||
### Generate Maneuver Alternative
|
||||
#C ALTERNATIVE 2: ROLL +45 DEGREES
|
||||
#40 continue
|
||||
# dir0(1) = 0.
|
||||
# dir0(2) = sd45
|
||||
# dir0(3) = -cd45
|
||||
# call vxfrmc(rbep,dir0,dir0,2)
|
||||
# go to 990
|
||||
#990 submor = .true.
|
||||
# iactn = 4
|
||||
# lenalt = lactn(iactn)
|
||||
# altdsc = altpk(3,10,icall,1,0,0)
|
||||
#C --SET TO HIGHEST THROTTLE SETTING FOR MAX SPEED
|
||||
# spd0 = 3.
|
||||
# spdmod = thrttl
|
||||
# call srch(dragvl,ndatbl,acmasp*grav,index,xx)
|
||||
# if(index.ne.0) go to 995
|
||||
# index = ndatbl
|
||||
# xx = 0.0
|
||||
#995 continue
|
||||
# gmx = gmxin*(index-xx-1.0)/(ndatbl-1.0)
|
||||
# gmx = amax1(gmx,1.5)
|
||||
# gmx = 1.5+(gmx-1.5)*ramp(.5,vp(3,me)/spdnow(me),0.)
|
||||
|
||||
mDir0 = Vec3.Construct(0.0, sd45, -cd45);
|
||||
//TODO convert from earth to body coordinates
|
||||
|
||||
mSpd0 = 3;
|
||||
|
||||
mGMX = brawlerPlatform.MaxAvailableGs(); // TODO add drag v lift
|
||||
mGMX = Math.Max(mGMX, 1.5);
|
||||
Vec3 vp = PLATFORM.VelocityNED();
|
||||
double speed = PLATFORM.Speed() * Math.FT_PER_M(); // Speed in f/sec
|
||||
mGMX = 1.5 + (mGMX - 1.5) * ramp(0.5, (vp[2] * Math.FT_PER_M()/speed), 0.0);
|
||||
|
||||
### Evaluate [Projected] Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithThrottle(mDir0, mGMX, mSpd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
brawlerPlatform.FlyVectorWithThrottle(mDir0, mGMX, mSpd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt3a.f
|
||||
// Replicates the low speed recover left 45 deg 3,A,3,1 alternative behavior
|
||||
|
||||
behavior alt3A31_low_speed_recover_left45
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3A31Enabled = false;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 10;
|
||||
int icall = 3;
|
||||
int lcall = 1;
|
||||
|
||||
// Maneuver Alternative flight values
|
||||
Vec3 mDir0 = Vec3();
|
||||
double mGMX = 1.0;
|
||||
double mSpd0 = 3.0;
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
// Magic numbers from alt3a.f
|
||||
double sd45 = 0.7071068;
|
||||
double cd45 = 0.7071068;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3411_straight_flight, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3A31Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
if (!brawlerPlatform.SlowFlight())
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " not in slow flight");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
// ALL CONDITIONS PASS
|
||||
### Generate Maneuver Alternative
|
||||
# C ALTERNATIVE 3: ROLL -45 DEGREES
|
||||
#60 continue
|
||||
# dir0(1) = 0.
|
||||
# dir0(2) = -sd45
|
||||
# dir0(3) = -cd45
|
||||
# call vxfrmc(rbep,dir0,dir0,2)
|
||||
# go to 990
|
||||
#990 submor = .true.
|
||||
# iactn = 4
|
||||
# lenalt = lactn(iactn)
|
||||
# altdsc = altpk(3,10,icall,1,0,0)
|
||||
#C --SET TO HIGHEST THROTTLE SETTING FOR MAX SPEED
|
||||
# spd0 = 3.
|
||||
# spdmod = thrttl
|
||||
# call srch(dragvl,ndatbl,acmasp*grav,index,xx)
|
||||
# if(index.ne.0) go to 995
|
||||
# index = ndatbl
|
||||
# xx = 0.0
|
||||
#995 continue
|
||||
# gmx = gmxin*(index-xx-1.0)/(ndatbl-1.0)
|
||||
# gmx = amax1(gmx,1.5)
|
||||
# gmx = 1.5+(gmx-1.5)*ramp(.5,vp(3,me)/spdnow(me),0.)
|
||||
|
||||
mDir0 = Vec3.Construct(0.0, -sd45, -cd45);
|
||||
//TODO convert from earth to body coordinates
|
||||
|
||||
mSpd0 = 3;
|
||||
|
||||
mGMX = brawlerPlatform.MaxAvailableGs(); // TODO add drag v lift
|
||||
mGMX = Math.Max(mGMX, 1.5);
|
||||
Vec3 vp = PLATFORM.VelocityNED();
|
||||
double speed = PLATFORM.Speed() * Math.FT_PER_M(); // Speed in f/sec
|
||||
mGMX = 1.5 + (mGMX - 1.5) * ramp(0.5, (vp[2] * Math.FT_PER_M()/speed), 0.0);
|
||||
|
||||
### Evaluate [Projected] Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithThrottle(mDir0, mGMX, mSpd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
brawlerPlatform.FlyVectorWithThrottle(mDir0, mGMX, mSpd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
188
platforms/brawler/alternatives/behavior_alt3B11_illuminate.txt
Normal file
188
platforms/brawler/alternatives/behavior_alt3B11_illuminate.txt
Normal file
@@ -0,0 +1,188 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt3b.f
|
||||
// Replicates the illuminate 3,B,1,1 alternative behavior
|
||||
// GENERATES ILLUMINATION MANEUVER
|
||||
//
|
||||
|
||||
behavior alt3B11_illuminate
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfPerceptionProcessor perception;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
WsfLocalTrack targetTrack;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
bool mAlternative3B11Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 11;
|
||||
int icall = 1;
|
||||
int lcall = 1;
|
||||
|
||||
double mMaxSustainedG = 2.0;
|
||||
|
||||
double mLongRange = 5.0 * Math.M_PER_NM();
|
||||
|
||||
Vec3 dir0;
|
||||
double gmx = 1.0;
|
||||
double spd0;
|
||||
|
||||
// ALSO NEED:
|
||||
// randomization to simulate imperfect decision making, valsig, read from MIND file, typically ~0.01
|
||||
// Production rule bias, used in scoring of alternative
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
double mLastTime = 0.0;
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
perception = (WsfPerceptionProcessor)PLATFORM.Processor("perception");
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3B11_illuminate, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
### check if alternative should even be considered?
|
||||
|
||||
if (!mAlternative3B11Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() <= 0)
|
||||
{
|
||||
return Failure("no weapon (target) tasks!");
|
||||
}
|
||||
WsfTask targetTask = tasks.Entry(0);
|
||||
targetTrack = PLATFORM.MasterTrackList().Find(targetTask.LocalTrackId());
|
||||
if (!targetTrack.IsValid())
|
||||
{
|
||||
return Failure("no target track!");
|
||||
}
|
||||
|
||||
|
||||
## alt3b.f : lines 84 - 127
|
||||
|
||||
# if(!lillum)
|
||||
# {
|
||||
# return Failure("lillum == false");
|
||||
# }
|
||||
#
|
||||
dir0 = Vec3.Construct(0,0,0);
|
||||
#if(nbvr == 0) call nabort('ALT3B...NBVR=0')
|
||||
|
||||
# #LBM - only fly against targetTrack, not all things
|
||||
# do 50 ibvr=1,nbvr
|
||||
# if (jtgbvr(ibvr).lt.0) call nabort('ALT3B...JTGBVR IS ZERO')
|
||||
# if (jtgbvr(ibvr).eq.0) goto 50
|
||||
# iac = mmindt(jtgbvr(ibvr))
|
||||
# if (iac.eq.0) goto 50
|
||||
|
||||
#call vdir(xp(1,me),xp(1,iac),dx)
|
||||
Vec3 dx = RelativePositionNED(PLATFORM.Location(), targetTrack.CurrentLocation());
|
||||
dx.Normalize();
|
||||
Vec3 vp = PLATFORM.VelocityNED();
|
||||
Vec3 dir0i = vorth(vp,dx);
|
||||
|
||||
#call veclin(0.5/xmag(dir0i),dir0i,root3*0.5,dx,dir0i)
|
||||
|
||||
//missile phases:
|
||||
//pinfr=1, psema=2, pactr=3, pcomg=4, pguns=5, phor=6, p_act_ir_1=7, p_inertial=8, pnewg=9
|
||||
|
||||
int kndbvr; //TODO? = pcomg if command guided launch
|
||||
int psema = 2; //semi active
|
||||
int pcomg = 4; //command guided
|
||||
if (kndbvr == psema)
|
||||
{
|
||||
# SEMI-ACTIVE MISSILE, GIVE FULL WEIGHT
|
||||
|
||||
#call vsum(dir0,dir0i,dir0);
|
||||
|
||||
}
|
||||
else if (kndbvr == pcomg)
|
||||
{
|
||||
# ACTIVE RADAR MISSILE, PRESUMABLY PRE-ACQUISITION
|
||||
# GIVE 50% WEIGHT TO ITS ILLUM VECTOR
|
||||
|
||||
#call vecinc(dir0,0.5,dir0i,dir0)
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
#call nabort('ALT3B...unknown/illegal kndbvr')
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " unknown/illegal kndbvr");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
# If BVR target is not to be considered in high detail do not
|
||||
# illuminate
|
||||
if (dir0.Magnitude() == 0.0)
|
||||
{
|
||||
string msg = write_str("T=",TIME_NOW,", alt ", ilevel, kalt, icall, lcall, " dir0 == zero");
|
||||
writeln_d(msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
#call unitv(dir0,dir0)
|
||||
int iactn = 4;
|
||||
gmx = 2.0;
|
||||
double bvrmch = 1.0; //TODO - find for real
|
||||
double fmachp = 1.0; //TODO - find for real
|
||||
spd0 = PLATFORM.Speed() * MATH.Max(1.0,bvrmch/fmachp); #spd0 in meter/seconds units here
|
||||
int spdmod = 1; //(desspd = 1, thrttl = 2, desacc = 3)
|
||||
|
||||
### Evaluate [Projected] Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateVectorWithSpeed(dir0, gmx, spd0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
brawlerPlatform.FlyVectorWithSpeed(dir0, gmx, spd0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
123
platforms/brawler/alternatives/behavior_alt3G11_barrel_roll.txt
Normal file
123
platforms/brawler/alternatives/behavior_alt3G11_barrel_roll.txt
Normal file
@@ -0,0 +1,123 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 alt3g.f and brlrol.f
|
||||
// Replicates the barrel roll 3,16,1,1 alternative behavior
|
||||
// DO A BARREL ROLL! - Peppy
|
||||
|
||||
|
||||
behavior alt3G11_barrel_roll
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
// Takes the place of 'brlflg'
|
||||
bool mAlternative3G11Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 3;
|
||||
int kalt = 16;
|
||||
int icall = 1;
|
||||
int lcall = 1;
|
||||
|
||||
// Barrel Roll Generation Parameters (formerly from rules file)
|
||||
// See Brawler Production Rule Handbook 2.1.2.4 Barrel Roll - brlrol
|
||||
double rolrat = 15; // Desired roll rate in degrees/sec
|
||||
double ptchrt = 30; // Desired pitch rate in degrees/sec
|
||||
double lgees = 0; // Desired longitudinal acceleration in units of gees.
|
||||
|
||||
// Maneuver Alternative flight values
|
||||
Vec3 mA0 = Vec3();
|
||||
Vec3 mAl0 = Vec3();
|
||||
double mAccmod = 0.0;
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
double grav = 32.17405; // From pcon.fi
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition behavior_alt3G11_barrel_roll, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
if (!mAlternative3G11Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
// ALL CONDITIONS PASS
|
||||
### Generate Maneuver Alternative
|
||||
# brlrol.f
|
||||
#--NEXT LINE ALLOWS ALT3G TO GENERATE ALTERNATIVE
|
||||
#brlflg=.true.
|
||||
#if(lprnt) write(ioutp,1000) rolrat,ptchrt,lgees
|
||||
#--SET DESIRED RATES
|
||||
#w0(1)=rolrat*rad
|
||||
#w0(2)=ptchrt*rad
|
||||
#w0(3)=0.0
|
||||
#al0 = grav*lgees
|
||||
#accmod = desacc
|
||||
#call xmit(5,althld(5),baralt)
|
||||
mA0.SetX(rolrat * Math.RAD_PER_DEG());
|
||||
mA0.SetY(ptchrt * Math.RAD_PER_DEG());
|
||||
mA0.SetZ(0.0);
|
||||
mAl0.SetX(grav * lgees); // Note al0 is actually a singe value, it is set to vector accreq(1) in command.f
|
||||
//mAccmod = ??; where do we get desacc?
|
||||
|
||||
# alt3g.f
|
||||
#iactn = 1
|
||||
#lenalt=lactn(iactn)
|
||||
#altdsc = indpk(3,16,1,1)
|
||||
#call xmit(5,baralt,althld(5)) <- copy predefined barrel roll maneuver into alternative storage
|
||||
|
||||
### Evaluate [Projected] Maneuver Alternative
|
||||
double score = brawlerPlatform.EvaluateRates(mA0, mAl0, ilevel, kalt, icall, lcall);
|
||||
return score;
|
||||
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
## what was evaluated should be actually performed now
|
||||
brawlerPlatform.FlyRates(mA0, mAl0);
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
264
platforms/brawler/alternatives/behavior_pilot_posture.txt
Normal file
264
platforms/brawler/alternatives/behavior_pilot_posture.txt
Normal file
@@ -0,0 +1,264 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
|
||||
behavior pilot_posture
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
WsfTask targetTask;
|
||||
WsfLocalTrack targetTrack;
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
double root3 = 1.732050808; # pcon.fi
|
||||
double splita = 45.0; # MIND file, TODO - use read in value
|
||||
end_script_variables
|
||||
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
|
||||
precondition
|
||||
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() <= 0)
|
||||
{
|
||||
string err = write_str("no weapon (target) tasks!");
|
||||
writeln_d(err);
|
||||
return Failure(err);
|
||||
}
|
||||
targetTask = tasks.Entry(0);
|
||||
targetTrack = PLATFORM.MasterTrackList().Find(targetTask.LocalTrackId());
|
||||
if (!targetTrack.IsValid() || targetTrack.TargetKilled())
|
||||
{
|
||||
string err = write_str("no target track!");
|
||||
writeln_d(err);
|
||||
return Failure(err);
|
||||
}
|
||||
|
||||
return true;
|
||||
end_precondition
|
||||
|
||||
|
||||
execute
|
||||
|
||||
writeln_d("executing pilot_posture");
|
||||
|
||||
Vec3 xp = brawlerPlatform.LocationNED();
|
||||
Vec3 vp = PLATFORM.VelocityNED();
|
||||
double spdnow = PLATFORM.Speed()*MATH.FT_PER_M();
|
||||
Vec3 xp_iac = brawlerPlatform.LocationNED(targetTrack);
|
||||
Vec3 vp_iac = targetTrack.VelocityNED();
|
||||
|
||||
|
||||
#aslct2()
|
||||
#spcial()
|
||||
#spbvri()
|
||||
|
||||
|
||||
// "iac" is target index, get target track from WEAPON task, for now
|
||||
|
||||
Vec3 hlvec = Vec3();
|
||||
double hlspd = 0.0;
|
||||
double hlval = 0.0;
|
||||
|
||||
extern int kturn;
|
||||
//C --GET KTURN VALUE
|
||||
//call ckrngi(myturn,-2,2,'~KTURN(IACID)~')
|
||||
double sgn = 1.0;
|
||||
if (kturn<0)
|
||||
{
|
||||
sgn = -1.0;
|
||||
}
|
||||
#double vsme = 0.0; #TODO - speed of sound
|
||||
#double bvrmch = 0.0; #TODO - mach to use BVR (MIND2)
|
||||
#double bvrmch = PLATFORM.Speed()*MATH.FT_PER_M() / vsme;
|
||||
#double sa = vsme*bvrmch;
|
||||
double sa = brawlerPlatform.Speed()*MATH.FT_PER_M();
|
||||
|
||||
//call asstgt(iacord,jacidord,virtl,nassign)
|
||||
//if(nassign.eq.0) goto 900
|
||||
//iac = iacord(1);
|
||||
if (kturn != 0)
|
||||
{
|
||||
writeln_d("kturn != 0");
|
||||
//C --THIS CODE NOT NEEDED FOR POINT TACTIC:
|
||||
//C --COMPUTE INTERCEPT PT AIMP, BASED ON MAX OF MACH 1 OR PRESENT MACH
|
||||
//C --USE THE FIRST MEMBER OF THE ASSIGNED TARGET GROUP.
|
||||
#st = xmag(vp(1,iac));
|
||||
double st = vp_iac.Magnitude();
|
||||
|
||||
//LBM - TODO - verify units used in WsfBrawlerPlatform AimPoint and Intercept() methods!!!
|
||||
#call aimpt(xp(1,me),amax1(sa,vsme),xp(1,iac),vp_iac,st,aimp,lsoln);
|
||||
#Vec3 aimp = brawlerPlatform.AimPoint(xp, MATH.Max(sa, vsme), xp_iac, vp_iac, st);
|
||||
Vec3 aimp = brawlerPlatform.AimPoint(xp, sa, xp_iac, vp_iac, st);
|
||||
|
||||
#Vec3 dxpme = Vec3.Subtract(xp_iac, xp);
|
||||
#Vec3 dxt = dxpme;
|
||||
Vec3 dxt = Vec3.Subtract(xp_iac, xp);
|
||||
dxt.SetZ(0.0);
|
||||
dxt.Normalize();
|
||||
if(aimp.Magnitude() > 0)
|
||||
{
|
||||
#call vsub(aimp,xp(1,me),dxi);
|
||||
Vec3 dxi = Vec3.Subtract(aimp, xp);
|
||||
dxi.SetZ(0.0);
|
||||
dxi.Normalize();
|
||||
}
|
||||
}
|
||||
|
||||
# if (kturn == 0) //C --POINT AT TGT
|
||||
# {
|
||||
# hdes = -xp(3,me);
|
||||
# if (lbit(pp_skrs,saskr) || pp_comg)
|
||||
# {
|
||||
# if (!ppmtrk)
|
||||
# {
|
||||
# hdes = amin1(hdes,-xp(3,iac));
|
||||
# }
|
||||
# }
|
||||
## //LBM - dont worry about rules right now
|
||||
## //C --CHANGED RULFLG VALUE 18 NOV 87 DICKERSON
|
||||
## if (rulflg == 1510)
|
||||
## {
|
||||
## call pcode(-rulflg);
|
||||
## hdes = prdalt;
|
||||
## }
|
||||
#
|
||||
# Vec3 aimpt = ((WsfBrawlerPlatform)PLATFORM).AimPoint(Vec3, double, Vec3, Vec3, double);
|
||||
#
|
||||
# #call intcpt(xp(1,me),spdnow(me),xp(1,iac),vp(1,iac),root3/2.0,0.0,hdes,hlvec,hlspd);
|
||||
# hlvec = ((WsfBrawlerPlatform)PLATFORM).Intercept(Vec3, PLATFORM.Speed()*MATH.FT_PER_M(), Vec3, Vec3, double, double, double);
|
||||
# hlspd = hlvec.Magnitude();
|
||||
# hlvec.Normalize();
|
||||
#
|
||||
# //goto 965;
|
||||
# }
|
||||
# //else
|
||||
if (kturn == 1 || kturn == -1) //C --END-RUN TGT
|
||||
{
|
||||
writeln_d("end run");
|
||||
double closmn = root3/2.0;
|
||||
double angint = splita*sgn;
|
||||
double hdes = PLATFORM.Altitude();
|
||||
//hdes = -xp(3,me);
|
||||
|
||||
//LBM - dont worry about lower targets or flying lower, for now
|
||||
# if (lbit(pp_skrs,saskr) || pp_comg)
|
||||
# {
|
||||
# if (!ppmtrk)
|
||||
# {
|
||||
# hdes = amin1(hdes,-xp(3,iac));
|
||||
# }
|
||||
# }
|
||||
//LBM - dont worry about rules right now
|
||||
# //C --CHANGED RULFLG VALUE 18 NOV 87 DICKERSON
|
||||
# if (rulflg == 1510)
|
||||
# {
|
||||
# call pcode(-rulflg);
|
||||
# hdes = prdalt;
|
||||
# }
|
||||
|
||||
|
||||
//LBM - TODO - verify units used in WsfBrawlerPlatform AimPoint and Intercept() methods!!!
|
||||
//call intcpt(xp(1,me),spdnow(me),xp(1,iac),vp(1,iac),root3/2.0,splita*sgn,hdes,hlvec,hlspd);
|
||||
Vec3 desVec = brawlerPlatform.Intercept(xp, spdnow, xp_iac, vp_iac, closmn, angint, hdes);
|
||||
hlvec = desVec.Normal();
|
||||
hlspd = desVec.Magnitude();
|
||||
|
||||
//brawlerPlatform.InterceptLocation3D(
|
||||
|
||||
//goto 965;
|
||||
}
|
||||
# else if (kturn == 2 || kturn == -2) //C --LOOP
|
||||
# {
|
||||
# if (lsoln) then
|
||||
# call xmit3(dxi,temp)
|
||||
# else
|
||||
# call xmit3(dxt,temp)
|
||||
# endif
|
||||
# call makex(vp(1,me),r)
|
||||
# call vxfrmc(r,temp,temp,1)
|
||||
# loopha = loopha .or. temp(1).lt.0.
|
||||
# loopnf = loopnf .or. (loopha .and. temp(1).gt.0. .and. (sign(1.,temp(2)).eq.sgn) )
|
||||
# if (loopnf) then
|
||||
# //C --HERE NO LONGER LOOP - POINT
|
||||
# goto 100
|
||||
# endif
|
||||
# temp(1) = 0.
|
||||
# temp(2) = sgn
|
||||
# temp(3) = 0.
|
||||
# call vxfrmc(r,hlvec,temp,2)
|
||||
# hlval = valme*1.5
|
||||
# hlspd = bvrmch*spdnow(me)/fmachp
|
||||
# //C --TURN OFF FORMATION VALUES DURING LOOP:
|
||||
# mdskpp = iand(mdskpp,6)
|
||||
# stkppp = stkppp*0.25
|
||||
# goto 970
|
||||
# }
|
||||
|
||||
# //C
|
||||
#//900 continue
|
||||
# //C --HERE NO TGT - PRESUMABLY DEAD
|
||||
# hlval = 0.
|
||||
# goto 970
|
||||
# //C
|
||||
|
||||
//965 continue
|
||||
//C --FINISH SETTING UP HIGH LEVEL STEERING VALUES
|
||||
#hlval = valeff(iac);
|
||||
hlval = brawlerPlatform.LastEngagementValue(targetTrack.Target());
|
||||
#writeln_d("hlvec = ", hlvec.ToString(), ", hlval = ", hlval, ", hlspd = ", hlspd);
|
||||
|
||||
//970 continue
|
||||
|
||||
//call steer
|
||||
#steer()
|
||||
# if (dirspc.ne.0) then
|
||||
# //C --SUPPRESS VECTORED FLIGHT VALUES - DIRECT HAS PRECEDENCE
|
||||
# valfpp= 0.0
|
||||
# elseif (vfspc.eq.0) then
|
||||
//C --USE NORMAL HIGH_LEVEL VALUES FOR VECTORED_FLIGHT
|
||||
//call xmit(3,hlvec,vecfpp)
|
||||
|
||||
extern Vec3 vecfpp;
|
||||
extern double valfpp;
|
||||
extern double sflypp;
|
||||
vecfpp = hlvec;
|
||||
valfpp = hlval;
|
||||
sflypp = hlspd;
|
||||
|
||||
writeln_d("vecfpp = ", vecfpp.ToString(), ", valfpp = ", valfpp, ", sflypp = ", sflypp);
|
||||
|
||||
|
||||
brawlerPlatform.SuggestVectoredFlight(vecfpp, valfpp, sflypp);
|
||||
# else
|
||||
# //C --USE FORCE_V VECTOR INSTEAD OF HL... VALUES
|
||||
# //C --THESE MAY BE SET BY EITHER PRODUCTION RULES OR IP
|
||||
# call xmit(3,hlvfor,vecfpp)
|
||||
# valfpp = hlvalf
|
||||
# sflypp = hlspdf
|
||||
# endif
|
||||
|
||||
|
||||
//call sepset(10.0) //LBM - not doing separation yet
|
||||
//9999
|
||||
return;
|
||||
|
||||
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
329
platforms/brawler/alternatives/behavior_weapon_decision_gun.txt
Normal file
329
platforms/brawler/alternatives/behavior_weapon_decision_gun.txt
Normal file
@@ -0,0 +1,329 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 aslct7.f and akshn7.f
|
||||
// Replicates the gun fire 7,3,7,x alternative behavior
|
||||
|
||||
include_once BrawlerScriptUtil.txt
|
||||
|
||||
behavior weapon_decision_gun
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
double RNGWPN = 3000.0; #feet (from MIND file)
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
WsfBrawlerPlatform brawlerPlatform;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawGuns = true;
|
||||
WsfDraw mDraw = WsfDraw();
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
// Takes the place of production rules
|
||||
bool mAlternative7371Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 7;
|
||||
int kalt = 3;
|
||||
int icall = 7; // Always 7 for gun
|
||||
int lcall = 1;
|
||||
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
|
||||
// Needed?
|
||||
brawlerPlatform = (WsfBrawlerPlatform)PLATFORM;
|
||||
end_on_init
|
||||
|
||||
// Replicates the checks done in canfirg.f
|
||||
// Return true if the gun can be fired ("hard" checks)
|
||||
// Sets the string to the fail reason
|
||||
script bool canfirg(string failMsg)
|
||||
/*
|
||||
cnfire = .false.
|
||||
C --NOTE THAT WE ARE RECALCULATING PILOT POSTURE VARIABLES HERE
|
||||
C --ppmrmx WILL BE NEEDED IN shldfrg, SO PERFORM THIS CALCULATION
|
||||
C --UNCONDITIONALLY.
|
||||
call gunenv(xp(1,me),vp(1,me),xp(1,ppmiac),vp(1,ppmiac),
|
||||
1 ppmptr,ppmrmn,ppmrmx,ppmapt,ppmse,ppmaof,ppmenv,ppmtrk,ppmohr,
|
||||
2 rbep )
|
||||
C --If temp midway in a 0.5 second burst exceeds maximum (1.0 by
|
||||
C --definition) then you can't shoot. Rate of temperature rise
|
||||
C --is 1.0/t_to_heat, so that firing for t_to_heat seconds reaches
|
||||
C --the limit.
|
||||
overheat = (gun_temp+0.25/t_to_heat .gt. 1.0)
|
||||
if (overheat) then
|
||||
rsfail = 'GUN OVERHEAT'
|
||||
return
|
||||
endif
|
||||
C
|
||||
C --CHECK IF TARGET IS IN ENVELOPE
|
||||
if (.not.ppmenv) then
|
||||
rsfail = 'NOT IN ENVELOPE '
|
||||
return
|
||||
endif
|
||||
C
|
||||
C --CHECK ON PROBABILITY IN RANGE
|
||||
pinrng = prmax2(ppmiac,ppmrmx,1.0,0.2)
|
||||
pbinrg = pinrng.ge.pr2lim
|
||||
if (.not.pbinrg) then
|
||||
rsfail = 'LOW PROB IN RANGE'
|
||||
return
|
||||
endif
|
||||
C
|
||||
visacq = inform(ppmiac).eq.1 .and. time.le.seet(ppmiac)+0.5
|
||||
C --If pilot has not had a recent visual (or does not have a
|
||||
C --radar lock if rdrgun is set), then gun can't be fired.
|
||||
if(.not.rdrgun) then
|
||||
C --DO I HAVE A RECENT VISUAL?
|
||||
if(.not.visacq) then
|
||||
rsfail = 'NO RECENT VISUAL'
|
||||
return
|
||||
endif
|
||||
else
|
||||
C --AN ESTABLISHED RADAR TRACK MAY SUBSTITUTE FOR A VISUAL
|
||||
C --IF RDRGUN=.TRUE.
|
||||
call lockid(iacid,ppmjid,locked)
|
||||
gunacq = visacq .or. locked.eq.2
|
||||
if(.not.gunacq) then
|
||||
rsfail = 'NO RECENT VISUAL OR LOCK'
|
||||
return
|
||||
endif
|
||||
endif
|
||||
C
|
||||
cnfire = .true.
|
||||
*/
|
||||
#bool canFire = false;
|
||||
bool canFire = true; #LBM - temporary
|
||||
|
||||
return canFire;
|
||||
end_script
|
||||
|
||||
// Replicates the checks done in shldfrg.f
|
||||
// Return true if the should should be fired ("soft" checks)
|
||||
// Sets the string to the fail reason if any
|
||||
script bool shldfrg(string failMsg)
|
||||
/*
|
||||
C --If target is inside Rmax2, don't need the following
|
||||
C --tests(target is inside no-escape range).
|
||||
C --CHECK THAT PILOT BELIEVES RANGE IS OK FOR TARGETING
|
||||
pinrng = prmax2(ppmiac,ppmrmx,ppm_rpeak,0.2)
|
||||
pbinrg = pinrng.ge.pr2lim
|
||||
call pdset('PROB_IN_RANGE',pbinrg)
|
||||
C
|
||||
C --CALCULATE CURRENT ENVELOPE LEVEL; ppmrmx WAS RECALCULATED IN canfirg
|
||||
elevnow = envlvg(rngnow(me,ppmiac),rdotme(ppmiac),ppmse,ppmrmx,
|
||||
1 'SHOOT')
|
||||
C --CALCULATE PROJECTED ENVELOPE, CONSTANT VELOCITY PROJECTION FOR
|
||||
C --ME AND CURRENT ACCELERATION PROJECTION FOR TARGET.
|
||||
C --call vecinc(xp(1,me),tproj3,vp(1,me),xme)
|
||||
C --Full projection for target, fixed velocity projection
|
||||
C --for attacker.
|
||||
C --call gunenv(xme,vp(1,me),xeut(1,ppmiac),veut(1,ppmiac),
|
||||
call gunenv(xeuan,veuan,xeut(1,ppmiac),veut(1,ppmiac),
|
||||
1 ppmptr,rmin,rmax,aimp,se,aof,inenvp,trkbl,ovrhoz,rbep)
|
||||
elevprj = envlvg(rngun(ppmiac),rngrun(ppmiac),se,rmax,'SHOOT')
|
||||
if(lprnt) write(ioutp,2000) rmin,rmax,rng(ppmiac),aimp,se,aof,
|
||||
1 elevprj
|
||||
C
|
||||
C --CHECK PROJECTION -- IS LEVEL DECREASING?
|
||||
worse = (elevnow.ge.elevprj)
|
||||
call pdset('SHOT_WORSENING',worse)
|
||||
C
|
||||
needid = (irel(ppmiac).eq.0) .and. (id_mode.ne.bvr_id_md)
|
||||
call pdset('SURE_BAD_GUY',.not.needid)
|
||||
C
|
||||
if (needid)then
|
||||
lfire = .false.
|
||||
rsfail = 'NEED ID'
|
||||
elseif(.not.(pbinrg.or.worse))then
|
||||
rsfail = '!(IN RPEAK OR WORSE)'
|
||||
lfire = .false.
|
||||
else
|
||||
lfire = .true.
|
||||
endif
|
||||
*/
|
||||
# bool lfire = false;
|
||||
bool lfire = true; #LBM - temporary
|
||||
|
||||
|
||||
return lfire;
|
||||
end_script
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition weapon_decision_gun, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
// aslct7.f line 123 - 132
|
||||
# --CHECK IF TARGET SELECTED
|
||||
# if (ppmiac .eq. 0 .and. .not.dewvmsl)then
|
||||
# rsfail = 'NO TARGET SELECTED'
|
||||
# goto 800
|
||||
# endif
|
||||
# --CHECK IF WEAPON SELECTED
|
||||
# if (ppmptr .eq. 0)then
|
||||
# rsfail = 'NO WEAPON SELECTED'
|
||||
# goto 800
|
||||
# endif
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() <= 0)
|
||||
{
|
||||
return Failure("no target selected");
|
||||
}
|
||||
|
||||
WsfTrack targetTrack = PLATFORM.MasterTrackList().FindTrack(tasks.Entry(0).LocalTrackId());
|
||||
if (!targetTrack.IsValid())
|
||||
{
|
||||
return Failure("no valid target track");
|
||||
}
|
||||
|
||||
#LBM - temporary
|
||||
# // Weapon selection done in selwpn.f (called from aslct2.f)
|
||||
# // checks weapon inventory. Use a similar check here as a replacement
|
||||
# if (!HaveWeapon(PLATFORM))
|
||||
# {
|
||||
# // TODO Account for weapon type gun/missile
|
||||
# return Failure("no weapon selected");
|
||||
# }
|
||||
|
||||
if (!PLATFORM.Weapon("gun").IsValid() || PLATFORM.Weapon("gun").QuantityRemaining() <= 0)
|
||||
{
|
||||
writeln_d(" ", PLATFORM.Name(), " no weapon selected at time: ", TIME_NOW);
|
||||
return Failure("no weapon selected");
|
||||
}
|
||||
|
||||
# // aslct7() calls canfir().
|
||||
# // canfir.f checks production rules and GCI inhibit
|
||||
# // just doing a simple flag for now
|
||||
# if (!mAlternative7371Enabled)
|
||||
# {
|
||||
# writeln_d("behavior not enabled!");
|
||||
# return Failure("behavior alternative not enabled");
|
||||
# }
|
||||
#
|
||||
# //canfir.f calls canfirg()
|
||||
# string msg = "";
|
||||
# if (!canfirg(msg))
|
||||
# {
|
||||
# return Failure(msg);
|
||||
# }
|
||||
#
|
||||
# // aslct7 line 199 - 205
|
||||
# // if undamaged calls shldfr().
|
||||
# // if we are damaged skip checks and fire now
|
||||
# if (PLATFORM.DamageFactor() <= 0.0)
|
||||
# {
|
||||
# // shldfr.f just calls the specific weapon type
|
||||
# if (!shldfrg(msg))
|
||||
# {
|
||||
# return Failure(msg);
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# // aslct7 creates and alternative to evaluate.
|
||||
# // The alternative has no projection and always
|
||||
# // evaluates to 1, so skip that processing
|
||||
|
||||
WsfWeapon gun = PLATFORM.Weapon("gun");
|
||||
if (gun.LaunchComputer().CanIntercept(targetTrack, 0.1)) #see "firing_delay" for BULLET weapon
|
||||
{
|
||||
WsfGeoPoint pt = gun.LaunchComputer().InterceptPoint();
|
||||
|
||||
#TODO - move slant range check to gun's launch computer???
|
||||
|
||||
if (PLATFORM.SlantRangeTo(pt) <= (RNGWPN * MATH.M_PER_FT()))
|
||||
{
|
||||
# #draw line to intercept point
|
||||
# if (mDrawGuns)
|
||||
# {
|
||||
# double delta = ((WsfBrawlerPlatform)PLATFORM).ProjectedTimeDelta();
|
||||
# mDraw.SetLayer("behavior_weapon_decision_gun");
|
||||
# mDraw.SetDuration(delta);
|
||||
# mDraw.SetColor(0.5, 0.5, 0.5); #gray
|
||||
# mDraw.SetLineSize(1);
|
||||
# mDraw.SetLineStyle("solid");
|
||||
# mDraw.BeginLines();
|
||||
# mDraw.Vertex(PLATFORM.Location());
|
||||
# mDraw.Vertex(pt);
|
||||
# mDraw.End();
|
||||
# }
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
writeln_d("no gun fire, too far away");
|
||||
return Failure("no gun fire, too far away");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
writeln_d("gun cannot intercept target yet");
|
||||
return Failure("gun cannot intercept target yet");
|
||||
}
|
||||
|
||||
// All conditions pass, weapon can fire
|
||||
return true;
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
// Replicates akshn7.f
|
||||
// We don't need to do all the bookeeping that BRAWLER
|
||||
// does. Just launch the weapon.
|
||||
// TODO Fill in gun fire
|
||||
|
||||
|
||||
|
||||
#LBM - temporary
|
||||
WsfTrack targetTrack = PLATFORM.MasterTrackList().FindTrack(processor.TasksReceivedOfType("WEAPON").Entry(0).LocalTrackId());
|
||||
WsfWeapon weapon = PLATFORM.Weapon("gun");
|
||||
bool launched = weapon.FireSalvo(targetTrack, 1); // Always firing one for now
|
||||
if (!launched)
|
||||
{
|
||||
writeln_d(" ", PLATFORM.Name(), " could NOT fire at track: ", targetTrack.TargetName(), " at time: ", TIME_NOW);
|
||||
}
|
||||
else if (mDrawGuns)
|
||||
{
|
||||
double delta = ((WsfBrawlerPlatform)PLATFORM).ProjectedTimeDelta();
|
||||
|
||||
mDraw.SetLayer("behavior_weapon_decision_gun");
|
||||
mDraw.SetDuration(delta);
|
||||
mDraw.SetColor(1.0, 1.0, 1.0); #white
|
||||
mDraw.SetLineSize(2);
|
||||
mDraw.SetLineStyle("dotted2");
|
||||
mDraw.BeginLines();
|
||||
mDraw.Vertex(PLATFORM.Location());
|
||||
mDraw.Vertex(targetTrack.CurrentLocation());
|
||||
mDraw.End();
|
||||
}
|
||||
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
@@ -0,0 +1,510 @@
|
||||
# ****************************************************************************
|
||||
# CUI
|
||||
#
|
||||
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
|
||||
#
|
||||
# The use, dissemination or disclosure of data in this file is subject to
|
||||
# limitation or restriction. See accompanying README and LICENSE for details.
|
||||
# ****************************************************************************
|
||||
|
||||
// converted BRAWLER v7.5 aslct7.f and akshn7.f
|
||||
// Replicates the missile fire 7,3,1,x alternative behavior
|
||||
|
||||
include_once BrawlerScriptUtil.txt
|
||||
|
||||
behavior weapon_decision_missile
|
||||
|
||||
script_debug_writes off
|
||||
|
||||
script_variables
|
||||
|
||||
WsfQuantumTaskerProcessor processor;
|
||||
|
||||
//**********************************************************************//
|
||||
//** debugging parameters **//
|
||||
//**********************************************************************//
|
||||
bool mDrawSteering = false;
|
||||
|
||||
//**********************************************************************//
|
||||
//** alternative parameters **//
|
||||
//**********************************************************************//
|
||||
// Flag used to enable/disable this alternative
|
||||
// Takes the place of production rules
|
||||
bool mAlternative7311Enabled = true;
|
||||
|
||||
// Alternative ID
|
||||
int ilevel = 7;
|
||||
int kalt = 3;
|
||||
int icall = 1; // Weapon number, for missiles 1 - 6
|
||||
int lcall = 1;
|
||||
|
||||
// Max/Min range for a SRM (meters)
|
||||
double mMaxRange = 25000 * Math.M_PER_FT();
|
||||
double mMinRange = 4000 * Math.M_PER_FT();
|
||||
|
||||
// Maximum angle a shot can be taken at (degrees)
|
||||
double mMaxFiringAngle = 15.0;
|
||||
|
||||
// Percent range is reduced by for simple envelope
|
||||
double mPercentRange = 0.2;
|
||||
|
||||
// Maximum number of missiles on a target
|
||||
int mTargetSaturation = 1;
|
||||
// Required track quality for a shot
|
||||
double mRequiredTrackQuality = 0.8;
|
||||
|
||||
//**********************************************************************//
|
||||
//********* VARIABLES BELOW THIS LINE ARE NOT FOR USER EDITING *********//
|
||||
//**********************************************************************//
|
||||
double grav = 32.17405; // From pcon.fi
|
||||
|
||||
end_script_variables
|
||||
|
||||
on_init
|
||||
if (PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
processor = (WsfQuantumTaskerProcessor)PROCESSOR;
|
||||
}
|
||||
end_on_init
|
||||
|
||||
// Replicates the checks done in canfirm.f
|
||||
// Return true if the missile can be fired
|
||||
// Sets the string to the fail reason
|
||||
script bool canfirm(WsfLocalTrack target, string failMsg)
|
||||
/*
|
||||
cnfire = .false.
|
||||
--MISSILE COMING OFF RAIL
|
||||
if (lnchng) then
|
||||
rsfail = 'MISL COMING OFF RAIL'
|
||||
return
|
||||
endif
|
||||
|
||||
--SWITCHOLOGY DELAYS
|
||||
pswtch = (time .ge. timemf)
|
||||
if (.not. pswtch)then
|
||||
rsfail = 'SWITCHOLOGY'
|
||||
return
|
||||
endif
|
||||
|
||||
--CHECK IF TARGET IS IN ENVELOPE
|
||||
--NOTE THAT SOME PPM... VARIABLES ARE RECALCULATED.
|
||||
call mslenv_typ_mm(ppmiac,renv_typ)
|
||||
call mslenv(iacid,xp(1,me),vp(1,me),ap(1,me),
|
||||
1 alphap,xp(1,ppmiac),vp(1,ppmiac),ap(1,ppmiac),
|
||||
2 ppmptr, rbep, rwep, ext_mle, .true., renv_typ, ppmrmn, ppmrmx,
|
||||
3 ppmapt, ppmse, ppmaof, ppmenv, ppmtrk, ppmohr,l_config)
|
||||
if (.not. ppmenv)then
|
||||
rsfail = 'TGT NOT IN ENV'
|
||||
return
|
||||
endif
|
||||
|
||||
--Does pilot beleive that target is within max range (R<Rmax1)?
|
||||
pinrng = prmax2(ppmiac,ppmrmx,1.,0.2)
|
||||
pbinrg = (pinrng .gt. pr2lim)
|
||||
if (.not.pbinrg)then
|
||||
rsfail = 'LOW PROB. TGT IN RNG'
|
||||
return
|
||||
endif
|
||||
if(lnchma.eq.0)then
|
||||
rsfail = 'FAIL ALL FIRE MODES'
|
||||
return
|
||||
endif
|
||||
cnfire = .true.
|
||||
*/
|
||||
|
||||
// Not currently checking for another missile coming off the rail
|
||||
|
||||
// Not currently checking for switchology delays
|
||||
|
||||
// CHECK IF TARGET IS IN ENVELOPE
|
||||
// Using a very simplified replacement of mslenv()
|
||||
// that take a percentage of ange and a simple angle check
|
||||
double range = PLATFORM.SlantRangeTo(target);
|
||||
double absRelativeBearing = MATH.Fabs(PLATFORM.RelativeBearingTo(target));
|
||||
if (range < (mMinRange + mMinRange * mPercentRange) ||
|
||||
range > (mMaxRange - mMaxRange * mPercentRange) ||
|
||||
absRelativeBearing >= mMaxFiringAngle )
|
||||
{
|
||||
#writeln("absRelativeBearing = ", absRelativeBearing, ", range = ", range);
|
||||
#failMsg = "TGT NOT IN ENV";
|
||||
target.SetAuxData("msg", "TGT NOT IN ENV");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Does pilot beleive that target is within max range (R<Rmax1)?
|
||||
// Using simplified version of prmax2
|
||||
// and assuming short range missile with rmax = 25000 ft
|
||||
double drng = (mMaxRange - PLATFORM.SlantRangeTo(target));
|
||||
if (drng < 0.0)
|
||||
{
|
||||
#failMsg = "LOW PROB. TGT IN RNG";
|
||||
target.SetAuxData("msg", "LOW PROB. TGT IN RNG");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Not currently checking launch modes
|
||||
// lnchma set if fctest() passes checks
|
||||
|
||||
return true;
|
||||
end_script
|
||||
|
||||
// Replicates the checks done in shldfrm.f
|
||||
// Return true if the missile should be fired
|
||||
// Sets the string to the fail reason if any
|
||||
script bool shldfrm(WsfLocalTrack target, string failMsg)
|
||||
/*
|
||||
C --CHECK THAT PILOT BELIEVES RANGE IS OK FOR TARGETING
|
||||
pinrng = prmax2(ppmiac,ppmrmx,ppm_rpeak,0.2)
|
||||
pbinrg = pinrng.ge.pr2lim
|
||||
call pdset('PROB_IN_RANGE',pbinrg)
|
||||
call mslenv_typ_mm(ppmiac,renv_typ)
|
||||
C
|
||||
C --CALCULATE tgleav
|
||||
C --POSSIBLE PROJECTIONS
|
||||
C -- ATTACKER TARGET
|
||||
C --(1) CONSTANT VELOCITY XEUAN CONSTANT VELOCITY vecinc
|
||||
C --(2) CURRENT MANEUVER XEUA CURRENT MANEUVER XEUT
|
||||
C --(3) CURRENT MANEUVER XEUA CONSTANT VELOCITY vecinc
|
||||
C --(4) CONSTANT VELOCITY XEUAN CURRENT MANEUVER XEUT
|
||||
C --LOGIC IS AS FOLLOWS:
|
||||
C --IF CASE (1) (neither maneuver) IS IN ENVELOPE THEN
|
||||
C -- IF CASE (2) (both maneuver) IS OUT OF ENVELOPE
|
||||
C -- IF CASE (3) (atkr maneuvers) IS IN ENVELOPE
|
||||
C -- IF CASE(4) (tgt maneuvers) IS OUT OF ENVELOPE
|
||||
C -- ASSERT: TARGET AT FAULT
|
||||
C
|
||||
C CASE 1: CALCULATE INENVP_CC
|
||||
if (ient.eq.sament) then
|
||||
call xmit3(xp(1,me),xme)
|
||||
call xmit3(vp(1,me),vme)
|
||||
call xmit(9,rbep,rbeme)
|
||||
call xmit(9,rwep,rweme)
|
||||
else
|
||||
call xmit3(xeuan,xme)
|
||||
call xmit3(veuan,vme)
|
||||
call xmit(9,rbeuan,rbeme)
|
||||
call xmit(9,rweuan,rweme)
|
||||
endif
|
||||
call vecinc(xp(1,ppmiac),tproj3,vp(1,ppmiac),xtgt)
|
||||
call xmit3(vp(1,ppmiac),vtgt)
|
||||
call zero3(azero)
|
||||
xtgt(3) = amin1(xtgt(3),-50.)
|
||||
call mslenv(iacid,xme,vme,azero,alphap,xtgt,vtgt,azero,
|
||||
1 misl(mslpp),rbeme,rweme,.false.,.true.,renv_typ,rmin_mm,
|
||||
2 rmax_mm,aimp,se_mm,aof_mm,inenvp_cc,trkbl,ovrhoz,l_config)
|
||||
C --"target leaving" CANNOT BE TRUE IF NOT IN ENVELOPE WHEN NEITHER
|
||||
C --MANEUVERING
|
||||
if(.not.inenvp_cc)then
|
||||
tgleav = .false.
|
||||
goto 200
|
||||
endif
|
||||
C
|
||||
C --CASE 2: CALCULATE INENVP_MM
|
||||
if (ient.eq.sament) then
|
||||
C --USE SAME AS CASE 1 SINCE I CAN'T MANEUVER
|
||||
continue
|
||||
else
|
||||
call xmit3(xeua,xme)
|
||||
call xmit3(veua,vme)
|
||||
call xmit(9,rbeua,rbeme)
|
||||
call xmit(9,rweua,rweme)
|
||||
endif
|
||||
call xmit3(xeut(1,ppmiac),xtgt)
|
||||
call xmit3(veut(1,ppmiac),vtgt)
|
||||
call mslenv(iacid,xme,vme,azero,alphap,xtgt,vtgt,azero,
|
||||
1 misl(mslpp),rbeme,rweme,.false.,.true.,renv_typ,rmin,rmax,
|
||||
2 aimp,se,aof,inenvp_mm,trkbl,ovrhoz,l_config)
|
||||
C --"target leaving" CANNOT BE TRUE IF STILL IN ENV. WHEN BOTH MANEUVER
|
||||
if(inenvp_mm)then
|
||||
tgleav = .false.
|
||||
goto 200
|
||||
endif
|
||||
C
|
||||
C --CASE 3: CALCULATE INENVP_MC
|
||||
if (ient.eq.sament) then
|
||||
C --USE SAME AS CASE 1 SINCE I CAN'T MANEUVER
|
||||
continue
|
||||
else
|
||||
call xmit3(xeua,xme)
|
||||
call xmit3(veua,vme)
|
||||
call xmit(9,rbeua,rbeme)
|
||||
call xmit(9,rweua,rweme)
|
||||
endif
|
||||
call vecinc(xp(1,ppmiac),tproj3,vp(1,ppmiac),xtgt)
|
||||
call xmit3(vp(1,ppmiac),vtgt)
|
||||
xtgt(3) = amin1(xtgt(3),-50.)
|
||||
call mslenv(iacid,xme,vme,azero,alphap,xtgt,vtgt,azero,
|
||||
1 misl(mslpp),rbeme,rweme,.false.,.true.,renv_typ,rmin,rmax,
|
||||
2 aimp,se,aof,inenvp_mc,trkbl,ovrhoz,l_config)
|
||||
if(.not.inenvp_mc)then
|
||||
tgleav = .false.
|
||||
goto 200
|
||||
endif
|
||||
C
|
||||
C --CASE 4: CALCULATE INENVP_CM
|
||||
if (ient.eq.sament) then
|
||||
C --USE SAME AS CASE 1 SINCE I CAN'T MANEUVER
|
||||
continue
|
||||
else
|
||||
call xmit3(xeuan,xme)
|
||||
call xmit3(veuan,vme)
|
||||
call xmit(9,rbeuan,rbeme)
|
||||
call xmit(9,rweuan,rweme)
|
||||
endif
|
||||
call xmit3(xeut(1,ppmiac),xtgt)
|
||||
call xmit3(veut(1,ppmiac),vtgt)
|
||||
call mslenv(iacid,xme,vme,azero,alphap,xtgt,vtgt,azero,
|
||||
1 misl(mslpp),rbeme,rweme,.false.,.true.,renv_typ,rmin,rmax,aimp,
|
||||
2 se,aof,inenvp_cm,trkbl,ovrhoz,l_config)
|
||||
tgleav = .not.inenvp_cm
|
||||
C
|
||||
200 continue
|
||||
call pdset('TGT_LEAVING_ENV',tgleav)
|
||||
C
|
||||
C --Calculate current envelope level (WORSE)
|
||||
elevnow= envlvl(rngnow(me,ppmiac),rdotme(ppmiac),ppmse,
|
||||
1 ppmaof,ppmrmn,ppmrmx,ppm_rpeak,ppm_semax,aoffmx,
|
||||
2 ppmtrk,ppmohr,'SHOOT ')
|
||||
C
|
||||
if (ient.ne.sament) then
|
||||
elevprj= envlvl(rng(ppmiac),rngr(ppmiac),se_mm,aof_mm,rmin_mm,
|
||||
1 rmax_mm,ppm_rpeak,ppm_semax,aoffmx,trkbl,ovrhoz,'SHOOT ')
|
||||
if(lprnt) write(ioutp,2000) rmin_mm,rmax_mm,
|
||||
1 rng(ppmiac),aimp,se_mm,aof_mm,elevprj
|
||||
else
|
||||
C --rng, rngr NOT SET FOR SAM, USE rngun, rngrun
|
||||
elevprj= envlvl(rngun(ppmiac),rngrun(ppmiac),se_mm,aof_mm,
|
||||
1 rmin_mm,rmax_mm,ppm_rpeak,ppm_semax,aoffmx,trkbl,ovrhoz,
|
||||
2 'SHOOT ')
|
||||
if(lprnt) write(ioutp,2000) rmin_mm,rmax_mm,
|
||||
1 rngun(ppmiac),aimp,se_mm,aof_mm,elevprj
|
||||
endif
|
||||
C --CHECK PROJECTION -- IS LEVEL DECREASING?
|
||||
worse = (elevnow.ge.elevprj)
|
||||
call pdset('SHOT_WORSENING',worse)
|
||||
10 continue
|
||||
C
|
||||
C --Check if target is too near beam for successful semi-active
|
||||
C -- missile shot
|
||||
lbeam = beamsht()
|
||||
call pdset('SA_BEAM_SHOT',lbeam)
|
||||
C
|
||||
C --If positive target ID required to fire, has ID been
|
||||
C --established?
|
||||
needid = (irel(ppmiac).eq.0) .and. (id_mode.ne.bvr_id_md)
|
||||
call pdset('SURE_BAD_GUY',.not.needid)
|
||||
C
|
||||
C --check for fratricide risk
|
||||
call set_hldcod(mslpp,ppmiac,hldcode,pp_skrs,pp_undes,lfrshot)
|
||||
lfrat = lbit(hldcode,2)
|
||||
call pdset('FRAT_RISK',lfrat)
|
||||
C
|
||||
C --CHECK IF FRIEND HAS A BETTER SHOT
|
||||
lfrnd = lbit(hldcode,1)
|
||||
call pdset('FRND_BETTER_SHOT',lfrnd)
|
||||
C
|
||||
C --Is target already engaged with max number of missiles/target?
|
||||
other_tgtd = 0
|
||||
do 100 igg=1,ngg
|
||||
iacf = listf(igg)
|
||||
acidf = iacidt(iacf)
|
||||
if (iacid .eq. acidf)goto 100
|
||||
C --Don't count another's selection if you have a much better
|
||||
C --shot, since he will wait for you to shoot
|
||||
if (.not.lfrshot(iacf)) goto 100
|
||||
C --Don't count another's selection if you have selected the
|
||||
C --same target earlier! RMK 9 Apr 92
|
||||
C --(Cant use others_tgt(iacid) here since not set until akshn7)
|
||||
if (others_tgt(acidf).eq.ppmiac)then
|
||||
C --However, we do need to use others_tgt(iacid) here, since
|
||||
C --we need to use others_msgtim(iacid), which is only correct
|
||||
C --if others_tgt(iacid) .eq. ppmiac
|
||||
if(others_tgt(iacid).eq.ppmiac) then
|
||||
C --I have selected this tgt previously
|
||||
if (others_msgtim(acidf).lt.others_msgtim(iacid)) then
|
||||
C --He selected this target earlier than I, so count him
|
||||
other_tgtd = other_tgtd + 1
|
||||
endif
|
||||
else
|
||||
C --I just changed to this target, so if anybody else has
|
||||
C --sent me a message selecting him, they must have gotten
|
||||
C --there first
|
||||
other_tgtd = other_tgtd + 1
|
||||
endif
|
||||
endif
|
||||
100 continue
|
||||
110 continue
|
||||
satur = ((nmhutl(ppmiac)+other_tgtd).ge.mxtgt_ac(ppmjid))
|
||||
call pdset('TARGET_SATURATED',satur)
|
||||
skr_lock = .false.
|
||||
do 300 iseek = 1, mx_skr
|
||||
if (skr_acquired(iseek)) then
|
||||
skr_lock = .true.
|
||||
goto 305
|
||||
endif
|
||||
300 continue
|
||||
305 continue
|
||||
call pdset('SEEKER_LOCK',skr_lock)
|
||||
C
|
||||
C --CHECK WEAPON QUALITY TRACK
|
||||
C --no_trk indicates track not needed for this launch mode
|
||||
no_trk = (lnchma .eq. ppsli) .or.
|
||||
1 (lnchma .eq. ppslr) .or.
|
||||
2 (lnchma .eq. pcguv) .or.
|
||||
3 (lnchma .eq. pvtnhms)
|
||||
if (.not.usewqt(iflite)) then
|
||||
C --Flight does not require WQT
|
||||
needwqt = .false.
|
||||
elseif (no_trk) then
|
||||
C --Using a luanch mode that is not cued from a track
|
||||
needwqt = .false.
|
||||
else
|
||||
needwqt = .not.wpnqual
|
||||
endif
|
||||
400 continue
|
||||
C
|
||||
C --FIRING LOGIC:
|
||||
lfire =
|
||||
1 .not.(needid.or.satur.or.lfrat.or.lfrnd.or.lbeam.or.needwqt)
|
||||
2 .and.(pbinrg.or.(worse.and..not.tgleav))
|
||||
if(lfire)then
|
||||
rsfail = ' '
|
||||
else
|
||||
if(needid)then
|
||||
rsfail = 'NEED ID'
|
||||
elseif(satur)then
|
||||
rsfail = 'MXTGT_AC LIMIT'
|
||||
elseif(lfrat)then
|
||||
rsfail = 'FRATRICIDE RISK'
|
||||
elseif(lfrnd)then
|
||||
rsfail = 'FRND HAS BETTER SHOT'
|
||||
elseif(lbeam)then
|
||||
rsfail = 'TGT TOO NEAR BEAM'
|
||||
elseif(.not.(pbinrg.or.(worse.and..not.tgleav)))then
|
||||
rsfail = 'FAILED ENV LOGIC'
|
||||
elseif (needwqt) then
|
||||
rsfail = 'NO WEAPON QUAL TRK'
|
||||
else
|
||||
call nabort('SHLDFRM..unknown failure reason')
|
||||
endif
|
||||
endif
|
||||
*/
|
||||
|
||||
// ONLY Checking target stauration and track quality for now
|
||||
if (PLATFORM.WeaponsActiveFor(target.TrackId()) >= mTargetSaturation)
|
||||
{
|
||||
//lfire = true;
|
||||
writeln_d(" ", PLATFORM.Name(), " shouldn't fire ", target.TargetName(), " saturated");
|
||||
failMsg = "MXTGT_AC LIMIT";
|
||||
return false;
|
||||
}
|
||||
if (target.TrackQuality() < mRequiredTrackQuality)
|
||||
{
|
||||
failMsg = "NO WEAPON QUAL TRK";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
end_script
|
||||
|
||||
precondition
|
||||
#writeln_d(PLATFORM.Name(), " precondition weapon_decision_missile, T=", TIME_NOW);
|
||||
|
||||
### Evaluate conditions that would prevent behavior alternative from running
|
||||
|
||||
if (!PROCESSOR.IsA_TypeOf("WSF_QUANTUM_TASKER_PROCESSOR"))
|
||||
{
|
||||
writeln_d("not a quantum tasker!");
|
||||
return Failure("behavior not attached to a WSF_QUANTUM_TASKER_PROCESSOR");
|
||||
}
|
||||
|
||||
// aslct7.f line 123 - 132
|
||||
# --CHECK IF TARGET SELECTED
|
||||
# if (ppmiac .eq. 0 .and. .not.dewvmsl)then
|
||||
# rsfail = 'NO TARGET SELECTED'
|
||||
# goto 800
|
||||
# endif
|
||||
# --CHECK IF WEAPON SELECTED
|
||||
# if (ppmptr .eq. 0)then
|
||||
# rsfail = 'NO WEAPON SELECTED'
|
||||
# goto 800
|
||||
# endif
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
if(tasks.Count() <= 0)
|
||||
{
|
||||
return Failure("no tasks");
|
||||
}
|
||||
// Assuming 1v1 and first and only task is the one we want
|
||||
WsfLocalTrack targetTrack = PLATFORM.MasterTrackList().FindTrack(tasks.Entry(0).LocalTrackId());
|
||||
if(tasks.Count() <= 0 || targetTrack.IsNull() || !targetTrack.IsValid())
|
||||
{
|
||||
writeln_d(" ", PLATFORM.Name(), " no target selected at time: ", TIME_NOW);
|
||||
return Failure("no target selected");
|
||||
}
|
||||
// Weapon selection done in selwpn.f (called from aslct2.f)
|
||||
// checks weapon inventory. Use a similar check here as a replacement
|
||||
if (!PLATFORM.Weapon("srm").IsValid() || PLATFORM.Weapon("srm").QuantityRemaining() <= 0)
|
||||
{
|
||||
writeln_d(" ", PLATFORM.Name(), " no weapon selected at time: ", TIME_NOW);
|
||||
return Failure("no weapon selected");
|
||||
}
|
||||
|
||||
// aslct7() calls canfir().
|
||||
// canfir.f checks production rules and GCI inhibit
|
||||
// just doing a simple flag for now
|
||||
if (!mAlternative7311Enabled)
|
||||
{
|
||||
writeln_d("behavior not enabled!");
|
||||
return Failure("behavior alternative not enabled");
|
||||
}
|
||||
|
||||
//canfir.f calls canfirm()
|
||||
string msg = "";
|
||||
if (!canfirm(targetTrack, msg))
|
||||
{
|
||||
msg = targetTrack.AuxDataString("msg");
|
||||
writeln_d(" ", PLATFORM.Name(), " couldn't fire at time: ", TIME_NOW, " ", msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
|
||||
// aslct7 line 199 - 205
|
||||
// if undamaged calls shldfr().
|
||||
// if we are damaged skip checks and fire now
|
||||
if (PLATFORM.DamageFactor() <= 0.0)
|
||||
{
|
||||
// shldfr.f just calls the specific weapon type
|
||||
if (!shldfrm(targetTrack, msg))
|
||||
{
|
||||
writeln_d(" ", PLATFORM.Name(), " shouldn't fire at time: ", TIME_NOW, " ", msg);
|
||||
return Failure(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// aslct7 creates and alternative to evaluate.
|
||||
// The alternative has no projection and always
|
||||
// evaluates to 1, so skip that processing
|
||||
|
||||
// All conditions pass, weapon can fire
|
||||
return true;
|
||||
end_precondition
|
||||
|
||||
execute
|
||||
// Replicates akshn7.f
|
||||
// We don't need to do all the bookeeping that BRAWLER
|
||||
// does. Just launch the weapon.
|
||||
|
||||
WsfTaskList tasks = processor.TasksReceivedOfType("WEAPON");
|
||||
// Assuming 1v1 and first and only task is the one we want
|
||||
WsfLocalTrack targetTrack = PLATFORM.MasterTrackList().FindTrack(tasks.Entry(0).LocalTrackId());
|
||||
|
||||
//Assuming weapon name, checked in precondition
|
||||
WsfWeapon weapon = PLATFORM.Weapon("srm");
|
||||
bool launched = weapon.FireSalvo(targetTrack, 1); // Always firing one for now
|
||||
if (!launched)
|
||||
{
|
||||
writeln_d(" ", PLATFORM.Name(), " could NOT fire at track: ", targetTrack.TargetName(), " at time: ", TIME_NOW);
|
||||
}
|
||||
end_execute
|
||||
|
||||
end_behavior
|
||||
|
||||
Reference in New Issue
Block a user