practicalli / practicalli/clojure
Text adventure game - moving - sequence of moves
Open
Nobody has claimed this yet.
kata
- Dominant language
- Makefile
- Stars
- 117
- Forks
- 36
- PR merge metrics
- No merged PRs in 30d
Description
A function takes a position
{:dir :NORTH :x 0 :y 0}
and a move instruction
"R10" (turn Right, go 10 units)
returns a new position
{:direction EAST :forward 10 :back 0}`
"Given a position (direction, forward, back) and move instruction, returns a new position"
[position action]
(apply-delta (assoc position :direction (turn position action)) action))
Now start with a single position and a sequence of directions, ["R10", "L20", "R10"] and return the final position.
pseudocode:
var pos = {:dir :NORTH :x 0 :y 0}
for (var dir : directions) {
pos = move(pos, dir)
}
return pos
In Clojure
`(reduce update-position initial-position)`
To see the "path" taken, use `reductions` instead
`(reductions update-position initial-position)`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the existing update-position function and its position and action representations. Start by reading how turn and apply-delta are implemented, then use the described sequence with reduce to produce the final position and reductions to expose the path. Done means sequential moves return the expected final position and path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100