You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/concept/annalyns-infiltration/.docs/instructions.md
+33-16
Original file line number
Diff line number
Diff line change
@@ -1,26 +1,35 @@
1
1
# Instructions
2
2
3
-
In this exercise, you'll be implementing the quest logic for a new RPG game a friend is developing. The game's main character is Annalyn, a brave girl with a fierce and loyal pet dog. Unfortunately, disaster strikes, as her best friend was kidnapped while searching for berries in the forest. Annalyn will try to find and free her best friend, optionally taking her dog with her on this quest.
3
+
In this exercise, you'll implement the quest logic for a new RPG game that a friend is developing.
4
+
The game's main character is Annalyn, a brave girl with a fierce and loyal pet dog.
5
+
Unfortunately, disaster strikes: her best friend was kidnapped while searching for berries in the forest.
6
+
Annalyn will try to find and rescue her friend, optionally taking her dog along on the quest.
4
7
5
-
After some time spent following her best friend's trail, she finds the camp in which her best friend is imprisoned. It turns out there are two kidnappers: a mighty knight and a cunning archer.
8
+
After some time spent following the trail, Annalyn discovers the camp where her friend is imprisoned.
9
+
It turns out there are two kidnappers: a mighty knight and a cunning archer.
6
10
7
11
Having found the kidnappers, Annalyn considers which of the following actions she can engage in:
8
12
9
-
- Fast attack: a fast attack can be made if the knight is sleeping, as it takes time for him to get his armor on, so he will be vulnerable.
10
-
- Spy: the group can be spied upon if at least one of them is awake. Otherwise, spying is a waste of time.
11
-
- Signal prisoner: the prisoner can be signalled using bird sounds if the prisoner is awake and the archer is sleeping, as archers are trained in bird signaling so they could intercept the message.
12
-
-_Free prisoner_: Annalyn can try sneaking into the camp to free the prisoner.
13
-
This is a risky thing to do and can only succeed in one of two ways:
14
-
- If Annalyn has her pet dog with her she can rescue the prisoner if the archer is asleep.
13
+
- Fast attack: a fast attack can be made if the knight is sleeping, as it takes time for him to put on his armor, leaving him vulnerable.
14
+
- Spy: the group can be spied upon if at least one of them is awake.
15
+
Otherwise, spying is a waste of time.
16
+
- Signal prisoner: the prisoner can be signaled using bird sounds if the prisoner is awake and the archer is sleeping.
17
+
Archers are trained in bird signaling and could intercept the message if they are awake.
18
+
-_Free prisoner_: Annalyn can attempt to sneak into the camp to free the prisoner.
19
+
This is risky and can only succeed in one of two ways:
20
+
- If Annalyn has her pet dog, she can rescue the prisoner if the archer is asleep.
15
21
The knight is scared of the dog and the archer will not have time to get ready before Annalyn and the prisoner can escape.
16
-
- If Annalyn does not have her dog then she and the prisoner must be very sneaky!
17
-
Annalyn can free the prisoner if the prisoner is awake and the knight and archer are both sleeping, but if the prisoner is sleeping they can't be rescued: the prisoner would be startled by Annalyn's sudden appearance and wake up the knight and archer.
22
+
- If Annalyn does not have her pet dog, then she and the prisoner must be very sneaky!
23
+
Annalyn can free the prisoner if the prisoner is awake and both the knight and archer are sleeping.
24
+
However, if the prisoner is sleeping, they can't be rescued, as the prisoner would be startled by Annalyn's sudden appearance and wake up the knight and archer.
18
25
19
-
You have four tasks: to implement the logic for determining if the above actions are available based on the state of the three characters found in the forest and whether Annalyn's pet dog is present or not.
26
+
You have four tasks: to implement the logic for determining if the above actions are available based on the state of the three characters in the forest and whether Annalyn's pet dog is present or not.
20
27
21
28
## 1. Check if a fast attack can be made
22
29
23
-
Implement the `can-fast-attack?` function, which takes a boolean value indicating whether the knight is awake. The function returns `true` if a fast attack can be made based on the state of the knight. Otherwise, it returns `false`:
30
+
Implement the `can-fast-attack?` function, which takes a boolean value indicating whether the knight is awake.
31
+
The function returns `true` if a fast attack can be made based on the state of the knight.
32
+
Otherwise, it returns `false`:
24
33
25
34
```clojure
26
35
(defknight-awake?true)
@@ -31,7 +40,9 @@ Implement the `can-fast-attack?` function, which takes a boolean value indicatin
31
40
32
41
## 2. Check if the group can be spied upon
33
42
34
-
Implement the `can-spy?` function, which takes three boolean values indicating whether the knight, archer and the prisoner, respectively, are awake. The function returns `true` if the group can be spied upon based on the state of the three characters. Otherwise, it returns `false`:
43
+
Implement the `can-spy?` function, which takes three boolean values indicating whether the knight, archer, and prisoner, respectively, are awake.
44
+
The function returns `true` if the group can be spied upon based on the state of the three characters.
45
+
Otherwise, it returns `false`:
35
46
36
47
```clojure
37
48
(defknight-awake?false)
@@ -42,9 +53,11 @@ Implement the `can-spy?` function, which takes three boolean values indicating w
42
53
;;=> true
43
54
```
44
55
45
-
## 3. Check if the prisoner can be signalled
56
+
## 3. Check if the prisoner can be signaled
46
57
47
-
Implement the `can-signal-prisoner?` function, which takes two boolean values indicating whether the archer and the prisoner, respectively, are awake. The function returns `true` if the prisoner can be signalled based on the state of the two characters. Otherwise, it returns `false`:
58
+
Implement the `can-signal-prisoner?` function, which takes two boolean values indicating whether the archer and the prisoner, respectively, are awake.
59
+
The function returns `true` if the prisoner can be signaled based on the state of the two characters.
60
+
Otherwise, it returns `false`:
48
61
49
62
```clojure
50
63
(defarcher-awake?false)
@@ -56,7 +69,11 @@ Implement the `can-signal-prisoner?` function, which takes two boolean values in
56
69
57
70
## 4. Check if the prisoner can be freed
58
71
59
-
Implement the `can-free-prisoner?` function, which takes four boolean values. The first three parameters indicate whether the knight, archer and the prisoner, respectively, are awake. The last parameter indicates whether Annalyn's pet dog is present. The function returns `true` if the prisoner can be freed based on the state of the three characters and Annalyn's pet dog presence. Otherwise, it returns `false`:
72
+
Implement the `can-free-prisoner?` function, which takes four boolean values.
73
+
The first three parameters indicate whether the knight, archer, and prisoner, respectively, are awake.
74
+
The last parameter indicates whether Annalyn's pet dog is present.
75
+
The function returns `true` if the prisoner can be freed based on the state of the three characters and the presence of Annalyn's pet dog.
0 commit comments