//--------------------------------------------------------------------------- #include #include "Toadscape.h" #include "Animal.h" #include "MoveInd.h" #pragma hdrstop //--------------------------------------------------------------------------- #pragma argsused StochasticLib1 sto1a(SEED); // set up global landscape pointer Toadscape* pLandscape; int main(int argc, char* argv[]) { int i,j,t0,t1,parameterset,Npaths,goaltype,cellsize,move; locn start,source,goal,origin,XYmax; int landID,maxcost,prevnodatacost; int nodatacost; // cost to use in place of 'nodata' value int maxsteps; // max. no. of steps used (unless NOLIMIT is applied) pLandscape = 0; parameterset = 0; char txt[20]; char id[20],cost[20],target[20]; char prevcost[20],prevtarget[20]; int startpatch,Xstart,Ystart,Xgoal,Ygoal; char costgrid[20],tgtgrid[20]; bool new_landscape; bool files_ok = 1; bool start_ok = 0; t0 = time(0); // open input control file ifstream inctrl ("control.txt"); if (!inctrl.is_open()) { cout<>txt; } // open log file ofstream outlog ("log.csv"); if (!outlog.is_open()) { cout<>id; new_landscape = 1; while (files_ok && id[0]) { inctrl>>cost>>target>>nodatacost>>maxsteps>>Npaths >>Xstart>>Ystart>>startpatch>>goaltype>>Xgoal>>Ygoal; cout< 2) { cout<get_id(); maxcost = pLandscape->ReadLandscape(costgrid,tgtgrid,"null"); new_landscape = 0; parameterset = 0; } if (maxcost < 1) { cout<get_cellsize(); if (maxcost > 0) { origin = pLandscape->get_origin(); XYmax = pLandscape->get_XYmax(); if (start.x < origin.x || start.y < origin.y || start.x > XYmax.x || start.y > XYmax.y) { cout< 0 && start_ok && nodatacost > 0 && maxsteps > 0) { // run SMS for the current landscape int method,pr,ms,prevpr,prevmethod; double dp,gb; // open parameter control file ifstream inparms ("parameters.txt"); if (!inparms.is_open()) { cout<>txt; // cout<<"i = "<ResetEffCosts(); } // reset all visits counters to zero pLandscape->ResetVisits(0); for (i = 0; i < Npaths; i++) { // release N individuals Animal* pAnimal = new Animal(source.x,source.y,0,0.5); pAnimal->set_movement(pr,method,dp,gb,ms,nodatacost); pAnimal->set_goal(goaltype,goal.x,goal.y); // reset visits counters in the current landscape pLandscape->ResetVisits(1); move = moveInd(pAnimal,pLandscape,source,startpatch,parameterset,id,maxsteps); delete pAnimal; if (move == 999) { cout<get_cellsize() <<","<WriteLandFile(4,parameterset); #endif // retain current pr and method prevpr = pr; prevmethod = method; // read next data record method = 0; // to ensure valid method is read if (files_ok) inparms>>method; parameterset++; // cout<<"method = "< 0"< 0"<>id; } cout<>i; return 0; } //---------------------------------------------------------------------------