Skip to content

Commit

Permalink
new command that uses A*
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Sep 17, 2023
1 parent 4366026 commit 7483350
Show file tree
Hide file tree
Showing 30 changed files with 772 additions and 38 deletions.
1 change: 1 addition & 0 deletions data/scenarios/Testing/00-ORDER.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Achievements
1320-world-DSL
1356-portals
144-subworlds
836-pathfinding
1341-command-count.yaml
1355-combustion.yaml
1379-single-world-portal-reorientation.yaml
Expand Down
7 changes: 7 additions & 0 deletions data/scenarios/Testing/836-pathfinding/00-ORDER.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
836-path-exists-find-location.yaml
836-path-exists-find-entity.yaml
836-path-exists-distance-limit-unreachable.yaml
836-path-exists-distance-limit-reachable.yaml
836-no-path-exists1.yaml
836-no-path-exists2.yaml
836-automatic-waypoint-navigation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
version: 1
name: Automatic navigation between waypoints
description: |
Demonstrate shortest-path patrolling between waypoints
creative: false
solution: |
run "scenarios/Testing/836-pathfinding/_836-automatic-waypoint-navigation/patrol.sw"
objectives:
- goal:
- Collect 64 eggs
condition: |
as base {
eggCount <- count "egg";
return $ eggCount >= 64;
};
attrs:
- name: easter_egg
fg: "#ffff88"
bg: "#eebbff"
entities:
- name: wayfinder
display:
char: 'w'
description:
- Enables `path` command
properties: [known, portable]
capabilities: [path]
- name: atlas
display:
char: 'a'
description:
- Enables `waypoint` command
properties: [known, portable]
capabilities: [waypoint]
- name: kudzu
display:
char: 'k'
attr: plant
description:
- Dense, impassable plant.
properties: [known, unwalkable, growable]
growth: [30, 50]
- name: egg
display:
char: 'o'
attr: easter_egg
description:
- Just the flower top of the plant
properties: [known, portable]
growth: [5, 10]
robots:
- name: base
loc: [0, 0]
dir: [1, 0]
devices:
- ADT calculator
- atlas
- branch predictor
- comparator
- compass
- dictionary
- grabber
- logger
- net
- scanner
- treads
- wayfinder
- name: gardener
dir: [1, 0]
system: true
devices:
- ADT calculator
- branch predictor
- comparator
- compass
- dictionary
- harvester
- treads
- logger
display:
invisible: true
program: |
run "scenarios/Testing/836-pathfinding/_836-automatic-waypoint-navigation/gardener.sw"
- name: rabbit
dir: [1, 0]
loc: [2, -2]
system: true
devices:
- treads
- logger
inventory:
- [64, egg]
display:
invisible: false
attr: snow
char: R
program: |
run "scenarios/Testing/836-pathfinding/_836-automatic-waypoint-navigation/rabbit.sw"
known: [flower, boulder, kudzu]
world:
upperleft: [-1, 1]
palette:
'.': [grass]
'k': [stone, kudzu, gardener]
'': [stone, upper left corner]
'': [stone, upper right corner]
'': [stone, lower left corner]
'': [stone, lower right corner]
'': [stone, horizontal wall]
'': [stone, vertical wall]
structures:
- name: bigbox
structure:
palette:
'.': [dirt]
'@': [dirt, boulder]
'w':
cell: [dirt]
waypoint:
name: wp
map: |
@@@
@w.
@.@
placements:
- src: bigbox
offset: [2, -2]
orient:
up: north
- src: bigbox
offset: [8, -2]
orient:
up: east
- src: bigbox
offset: [8, -6]
orient:
up: south
- src: bigbox
offset: [2, -6]
orient:
up: west
map: |
┌───────────┐
│...........│
│...........│
│.....k.....│
│...........│
│...........│
│...........│
│.....k.....│
│...........│
│...........│
└───────────┘
48 changes: 48 additions & 0 deletions data/scenarios/Testing/836-pathfinding/836-no-path-exists1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: 1
name: Builtin pathfinding, unreachable goal, enclosed robot
description: |
There is finite area to explore, so
this will terminate quickly.
creative: false
objectives:
- goal:
- Flower must not be reachable.
condition: |
as base {
nextDir <- path (inL ()) (inR "flower");
return $ case nextDir (\_. true) (\_. false);
};
solution: |
noop;
entities:
- name: wayfinder
display:
char: 'w'
description:
- Enables `path` command
properties: [known, portable]
capabilities: [path]
robots:
- name: base
dir: [1,0]
devices:
- treads
- logger
- ADT calculator
- dictionary
- wayfinder
known: [mountain, flower, tree]
world:
palette:
'B': [grass, null, base]
'.': [grass]
'x': [stone, mountain]
'f': [grass, flower]
'T': [grass, tree]
upperleft: [0, 0]
map: |
xxxxx......
x...x......
x.B.x...f..
x...x......
xxxxx......
52 changes: 52 additions & 0 deletions data/scenarios/Testing/836-pathfinding/836-no-path-exists2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: 1
name: Builtin pathfinding, unreachable goal, enclosed goal
description: |
There is infinite area to explore, so
this will fail to terminate unless
a limit is set on the max distance.
In this scenario, we fall back onto the internal distance limit.
Normally, it would be very expensive to allow this goal condition
check to run upon every tick. But in this case, we should
have won the scenario by the first tick.
creative: false
objectives:
- goal:
- Flower must not be reachable.
condition: |
as base {
nextDir <- path (inL ()) (inR "flower");
return $ case nextDir (\_. true) (\_. false);
};
solution: |
noop;
entities:
- name: wayfinder
display:
char: 'w'
description:
- Enables `path` command
properties: [known, portable]
capabilities: [path]
robots:
- name: base
dir: [1,0]
devices:
- treads
- logger
- ADT calculator
- dictionary
- wayfinder
world:
palette:
'B': [grass, null, base]
'.': [grass]
'x': [stone, mountain]
'f': [grass, flower]
upperleft: [0, 0]
map: |
......xxxxx
......x...x
..B...x.f.x
......x...x
......xxxxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 1
name: Builtin pathfinding - entity target
description: |
Use distance limit with `path` command
creative: false
objectives:
- goal:
- Flower must be reachable within 3 cells.
condition: |
as base {
nextDir <- path (inR 3) (inR "flower");
return $ case nextDir (\_. false) (\_. true);
};
solution: |
move;
robots:
- name: base
dir: [1,0]
devices:
- treads
- logger
- 3D printer
- dictionary
- grabber
world:
palette:
'B': [grass, null, base]
'.': [grass]
'f': [grass, flower]
upperleft: [0, 0]
map: |
.......
.B...f.
.......
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: 1
name: Builtin pathfinding - entity target
description: |
Use distance limit with `path` command
creative: false
objectives:
- goal:
- Flower must NOT be reachable within 3 cells.
condition: |
as base {
nextDir <- path (inR 3) (inR "flower");
return $ case nextDir (\_. true) (\_. false);
};
solution: |
turn back;
move;
robots:
- name: base
dir: [1,0]
devices:
- treads
- logger
- 3D printer
- dictionary
- grabber
world:
palette:
'B': [grass, null, base]
'.': [grass]
'f': [grass, flower]
upperleft: [0, 0]
map: |
.......
..B..f.
.......
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: 1
name: Builtin pathfinding - entity target
description: |
Use `path` command to navigate to an entity
creative: false
objectives:
- goal:
- Get the flower.
condition: |
as base {has "flower";}
solution: |
run "scenarios/Testing/836-pathfinding/_836-path-exists/find-entity-solution.sw";
entities:
- name: wayfinder
display:
char: 'w'
description:
- Enables `path` command
properties: [known, portable]
capabilities: [path]
robots:
- name: base
dir: [1,0]
devices:
- ADT calculator
- branch predictor
- comparator
- compass
- dictionary
- logger
- grabber
- treads
- wayfinder
known: [flower, mountain]
world:
palette:
'B': [grass, null, base]
'.': [grass]
'x': [stone, mountain]
'f': [grass, flower]
upperleft: [0, 0]
map: |
xxxxfx
x.Bx.x
x.xx.x
x....x
xxxxxx
Loading

0 comments on commit 7483350

Please sign in to comment.