diggingInvaders: tweaks.

develop
expwnent 2013-06-11 07:17:41 -04:00
parent f557376c3a
commit 776d088eb9
1 changed files with 15 additions and 8 deletions

@ -340,7 +340,7 @@ void findAndAssignInvasionJob(color_ostream& out, void* tickTime) {
if ( invaderPts.find(unit->pos) != invaderPts.end() ) if ( invaderPts.find(unit->pos) != invaderPts.end() )
continue; continue;
//must be able to wield a pick: this is overly pessimistic //must be able to wield a pick: this is overly pessimistic
if ( unit->status2.limbs_grasp_count < unit->status2.limbs_grasp_max ) if ( unit->status2.limbs_grasp_max <= 0 || unit->status2.limbs_grasp_count < unit->status2.limbs_grasp_max )
continue; continue;
df::map_block* block = Maps::getTileBlock(unit->pos); df::map_block* block = Maps::getTileBlock(unit->pos);
invaderConnectivity.insert(block->walkable[unit->pos.x&0xF][unit->pos.y&0xF]); invaderConnectivity.insert(block->walkable[unit->pos.x&0xF][unit->pos.y&0xF]);
@ -460,23 +460,28 @@ void findAndAssignInvasionJob(color_ostream& out, void* tickTime) {
//find important edges //find important edges
Edge firstImportantEdge(df::coord(), df::coord(), -1); Edge firstImportantEdge(df::coord(), df::coord(), -1);
df::coord closest; //df::coord closest;
cost_t closestCostEstimate=0; //cost_t closestCostEstimate=0;
cost_t closestCostActual=0; //cost_t closestCostActual=0;
for ( auto i = localPts.begin(); i != localPts.end(); i++ ) { for ( auto i = localPts.begin(); i != localPts.end(); i++ ) {
df::coord pt = *i; df::coord pt = *i;
if ( costMap.find(pt) == costMap.end() ) if ( costMap.find(pt) == costMap.end() )
continue; continue;
if ( parentMap.find(pt) == parentMap.end() ) if ( parentMap.find(pt) == parentMap.end() )
continue; continue;
closest = pt; //closest = pt;
closestCostEstimate = costMap[closest]; //closestCostEstimate = costMap[closest];
//if ( workNeeded[pt] == 0 ) //if ( workNeeded[pt] == 0 )
// continue; // continue;
while ( parentMap.find(pt) != parentMap.end() ) { while ( parentMap.find(pt) != parentMap.end() ) {
//out.print("(%d,%d,%d)\n", pt.x, pt.y, pt.z); //out.print("(%d,%d,%d)\n", pt.x, pt.y, pt.z);
df::coord parent = parentMap[pt]; df::coord parent = parentMap[pt];
closestCostActual += getEdgeCost(out, parent, pt); cost_t cost = getEdgeCost(out, parent, pt);
if ( cost < 0 ) {
//path invalidated
return;
}
//closestCostActual += cost;
if ( Maps::canStepBetween(parent, pt) ) { if ( Maps::canStepBetween(parent, pt) ) {
} else { } else {
@ -502,10 +507,12 @@ void findAndAssignInvasionJob(color_ostream& out, void* tickTime) {
if ( firstImportantEdge.p1 == df::coord() ) if ( firstImportantEdge.p1 == df::coord() )
return; return;
/*
if ( closestCostActual != closestCostEstimate ) { if ( closestCostActual != closestCostEstimate ) {
out.print("%s,%d: closest = (%d,%d,%d), estimate = %lld != actual = %lld\n", __FILE__, __LINE__, closest.x,closest.y,closest.z, closestCostEstimate, closestCostActual); out.print("%s,%d: closest = (%d,%d,%d), estimate = %lld != actual = %lld\n", __FILE__, __LINE__, closest.x,closest.y,closest.z, closestCostEstimate, closestCostActual);
return; return;
} }
*/
assignJob(out, firstImportantEdge, parentMap, costMap, invaders, requiresZNeg, requiresZPos, cache); assignJob(out, firstImportantEdge, parentMap, costMap, invaders, requiresZNeg, requiresZPos, cache);
lastInvasionDigger = firstInvader->id; lastInvasionDigger = firstInvader->id;