Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

annalyns-infiltration: Update docs #707

Merged
merged 3 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions exercises/concept/annalyns-infiltration/.docs/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

## 1. Check if a fast attack can be made

We need to check if the knight is awake and _invert_ its truth value. This can be done with the [`not`][not] function.
We need to check if the knight is awake and _invert_ the boolean value representing their state. This can be done with the [`not`][not] function.

## 2. Check if the group can be spied upon

We want the function to return `true` if _any_ of the supplied predicates are `true`. This can be done using the [`or`][or] function.
We want to return `true` if _any_ of the supplied predicates are `true`. This can be done with the [`or`][or] function.

## 3. Check if the prisoner can be signalled
## 3. Check if the prisoner can be signaled

We want to return `true` if and only if _all_ of the supplied predicates are `true`. This can be done with the [`and`][and] function.

## 4. Check if the prisoner can be freed

Here, we need to combine the three basic logical operators, [`and`][and], [`or`][or], and [`not`][not].
We need to combine the three basic logical operators, [`and`][and], [`or`][or], and [`not`][not].

[not]: https://clojuredocs.org/clojure.core/not
[or]: https://clojuredocs.org/clojure.core/or
Expand Down
49 changes: 33 additions & 16 deletions exercises/concept/annalyns-infiltration/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
# Instructions

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.
In this exercise, you'll implement the quest logic for a new RPG game that a friend is developing.
The game's main character is Annalyn, a brave girl with a fierce and loyal pet dog.
Unfortunately, disaster strikes: her best friend was kidnapped while searching for berries in the forest.
Annalyn will try to find and rescue her friend, optionally taking her dog along on the quest.

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.
After some time spent following the trail, Annalyn discovers the camp where her friend is imprisoned.
It turns out there are two kidnappers: a mighty knight and a cunning archer.

Having found the kidnappers, Annalyn considers which of the following actions she can engage in:

- 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.
- Spy: the group can be spied upon if at least one of them is awake. Otherwise, spying is a waste of time.
- 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.
- _Free prisoner_: Annalyn can try sneaking into the camp to free the prisoner.
This is a risky thing to do and can only succeed in one of two ways:
- If Annalyn has her pet dog with her she can rescue the prisoner if the archer is asleep.
- 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.
- Spy: the group can be spied upon if at least one of them is awake.
Otherwise, spying is a waste of time.
- Signal prisoner: the prisoner can be signaled using bird sounds if the prisoner is awake and the archer is sleeping.
Archers are trained in bird signaling and could intercept the message if they are awake.
- _Free prisoner_: Annalyn can attempt to sneak into the camp to free the prisoner.
This is risky and can only succeed in one of two ways:
- If Annalyn has her pet dog, she can rescue the prisoner if the archer is asleep.
The knight is scared of the dog and the archer will not have time to get ready before Annalyn and the prisoner can escape.
- If Annalyn does not have her dog then she and the prisoner must be very sneaky!
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.
- If Annalyn does not have her pet dog, then she and the prisoner must be very sneaky!
Annalyn can free the prisoner if the prisoner is awake and both the knight and archer are sleeping.
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.

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.
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.

## 1. Check if a fast attack can be made

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`:
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`:

```clojure
(def knight-awake? true)
Expand All @@ -31,7 +40,9 @@ Implement the `can-fast-attack?` function, which takes a boolean value indicatin

## 2. Check if the group can be spied upon

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`:
Implement the `can-spy?` function, which takes three boolean values indicating whether the knight, archer, and 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`:

```clojure
(def knight-awake? false)
Expand All @@ -42,9 +53,11 @@ Implement the `can-spy?` function, which takes three boolean values indicating w
;;=> true
```

## 3. Check if the prisoner can be signalled
## 3. Check if the prisoner can be signaled

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`:
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 signaled based on the state of the two characters.
Otherwise, it returns `false`:

```clojure
(def archer-awake? false)
Expand All @@ -56,7 +69,11 @@ Implement the `can-signal-prisoner?` function, which takes two boolean values in

## 4. Check if the prisoner can be freed

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`:
Implement the `can-free-prisoner?` function, which takes four boolean values.
The first three parameters indicate whether the knight, archer, and 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 the presence of Annalyn's pet dog.
Otherwise, it returns `false`:

```clojure
(def knight-awake? false)
Expand Down
Loading