-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new `GPS receiver` device which enables the `senseloc` capability (and hence the `whereami` command). Towards #26 . - My immediate motivation is that I want to be able to define `excursion : cmd unit -> cmd unit` which executes the given command and then returns to the same location and orientation as before. Being able to use the `whereami` command is one of the last missing pieces of machinery necessary to be able to do this in classic mode (the other is a `heading` command, see #955). - The proposed recipe for `GPS receiver` is `antenna + circuit + clock + compass`, which is a somewhat difficult recipe (`antenna` requires `silver` which requires a `deep mine`; a `clock` requires `quartz` + a bunch of `iron gears`, etc.). One might wonder whether we should make the recipe easier since finding out where you are seems like a kind of fundamental operation. However, consider that in order to even be able to make use of the result of `whereami` you need at least (1) an `ADT calculator` to deal with the pair (which transitively requires `typewriter` -> `circuit` -> `silicon` -> `quartz`) (2) probably things like `comparator` and `calculator` to do anything useful with the coordinates. By the time you have those things you can definitely already build `circuit` + `clock` + `compass`, and you're probably not that far away from getting some `silver` for an `antenna`. Also, in practice it's an interesting/fun constraint to build up machinery that has to work entirely based on *relative* position without being able to find out your absolute coordinates. - For some reason this is causing `Testing/508-capability-subset` to fail. I think perhaps it is due to #397 ? I will investigate. *EDIT*: unfortunately, that wasn't it!
- Loading branch information
Showing
6 changed files
with
98 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ | |
955-heading.yaml | ||
397-wrong-missing.yaml | ||
961-custom-capabilities.yaml | ||
956-GPS.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
version: 1 | ||
name: Test GPS receiver device | ||
description: | | ||
Test the `whereami` command and GPS receiver device. | ||
https://github.com/swarm-game/swarm/issues/956 | ||
objectives: | ||
- condition: | | ||
loc <- as base {whereami}; | ||
return $ loc == (0,0) | ||
goal: | ||
- | | ||
The goal is to move back to the origin after being | ||
unceremoniously teleported to a random location. The only way | ||
to do this is to use a GPS receiver device to learn the | ||
current location and use the result to decide how to move. | ||
solution: | | ||
def x = \n. \c. if (n == 0) {} {c ; x (n-1) c} end; | ||
def abs = \n. if (n<0) {-n} {n} end; | ||
wait 2; | ||
loc <- whereami; | ||
turn (if (fst loc < 0) {east} {west}); x (abs (fst loc)) move; | ||
turn (if (snd loc < 0) {north} {south}); x (abs (snd loc)) move; | ||
robots: | ||
- name: base | ||
dir: [0,1] | ||
loc: [-5,5] | ||
devices: | ||
- clock | ||
- dictionary | ||
- GPS receiver | ||
- treads | ||
- compass | ||
- ADT calculator | ||
- strange loop | ||
- comparator | ||
- calculator | ||
- branch predictor | ||
- logger | ||
- name: teleporter | ||
dir: [0,1] | ||
loc: [0,0] | ||
system: true | ||
display: | ||
invisible: true | ||
program: | | ||
x <- random 11; | ||
y <- random 11; | ||
teleport base (x-5, y-5) | ||
world: | ||
default: [blank] | ||
palette: | ||
'.': [grass] | ||
upperleft: [-5, 5] | ||
map: | | ||
........... | ||
........... | ||
........... | ||
........... | ||
........... | ||
........... | ||
........... | ||
........... | ||
........... | ||
........... | ||
........... | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters