Advertisement
Guest User

Untitled

a guest
Jan 7th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. class ICell
  2. {
  3. public:
  4. int x;
  5. int y;
  6. ICell* previous;
  7. bool visited;
  8. bool up;
  9. bool left;
  10. };
  11.  
  12.  
  13. class IResult
  14. {
  15. public:
  16. std::vector<ICell> path;
  17. sf::Image* img;
  18. int time;
  19. int steps;
  20. };
  21.  
  22. IResult BFSsolve(sf::Image& img, int xstart, int ystart, int xend, int yend)
  23. {
  24. int width = img.GetWidth();
  25. int height = img.GetHeight();
  26. sf::Clock clock;
  27. std::queue<ICell> cellq;
  28. ICell cells[width/2][height/2];
  29. std::cout << width << "\n";
  30. for(int i = 0; i < width / 2; i++)
  31. {
  32. for(int k = 0; k < height / 2; k++)
  33. {
  34. //std::cout << k << "\n";
  35. cells[i][k].x = i;
  36. cells[i][k].y = k;
  37. cells[i][k].visited = false;
  38. }
  39. }
  40. std::cout << width << "\n";
  41. for(int g = 0; g <= width; g++)
  42. {
  43. for(int h = 0; h <= height; h++)
  44. {
  45. int rx = g;
  46. int ry = h;
  47. if((h == 0) || (img.GetPixel(g, h - 1) == sf::Color::Black))
  48. {
  49. cells[g/2][h/2].up = true;
  50. }
  51. if((g == 0) || (img.GetPixel(g - 1, h) == sf::Color::Black))
  52. {
  53. cells[g/2][h/2].left = true;
  54. }
  55. }
  56. }
  57. cells[xstart][ystart].visited = true;
  58. std::cout << xstart << " " << ystart << "\n";
  59. std::cout << cells[xstart][ystart].x << " " << cells[xstart][ystart].y << "\n";
  60. cellq.push(cells[xstart][ystart]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement