Course:CPSC312-2017-Kingdom of Zed
Kingdom of Zed
Authors: Brian Chen, Johnson Huang, Erik Cui
What is the problem?
We will create the Kingdom of Zed game as defined by http://www.cs.sfu.ca/CourseCentral/383/pjj/a1.html
Github repo here: https://github.com/brian618/the-unseen-blade
What is the something extra?
We will attempt to implement 3 additional tasks found in http://www.cs.sfu.ca/CourseCentral/383/pjj/a1.html
1) Allow maps of Zed or arbitrary size, i.e. any n×n map for n >= 2
2) Display the output as a grid (not a list)
3) Implement one or more solving strategies, so that your program tries to find a solution intelligently (rather than just brute force). This will allow the program to handle large or difficult puzzles
What did we learn from doing this?
When programming when Haskell, breaking down the solution into small parts is essential. To implement the Zed solution algorithm, we separated matrix processing from the validation, making the program easier to reason with and program. Creating a list of all possible variation of boards in Haskell is trivial, but verifying board correctness is fairly tedious. List comprehension allows Haskell to generate constrained permutations in concise code, whereas other languages would need verbose for-loops or other methods of iteration. Haskell is suitable for this task if concise code / speed of implementation is desired. However, in general Haskell is harder to optimize for performance because of the abstraction, so solutions are likely to be slower than similar algorithms in lower level languages like C/C++.