-
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.
- Loading branch information
Showing
4 changed files
with
197 additions
and
0 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
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; |
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,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; |
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,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.... |