Advertisement
Guest User

mieldote

a guest
Nov 23rd, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. Mapa M(60,vector < bool> (60,false));
  2. queue<Posicio> Q;
  3. Info in = dades(id);
  4. Q.push(in.pos);
  5. int post_cerc = 0;
  6. bool continua = false;
  7. Posicio poste;
  8. poste = in.pos;
  9. while (not Q.empty() and not continua){
  10. Posicio p = Q.front();
  11. Q.pop();
  12. if(not M[p.x][p.y]) {
  13. M[p.x][p.y] = true;
  14. int cont = 0;
  15. while (cont < 8 and not continua){
  16. Posicio seg;
  17. seg.x = p.x + X[cont];
  18. seg.y = p.y + Y[cont];
  19. if (que(seg.x,seg.y) == 1 or que(seg.x,seg.y) == 2 /*or temps_foc(seg.x,seg.y) == 0*/) {
  20. Q.push(seg);
  21. }
  22. if (valor_post(seg.x,seg.y) > 0) {
  23. if(de_qui_post(seg.x,seg.y) != equip) {
  24. post_cerc = cont;
  25. continua = true;
  26. poste.x = seg.x;
  27. poste.y = seg.y;
  28. }
  29. }
  30. ++cont;
  31. }
  32. }
  33. }
  34.  
  35.  
  36. int cont1 = 0;
  37. int trobat = false;
  38. int cercano = 0;
  39. while (cont1 < 8 and not trobat){
  40. Posicio fin;
  41. fin.x = in.pos.x + X[post_cerc] + X[cont1];
  42. fin.y = in.pos.y + Y[post_cerc] + Y[cont1];
  43. if ((fin.x < 60 and fin.x >= 0) and (fin.y < 60 and fin.y >= 0)){
  44. if (valor_post(fin.x,fin.y) > 0) {
  45. if(de_qui_post(fin.x,fin.y) != equip) {
  46. if(poste.x == fin.x and poste.y == fin.y) {
  47. cercano = cont1;
  48. trobat = true;
  49. }
  50. }
  51. }
  52. }
  53. ++cont1;
  54. }
  55. if(cercano < post_cerc) {
  56. Posicio ves;
  57. ves.x = in.pos.x+ X[post_cerc] + X[cont1];
  58. ves.y = in.pos.y+ Y[post_cerc] + Y[cont1];
  59. Q.push(ves);
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement