#include "type.h" window W(WWIDTH,WHEIGHT); evader E; ps_file PS(15.0, 15.0, "00.ps"); list O; ofstream logfile; long max_mem; long total_nodes; long tree_length; drrt D(20,20); void read_data(char *, char *); int main(){ double i=0; double x, y, x1, y1, len; double eoldx,eoldy, epoldx, epoldy; obstacle obs; polygon poly; max_mem = DRRT_SIZE; total_nodes = 0; tree_length = 0; clock_t begintime, endtime; static char a[7] = { '0', '0', '0'}; char name[7]; begintime = clock(); logfile.open("logfile.txt"); read_data("poly","funct"); W.display(); forall(obs, O){ poly = obs.body(i); W.draw_filled_polygon(poly); } D.initialize(); W.read_mouse(x,y); E.setx(x); E.sety(y); E.initialize(); eoldx = x; eoldy = y; epoldx = x; epoldy = y; while(!D.move()){ if (W.get_mouse(x1,y1)){ x = x1 - eoldx; y = y1 - eoldy; len = x*x+y*y; len = sqrt(len); x /= len; y /= len; x *= STEP; y *= STEP; x += eoldx; y += eoldy; E.setx(x); E.sety(y); } i++; // Prepare file name. if ( int(a[2]) == int('9') + 1 ) { a[2] = '0'; a[1] = char( int(a[1]) + 1 ); if ( int(a[1]) == int('9') + 1 ) { a[1] = '0'; a[0] = char( int(a[0]) + 1 ); if ( a[0] == char(int('4') + 1) ) exit (0); } } strcpy (name, ""); strcpy (name, a ); strcat (name, ".ps"); a[2] = char( int(a[2]) + 1 ); // increment file name. PS.newfile(15.0, 15.0, name ); W.clear(); cout << "Size of O for window is :"<< O.size() << endl; // Draw obstacles to window and postscript file. forall(obs, O) { poly = obs.body(i); W.draw_filled_polygon(poly); if (! (poly.vertices()).empty() ) PS.draw_filled_polygon( poly.vertices() ); } // Draw Evader W.draw_disc(E.getx(),E.gety(),2,color(0,255,0)); PS.draw_disc(E.getx(),E.gety(),2,color(0,255,0)); // Draw line of Evader's position from old to new location. W.draw_segment(E.getx(),E.gety(),eoldx,eoldy,color(0,255,0)); PS.draw_segment(E.getx(),E.gety(),eoldx,eoldy,color(0,255,0)); // Draw the predicted location of the Evader. W.draw_segment(E.predictedx,E.predictedy,epoldx,epoldy,color(0,0,255)); PS.draw_segment(E.predictedx,E.predictedy,epoldx,epoldy,color(0,0,255)); eoldx = E.getx(); eoldy = E.gety(); epoldx = E.predictedx; epoldy = E.predictedy; } endtime = clock(); endtime = (endtime - begintime)/CLOCKS_PER_SEC; cout << "yea!!" << endl; cout << "This run took a maximum of " << max_mem; cout << " nodes to find a solution!" << endl; cout << "The total number of nodes made was: " << total_nodes << endl; cout << "The length of the solution was " << tree_length << " nodes long!"<< endl; cout << "Total time to solution: " << endtime << " seconds!" <> body; functfile >> a; functfile >> b; functfile >> c; if(polyfile){ obs = new obstacle(body, a, b, c); O.push(*obs); } } polyfile.close(); functfile.close(); } /* void Draw_In_Window(double eoldx, double eoldy, double epoldx, double epoldy ) { static double i=0; obstacle obs; polygon poly; static char a[7] = { '0', '0' }; char name[7]; // Prepare file name. if ( int(a[1]) == int('9') + 1 ) { a[1] = '0'; a[0] = char( int(a[0]) + 1 ); if ( a[0] == char(int('9') + 1) ) exit (0); } strcpy (name, ""); strcpy (name, a ); strcat (name, ".ps"); ps_file ps(15.0, 15.0, name ); W.clear(); i++; // Draw obstacles. forall(obs, O) { poly = obs.body(i); W.draw_filled_polygon(poly); poly = obs.poly; ps.draw_filled_polygon( poly.vertices() ); } // Draw Evader W.draw_disc(E.getx(),E.gety(),2,color(0,255,0)); ps.draw_disc(E.getx(),E.gety(),2,color(0,255,0)); // Draw line of Evader's position from old to new location. W.draw_segment(E.getx(),E.gety(),eoldx,eoldy,color(0,255,0)); ps.draw_segment(E.getx(),E.gety(),eoldx,eoldy,color(0,255,0)); // Draw the predicted location of the Evader. W.draw_segment(E.predictedx,E.predictedy,epoldx,epoldy,color(0,0,255)); ps.draw_segment(E.predictedx,E.predictedy,epoldx,epoldy,color(0,0,255)); a[1] = char( int(a[1]) + 1 ); ps.close(); } */