mirror of
https://github.com/ineedbots/iw5_bot_warfare.git
synced 2025-06-28 23:21:51 +00:00
comments spacing
This commit is contained in:
@ -907,11 +907,11 @@ RaySphereIntersect( start, end, spherePos, radius )
|
||||
return false;
|
||||
|
||||
mu1 = ( 0 - b + sqrt( bb4ac ) ) / ( 2 * a );
|
||||
//mu2 = (0-b - sqrt(bb4ac)) / (2 * a);
|
||||
// mu2 = (0-b - sqrt(bb4ac)) / (2 * a);
|
||||
|
||||
// intersection points of the sphere
|
||||
ip1 = start + mu1 * dp;
|
||||
//ip2 = start + mu2 * dp;
|
||||
// ip2 = start + mu2 * dp;
|
||||
|
||||
myDist = DistanceSquared( start, end );
|
||||
|
||||
@ -1525,7 +1525,7 @@ _WaypointsToKDTree( waypoints, dem )
|
||||
heap HeapRemove();
|
||||
}
|
||||
|
||||
median = int( sorted.size / 2 ); //use divide and conq
|
||||
median = int( sorted.size / 2 ); // use divide and conq
|
||||
|
||||
left = [];
|
||||
right = [];
|
||||
@ -1616,7 +1616,7 @@ KDTree()
|
||||
/*
|
||||
Called on a KDTree. Will insert the object into the KDTree.
|
||||
*/
|
||||
KDTreeInsert( data ) //as long as what you insert has a .origin attru, it will work.
|
||||
KDTreeInsert( data ) // as long as what you insert has a .origin attru, it will work.
|
||||
{
|
||||
self.root = self _KDTreeInsert( self.root, data, 0, -2147483647, -2147483647, -2147483647, 2147483647, 2147483647, 2147483647 );
|
||||
}
|
||||
@ -1976,9 +1976,9 @@ GetNearestWaypoint( pos )
|
||||
*/
|
||||
AStarSearch( start, goal, team, greedy_path )
|
||||
{
|
||||
open = NewHeap( ::ReverseHeapAStar ); //heap
|
||||
openset = [];//set for quick lookup
|
||||
closed = [];//set for quick lookup
|
||||
open = NewHeap( ::ReverseHeapAStar ); // heap
|
||||
openset = []; // set for quick lookup
|
||||
closed = []; // set for quick lookup
|
||||
|
||||
|
||||
startWp = getNearestWaypoint( start );
|
||||
@ -2010,26 +2010,26 @@ AStarSearch( start, goal, team, greedy_path )
|
||||
|
||||
|
||||
node = spawnStruct();
|
||||
node.g = 0; //path dist so far
|
||||
node.h = DistanceSquared( level.waypoints[ startWp ].origin, level.waypoints[ goalWp ].origin ); //herustic, distance to goal for path finding
|
||||
node.g = 0; // path dist so far
|
||||
node.h = DistanceSquared( level.waypoints[ startWp ].origin, level.waypoints[ goalWp ].origin ); // herustic, distance to goal for path finding
|
||||
node.f = node.h + node.g; // combine path dist and heru, use reverse heap to sort the priority queue by this attru
|
||||
node.index = startWp;
|
||||
node.parent = undefined; //we are start, so we have no parent
|
||||
node.parent = undefined; // we are start, so we have no parent
|
||||
|
||||
//push node onto queue
|
||||
// push node onto queue
|
||||
openset[ node.index + "" ] = node;
|
||||
open HeapInsert( node );
|
||||
|
||||
//while the queue is not empty
|
||||
// while the queue is not empty
|
||||
while ( open.data.size )
|
||||
{
|
||||
//pop bestnode from queue
|
||||
// pop bestnode from queue
|
||||
bestNode = open.data[ 0 ];
|
||||
open HeapRemove();
|
||||
openset[ bestNode.index + "" ] = undefined;
|
||||
wp = level.waypoints[ bestNode.index ];
|
||||
|
||||
//check if we made it to the goal
|
||||
// check if we made it to the goal
|
||||
if ( bestNode.index == goalWp )
|
||||
{
|
||||
path = [];
|
||||
@ -2044,7 +2044,7 @@ AStarSearch( start, goal, team, greedy_path )
|
||||
level.waypointUsage[ team ][ bestNode.index + "" ]++;
|
||||
}
|
||||
|
||||
//construct path
|
||||
// construct path
|
||||
path[ path.size ] = bestNode.index;
|
||||
|
||||
bestNode = bestNode.parent;
|
||||
@ -2053,7 +2053,7 @@ AStarSearch( start, goal, team, greedy_path )
|
||||
return path;
|
||||
}
|
||||
|
||||
//for each child of bestnode
|
||||
// for each child of bestnode
|
||||
for ( i = wp.children.size - 1; i >= 0; i-- )
|
||||
{
|
||||
child = wp.children[ i ];
|
||||
@ -2066,7 +2066,7 @@ AStarSearch( start, goal, team, greedy_path )
|
||||
temppen = 1;
|
||||
|
||||
if ( isDefined( level.waypointUsage[ team ][ child + "" ] ) )
|
||||
temppen = level.waypointUsage[ team ][ child + "" ]; //consider how many bots are taking this path
|
||||
temppen = level.waypointUsage[ team ][ child + "" ]; // consider how many bots are taking this path
|
||||
|
||||
if ( temppen > 1 )
|
||||
penalty = temppen;
|
||||
@ -2076,10 +2076,10 @@ AStarSearch( start, goal, team, greedy_path )
|
||||
if ( childWp.type == "climb" || childWp.type == "prone" )
|
||||
penalty += 4;
|
||||
|
||||
//calc the total path we have took
|
||||
newg = bestNode.g + DistanceSquared( wp.origin, childWp.origin ) * penalty; //bots on same team's path are more expensive
|
||||
// calc the total path we have took
|
||||
newg = bestNode.g + DistanceSquared( wp.origin, childWp.origin ) * penalty; // bots on same team's path are more expensive
|
||||
|
||||
//check if this child is in open or close with a g value less than newg
|
||||
// check if this child is in open or close with a g value less than newg
|
||||
inopen = isDefined( openset[ child + "" ] );
|
||||
|
||||
if ( inopen && openset[ child + "" ].g <= newg )
|
||||
@ -2105,11 +2105,11 @@ AStarSearch( start, goal, team, greedy_path )
|
||||
node.f = node.g + node.h;
|
||||
node.index = child;
|
||||
|
||||
//check if in closed, remove it
|
||||
// check if in closed, remove it
|
||||
if ( inclosed )
|
||||
closed[ child + "" ] = undefined;
|
||||
|
||||
//check if not in open, add it
|
||||
// check if not in open, add it
|
||||
if ( !inopen )
|
||||
{
|
||||
open HeapInsert( node );
|
||||
@ -2117,7 +2117,7 @@ AStarSearch( start, goal, team, greedy_path )
|
||||
}
|
||||
}
|
||||
|
||||
//done with children, push onto closed
|
||||
// done with children, push onto closed
|
||||
closed[ bestNode.index + "" ] = bestNode;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user