getCostChange
PURPOSE 
040407 RS. costChange = meassures how fast the enemy is approaching per time
SYNOPSIS 
function [fuzzy_costChange, oldCost, oldSimulationTime] = getCostChange(oldCost, cost, oldSimulationTime, enemy, friendly_force)
DESCRIPTION 
CROSS-REFERENCE INFORMATION 
This function calls:
This function is called by:
SOURCE CODE 
0001
0002
0003 function [fuzzy_costChange, oldCost, oldSimulationTime] = getCostChange(oldCost, cost, oldSimulationTime, enemy, friendly_force)
0004
0005
0006
0007
0008
0009
0010 global simulationTime;
0011 costChange = cost - oldCost;
0012 if costChange == 0
0013 fuzzy_costChange = [0.33 0.34 0.33];
0014 return;
0015 end;
0016 timeChange = abs(simulationTime - oldSimulationTime);
0017 costChangePerTime = costChange/timeChange;
0018
0019 oldCost = cost;
0020 oldSimulationTime = simulationTime;
0021
0022 fuzzy_costChange = [0.334 0.332 0.334];
0023
0024 c = 0.05;
0025 if costChangePerTime > c
0026 fuzzy_costChange = [0 0 1];
0027 return;
0028 end;
0029 if costChangePerTime < c
0030 fuzzy_costChange = [1 0 0];
0031 return;
0032 end;
0033 if costChange <= 0
0034 neutral = (c + costChange)/c;
0035 else
0036 neutral = (c + costChange)/c;
0037 end;
0038 fuzzy_costChange = [neutral/2 neutral neutral/2];
Generated on Wed 16-Mar-2005 09:17:47 by m2html © 2003