Skip to content

Commit

Permalink
defend against attackers
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Jan 22, 2024
1 parent 9320a98 commit 56540af
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/scenarios/Challenges/00-ORDER.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ wave.yaml
wolf-goat-cabbage.yaml
blender.yaml
friend.yaml
horde.yaml
pack-tetrominoes.yaml
dimsum.yaml
Mazes
Expand Down
45 changes: 45 additions & 0 deletions data/scenarios/Challenges/_horde/baddie.sw
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
def goDir = \d.
let direction = fst d in
if (direction == down) {

// Found the base. We can stop.

} {
turn direction;

// An obstruction might arise after
// navigation direction is determined
// but before we move.
try {
move;
} {};
}
end;

def drillWhileBlocked = \baseLoc.

isBlocked <- blocked;
if isBlocked {
drill forward;
return ();
} {
myLoc <- whereami;
if (fst myLoc > fst baseLoc) {
move;
} {};
}
end;

def chaseBase =
baseLoc <- as base {whereami};

nextDir <- path (inL ()) (inL baseLoc);
case nextDir (\_. drillWhileBlocked baseLoc) goDir;
end;

def go =
chaseBase;
go;
end;

go;
50 changes: 50 additions & 0 deletions data/scenarios/Challenges/_horde/solution.sw
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

// modulus function (%)
def mod : int -> int -> int = \i.\m.
i - m * (i / m)
end

def placeObstacle =
emptyHere <- isempty;
if emptyHere {
place "wall"
} {
swap "wall";
return ();
}
end

def drillWhileBlocked = \xPos.
isBlocked <- blocked;
if isBlocked {
try {
push;
} {
drill forward;
move;
}
} {
move;
};


if (mod xPos 3 == 0) {
placeObstacle;
} {};

end;

def go =
myLoc <- whereami;

let xPos = fst myLoc in

if (xPos > -20) {
drillWhileBlocked xPos;
go;
} {}

end;

turn west;
go;
101 changes: 101 additions & 0 deletions data/scenarios/Challenges/horde.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
version: 1
name: Horde
author: Karl Ostmo
description: |
Keep the horde at bay
creative: false
objectives:
- goal:
- |
Win
condition: |
return false
robots:
- name: base
dir: east
devices:
- 3D printer
- branch predictor
- ADT calculator
- clock
- comparator
- compass
- counter
- dictionary
- dozer blade
- drill
- fast grabber
- GPS receiver
- harvester
- hearing aid
- keyboard
- lambda
- logger
- net
- rolex
- scanner
- strange loop
- toolkit
- treads
- welder
- workbench
inventory:
- [1000, wall]
- name: baddie
devices:
- drill
system: true
display:
invisible: false
dir: west
program: |
run "scenarios/Challenges/_horde/baddie.sw"
solution: |
run "scenarios/Challenges/_horde/solution.sw"
entities:
- name: wall
display:
char: 'w'
description:
- Wall
properties: [known, unwalkable, pushable]
- name: rubble
display:
char: 'r'
description:
- Rubble
properties: [known, pickable]
recipes:
- in:
- [1, wall]
out:
- [1, rubble]
required:
- [1, drill]
time: 8
known: [water]
world:
dsl: |
let
outerBoundary = x <= -5 || x >= 5 || y > 25
in
overlay
[ {grass}
, mask outerBoundary {water}
]
upperleft: [-1, 4]
palette:
'B': [dirt, null, base]
'b': [dirt, null, baddie]
'.': [dirt]
'w': [dirt, wall]
map: |
wwwww......wwwwww....
wwwww......wwwwww....
wwwww......wwwwww....
wwwww......wwwwww....
wwwww.B....wwwwww...b
wwwww......wwwwww....
wwwww......wwwwww....
wwwww......wwwwww....
wwwww......wwwwww....

0 comments on commit 56540af

Please sign in to comment.