jacamo-lang / mapc2020

Team for MAPC 2020
GNU General Public License v3.0
3 stars 1 forks source link

goto_Astar seems to be ignoring attached blocks #55

Open cleberjamaral opened 3 years ago

cleberjamaral commented 3 years ago

There are situations in which the agents are getting stuck apparently because the path algorithms is ignoring attached blocks. For instance, in the image below A4 got stuck near A1. After that A13 got stuck near A4. The objective of A13 is to connect with A1 and A4 wants to connect with A5. In this situation all these agents will wait forever for a resolution that never comes. Screenshot_2021-02-11_14-53-39

This problem is different than the issue #43, because here the algorithm returns a route but the routes seems to be wrong and the agent get stuck.

[agentA4] Fail on going to x: -22 y: -26 act: n
[agentA4] No success on: goto(-22,-26,error) myposition(-26,-22)
[agentA13] Fail on going to x: -24 y: -23 act: n
[agentA13] No success on: goto(-24,-23,error) myposition(-24,-21)
[ NORMAL  ]  ##   Simulation at step 188
[agentA13] Fail on going to x: -24 y: -23 act: n
[agentA13] No success on: goto(-24,-23,error) myposition(-24,-21)
[agentA4] Fail on going to x: -22 y: -26 act: n
[agentA4] No success on: goto(-22,-26,error) myposition(-26,-22)
[ NORMAL  ]  ##   Simulation at step 189
[agentA4] Fail on going to x: -22 y: -26 act: n
[agentA4] No success on: goto(-22,-26,error) myposition(-26,-22)
cleberjamaral commented 3 years ago

I am confused with this issue. These agents were using .get_direction/7 from goto_iaA_star.asl. This plan does a .findall in the gps_map sending all of them to the path algorithm.

    .findall(gps_map(XG,YG,OG,MyMAP),gps_map(XG,YG,OG,MyMAP),LG);
    .findall(attached(I,J),attached(I,J),LA);
    .get_direction(OX,OY,X,Y,LG,LA,DIRECTION);

The gps_map is formed by primitive beliefs and also by results from two rules, in which one of them is:

gps_map(XB,YB,block(B),MyMAP) :-
    origin(MyMAP) &
    thing(I,J,block,B) &
    not attached(I,J) &
    myposition(X,Y) &
    XB = X+I & YB = Y+J
.

Finally, the GridState.java class instantiate the states of the search algorithm considers an obstacle "block(" as below:

public boolean isWalkable(Location newl) {
    return (!map.contains(newl.x, newl.y)) || // Any not mapped position is walkable (unknown and free terrains) 
           ( // Check if the new position is mapped as a "not free" or obstacle terrains 
                   (!map.get(newl.x, newl.y).equals("obstacle")) && // obstacle are objects mapped by lps artifact
                   (!map.get(newl.x, newl.y).startsWith("block(")) && // block(B) comes from a rule in the iaA_star
                   (!map.get(newl.x, newl.y).startsWith("entity(")) // entity(E) comes from a rule in the iaA_star
           );
}

So, in theory, the algorithm should consider blocks attached to other agents or dropped on the ground as obstacles. To understand this issue we probably need to improve our debugging tools.

cleberjamaral commented 3 years ago

Duplicated #47