Watch for lodestone (#2146)
Some checks are pending
Haskell-CI-Windows / Haskell-CI - ${{ matrix.os }} - ghc-${{ matrix.ghc }} (3.10.1.0, 9.8.2, windows-latest) (push) Waiting to run
Haskell-CI / Haskell-CI - Linux - ${{ matrix.compiler }} (false, ghc-9.2.8, ghc, 9.2.8, ghcup) (push) Waiting to run
Haskell-CI / Haskell-CI - Linux - ${{ matrix.compiler }} (false, ghc-9.4.8, ghc, 9.4.8, ghcup) (push) Waiting to run
Haskell-CI / Haskell-CI - Linux - ${{ matrix.compiler }} (false, ghc-9.6.5, ghc, 9.6.5, ghcup) (push) Waiting to run
Haskell-CI / Haskell-CI - Linux - ${{ matrix.compiler }} (false, ghc-9.8.2, ghc, 9.8.2, ghcup) (push) Waiting to run
JSON schema / Validate scenarios against schema (push) Waiting to run
YAML normalization / Ensure YAML files are normalized (push) Waiting to run

* use `watch` to avoid busy-waiting for the bit seed to grow

Prompted by #2140, which shows hundreds of `ishere` calls.

| Before | After |
|--------|--------|
| <img width="143" alt="Screenshot 2024-09-15 at 10 02 51 PM" src="https://github.com/user-attachments/assets/174827e4-9371-4405-a6c2-dd20233e4588"> | <img width="143" alt="Screenshot 2024-09-15 at 10 01 32 PM" src="https://github.com/user-attachments/assets/a1d02d16-487c-46d0-b5f1-5aaf4da111cb"> |

This should make the testing scenario take 0.1s from previous 0.5s. You can test it with:
```sh
cabal run swarm-integration -O0 -- -p '/Testing\/562-lodestone/
```
This commit is contained in:
Ondřej Šebek 2024-09-15 23:07:04 +02:00 committed by GitHub
parent 746be8f4f6
commit c37334f4ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -5,8 +5,10 @@ def ifC = \p.\t.\e.
if b t e
end;
def until = \p.\t.
ifC p t {until p t}
def waitFor = \e.\t.
watch down;
wait 100;
ifC (ishere e) t {waitFor e t}
end;
def repeat = \c.
@ -29,18 +31,18 @@ end;
// get one lodestone
build {log "Hey!"; turn north; m2; l <- grab; turn back; m2; place l};
until (ishere "lodestone") {grab};
waitFor "lodestone" {grab};
// get two bit (0)
build {
log "Hi!";
repeat (
log "I am going for a bit";
turn east; m2; x <- until (ishere "bit (0)") {harvest}; turn back; m2; place x;
turn east; m2; x <- waitFor "bit (0)" {harvest}; turn back; m2; place x;
log "I brought a bit";
)};
until (ishere "bit (0)") {grab};
until (ishere "bit (0)") {grab};
waitFor "bit (0)" {grab};
waitFor "bit (0)" {grab};
make "bit (1)";
make "drill bit"

View File

@ -25,6 +25,7 @@ robots:
- workbench
- 3D printer
- branch predictor
- rolex
inventory:
- [10, drill]
- [10, lambda]
@ -37,6 +38,7 @@ robots:
- [10, strange loop]
- [10, branch predictor]
- [10, toolkit]
- [10, rolex]
- [0, drill bit]
- [0, bit (0)]
- [0, bit (1)]