Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mapa M(60,vector < bool> (60,false));
- queue<Posicio> Q;
- Info in = dades(id);
- Q.push(in.pos);
- int post_cerc = 0;
- bool continua = false;
- Posicio poste;
- poste = in.pos;
- while (not Q.empty() and not continua){
- Posicio p = Q.front();
- Q.pop();
- if(not M[p.x][p.y]) {
- M[p.x][p.y] = true;
- int cont = 0;
- while (cont < 8 and not continua){
- Posicio seg;
- seg.x = p.x + X[cont];
- seg.y = p.y + Y[cont];
- if (que(seg.x,seg.y) == 1 or que(seg.x,seg.y) == 2 /*or temps_foc(seg.x,seg.y) == 0*/) {
- Q.push(seg);
- }
- if (valor_post(seg.x,seg.y) > 0) {
- if(de_qui_post(seg.x,seg.y) != equip) {
- post_cerc = cont;
- continua = true;
- poste.x = seg.x;
- poste.y = seg.y;
- }
- }
- ++cont;
- }
- }
- }
- int cont1 = 0;
- int trobat = false;
- int cercano = 0;
- while (cont1 < 8 and not trobat){
- Posicio fin;
- fin.x = in.pos.x + X[post_cerc] + X[cont1];
- fin.y = in.pos.y + Y[post_cerc] + Y[cont1];
- if ((fin.x < 60 and fin.x >= 0) and (fin.y < 60 and fin.y >= 0)){
- if (valor_post(fin.x,fin.y) > 0) {
- if(de_qui_post(fin.x,fin.y) != equip) {
- if(poste.x == fin.x and poste.y == fin.y) {
- cercano = cont1;
- trobat = true;
- }
- }
- }
- }
- ++cont1;
- }
- if(cercano < post_cerc) {
- Posicio ves;
- ves.x = in.pos.x+ X[post_cerc] + X[cont1];
- ves.y = in.pos.y+ Y[post_cerc] + Y[cont1];
- Q.push(ves);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement