forked from sharkdp/cube-composer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChapter0.purs
73 lines (68 loc) · 3.15 KB
/
Chapter0.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
module Levels.Chapter0 where
import Prelude
import Data.List (List(..), (:), snoc)
import Data.Maybe (Maybe(..))
import Helper (fromArray, (:->), (:>))
import Transformer (mapReject, replaceMultiple, replaceSingle)
import Types (Chapter, Cube(..), Difficulty(..))
chapter0 :: Chapter
chapter0 = {
name: "Introduction",
transformers: fromArray [
"replaceYbyR" :> {
name: "map {Yellow}↦{Red}",
function: replaceSingle Yellow Red
},
"stackY" :> {
name: "map (stack {Yellow})",
function: map (_ `snoc` Yellow)
},
"replaceYbyYR" :> {
name: "map {Yellow}↦[{Red}{Yellow}]",
function: replaceMultiple Yellow (Yellow : Red : Nil)
},
"rejectY" :> {
name: "map (reject {Yellow})",
function: mapReject Yellow
}
],
levels: fromArray [
"0.1" :-> {
name: "Transformation",
help: Just """In this game, your goal is to create a sequence of functions which
transforms the colored cubes into the desired pattern (shown above).
To change yellow cubes to red cubes, add the function `replaceYbyR` to your program.
You can do so by clicking on the function or by dragging it to the
program on the right.""",
difficulty: Easy,
initial: [[Yellow, Yellow, Red], [Yellow, Red], [Red], [Red], [Yellow, Red], [Yellow, Yellow, Red]],
target: [[Red, Red, Red], [Red, Red], [Red], [Red], [Red, Red], [Red, Red, Red]]
},
"0.2" :-> {
name: "Rejection",
help: Just """To remove all cubes of a specified color, use the <code>reject</code>
function.""",
difficulty: Easy,
initial: [[Yellow, Yellow, Red], [Yellow, Red], [Red], [Red], [Yellow, Red], [Yellow, Yellow, Red]],
target: [[Red], [Red], [Red], [Red], [Red], [Red]]
},
"0.3" :-> {
name: "Composition",
help: Just """Most levels require a combination of two or more functions. Try to
add the functions `stackY` and `rejectY` to your program. Note that
you can change the order of the functions by drag and drop. Try to
understand the effect of `stackY` by observing how the cubes change.""",
difficulty: Easy,
initial: [[Yellow, Yellow, Red], [Yellow, Red], [Red], [Red], [Yellow, Red], [Yellow, Yellow, Red]],
target: [[Red, Yellow], [Red, Yellow], [Red, Yellow], [Red, Yellow], [Red, Yellow], [Red, Yellow]]
},
"0.4" :-> {
name: "Spanish flag",
help: Just """Try this on your own. You need to compose three
functions.""",
difficulty: Medium,
initial: [[Yellow, Yellow, Red], [Yellow, Red], [Red], [Red], [Yellow, Red], [Yellow, Yellow, Red]],
target: [[Red, Yellow, Red], [Red, Yellow, Red], [Red, Yellow, Red], [Red, Yellow, Red], [Red, Yellow, Red], [Red, Yellow, Red]]
}
]
}