Skip to content

Commit

Permalink
Add metal drill recipes
Browse files Browse the repository at this point in the history
- add drill test challenge!
- add recipes with metal drill
- make iron veins slightly more likely
  • Loading branch information
xsebek committed Jun 10, 2022
1 parent 95752fc commit 99ce4d2
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 6 deletions.
50 changes: 49 additions & 1 deletion data/recipes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,22 @@
- in:
- [1, mountain]
out:
- [9, rock]
- [8, rock]
- [1, mountain tunnel]
required:
- [1, drill]
time: 90

- in:
- [1, mountain]
out:
- [16, rock]
- [1, mountain tunnel]
required:
- [1, metal drill]
time: 9


- in:
- [5, rock]
out:
Expand All @@ -107,6 +117,7 @@
- [1, copper vein]
out:
- [1, copper mine]
- [1, copper ore]
required:
- [1, drill]
time: 42
Expand All @@ -115,10 +126,29 @@
- [1, iron vein]
out:
- [1, iron mine]
- [1, iron ore]
required:
- [1, drill]
time: 64

- in:
- [1, copper vein]
out:
- [1, copper mine]
- [1, copper ore]
required:
- [1, metal drill]
time: 6

- in:
- [1, iron vein]
out:
- [1, iron mine]
- [1, iron ore]
required:
- [1, metal drill]
time: 7

## MINES

- in:
Expand All @@ -139,6 +169,24 @@
- [1, drill]
time: 64

- in:
- [1, copper mine]
out:
- [1, copper ore]
- [1, copper mine]
required:
- [1, metal drill]
time: 6

- in:
- [1, iron mine]
out:
- [1, iron ore]
- [1, iron mine]
required:
- [1, metal drill]
time: 7

## SMELTING

- in:
Expand Down
3 changes: 3 additions & 0 deletions data/scenarios/01-creative.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ robots:
- name: base
loc: [0,0]
dir: [0,0]
display:
char: Ω
attr: robot
world:
seed: null
offset: true
76 changes: 76 additions & 0 deletions data/scenarios/03Challenges/02-drill_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Test drill
description: This is a developer playground and will be replaced with more suitable challenges soon.
entities:
- name: goal
display:
attr: device
char: 'X'
description:
- Send robots to mine rock, iron and copper.
properties: [portable]
- name: knownwater
display:
attr: water
char: ' '
description:
- An infinite ocean of water.
properties: [known, portable, growable, liquid]
growth: [0,0]
yields: water
- name: knownwater'
display:
attr: water
char: '~'
description:
- An infinite ocean of water.
properties: [known, portable, growable, liquid]
growth: [0,0]
yields: water
win: |
try {
i <- as base {has "iron ore"};
c <- as base {has "copper ore"};
s <- as base {has "rock"};
return (i && c && s)
} { return false }
robots:
- name: base
loc: [0,-2]
dir: [1,0]
display:
char: Ω
attr: robot
devices:
- logger
- grabber
- plasma cutter
- 3D printer
inventory:
- [1, goal]
- [2, metal drill]
- [1, drill]
- [2, logger]
world:
default: [ice, knownwater]
palette:
'.': [grass, null]
' ': [ice, knownwater]
'L': [grass, Linux]
'T': [grass, tree]
'~': [ice, knownwater']
'': [stone, upper left corner]
'': [stone, upper right corner]
'': [stone, lower left corner]
'': [stone, lower right corner]
'': [stone, horizontal wall]
'': [stone, vertical wall]
'A': [stone, mountain]
'C': [stone, copper vein]
'I': [stone, iron vein]
upperleft: [-1, 1]
map: |
┌──── ~~
│IAAT~ ~L~
│..AAA│ ~~
│....C│ ~
└─────┘ ~
4 changes: 2 additions & 2 deletions src/Swarm/Game/Scenario.hs
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ mkWorldFun pwd = E $ \em -> do
wd <- pwd
let toEntity :: Char -> Parser (Int, Maybe Entity)
toEntity c = case KeyMap.lookup (Key.fromString [c]) (unPalette (palette wd)) of
Nothing -> fail $ "Char not in entity palette: " ++ [c]
Nothing -> fail $ "Char not in entity palette: " ++ show c
Just (t, mt) -> case mt of
Nothing -> return (fromEnum t, Nothing)
Just name -> case lookupEntityName name em of
Nothing -> fail $ "Unknown entity name: " ++ from @Text name
Nothing -> fail $ "Unknown entity name: " ++ show name
Just e -> return (fromEnum t, Just e)

grid = map (into @String) . T.lines $ area wd
Expand Down
9 changes: 7 additions & 2 deletions src/Swarm/Game/Step.hs
Original file line number Diff line number Diff line change
Expand Up @@ -898,8 +898,12 @@ execConst c vs s k = do
rDir <- use robotOrientation

let nextLoc = loc ^+^ applyTurn d (rDir ? V2 0 0)
em <- use entityMap
drill <- lookupEntityName "drill" em `isJustOr` Fatal "Drill does not exist?!"

let toyDrill = lookupByName "drill" ins
metalDrill = lookupByName "metal drill" ins
insDrill = listToMaybe $ metalDrill <> toyDrill

drill <- insDrill `isJustOr` Fatal "Drill is required but not installed?!"
nextME <- entityAt nextLoc
nextE <-
nextME
Expand Down Expand Up @@ -1400,6 +1404,7 @@ execConst c vs s k = do
[ "Bad application of execConst:"
, from (prettyCESK (Out (VCApp c (reverse vs)) s k))
]

finishCookingRecipe ::
(Has (State GameState) sig m, Has (Throw Exn) sig m) =>
Recipe e ->
Expand Down
2 changes: 1 addition & 1 deletion src/Swarm/Game/WorldGen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ testWorld2 baseSeed (Coords ix@(r, c)) =

genBiome Big Hard Natural
| sample ix cl0 > 0.5 && sample ix rg0 > 0.999 = (StoneT, Just "copper vein")
| sample ix cl0 > 0.5 && sample ix rg1 > 0.999 = (StoneT, Just "iron vein")
| sample ix cl0 > 0.5 && sample ix rg1 > 0.99 = (StoneT, Just "iron vein")
| sample ix cl0 > 0.5 = (StoneT, Just "mountain")
| h `mod` 30 == 0 = (StoneT, Just "boulder")
| sample ix cl0 > 0 = (DirtT, Just "tree")
Expand Down

0 comments on commit 99ce4d2

Please sign in to comment.