quick overview of the code part: ‘State’ represents the state of the agent/car at time T and Type indicates the type of road the cell is. I check with Type and Type’ whether the roads are connected, i.e., whether there is a path from one cell to the next.
Is there a shorter and more compact way to write this? As I mentioned it’s very time-consuming with many different types of streets a cell can be. Thanks for your help!
action(agent(B),move_forward,T) :-
state(agent(A),(X,Y),Type,dir(D),T-1),
cell((X,Y-1),Type'),
not action(agent(A),move_left,T),not action(agent(A),move_right,T),
Type=1, Type'=5, D=s, T <= k.
action(agent(B),move_forward,T) :-
state(agent(A),(X,Y),Type,dir(D),T-1),
cell((X,Y-1),Type'),
not action(agent(A),move_left,T),not action(agent(A),move_right,T),
Type=1, Type'=3, D=s, T <= k.
action(agent(B),move_forward,T) :-
state(agent(A),(X,Y),Type,dir(D),T-1),
cell((X,Y-1),Type'),
not action(agent(A),move_left,T),not action(agent(A),move_right,T),
Type=1, Type'=7, D=s, T <= k.
action(agent(B),move_forward,T) :-
state(agent(A),(X,Y),Type,dir(D),T-1),
cell((X,Y+1),Type'),
not action(agent(A),move_left,T),not action(agent(A),move_right,T),
Type=1, Type'=1, D=n, T <= k.
action(agent(B),move_forward,T) :-
state(agent(A),(X,Y),Type,dir(D),T-1),
cell((X,Y+1),Type'),
not action(agent(A),move_left,T),not action(agent(A),move_right,T),
Type=1, Type'=13, D=n, T <= k.
action(agent(B),move_forward,T) :-
state(agent(A),(X,Y),Type,dir(D),T-1),
cell((X,Y+1),Type'),
not action(agent(A),move_left,T),not action(agent(A),move_right,T),
Type=1, Type'=21, D=n, T <= k.
The current code works but is very time-consuming, as there is a lot of copy and paste involved with only the direction (dir(D)) or the type of the cell changing.