Course:CPSC312-2019-yexiu-isaac

From UBC Wiki

Battleship Board Game

Authors: Yexiu Zhou, Isaac Cheung

What is the problem?

We will be building a Haskell implementation of the Battleship board game to determine the feasibility of using Haskell to develop board games.

What is the something extra?

Allowing the player to create their own board

Ability to load and save current game

Difficulty levels

  • Easy - Computer always randomly targets positions.
  • Normal - Computer will target around confirmed hits if there are any, otherwise random.
  • Hard - Computer is given a single point at the beginning of the game that will guarantee a hit.
  • God Mode - The computer sees your board.

What did we learn from doing this?

We were able to complete the project with Haskell.

Some problems we had to overcome were that:

  • IO Types can be quite finicky
  • Generating random moves was harder than initially assumed
  • Coming from an Object Oriented mindset meant that initially we were fighting against the language instead of fully utilizing it's strengths
  • readFile and lazy IO makes saving to the same file a genuine problem.

Some things that we found Haskell did very well:

  • The syntax was very readable
  • Easy to access list elements
  • Very easy to do bug fixes (fixing one part of the code doesn't break another)

Some issues we noticed about using Haskell for game development:

  • Lack of global variables meant that everything needed to be constantly passed through functions
  • Slower than more traditional languages used in game development such as C++
  • managing states in Haskell can be cumbersome, especially considering how in OOP languages you can directly manipulate the state

The issues stated here aren't really relevant for battleship, however they might bottleneck Haskell's viability for creating larger more dynamic games.

Overall, while Haskell was suitable for creating battleship, for larger games Haskell might be outclassed by other languages in terms of performance (which explains why Haskell isn't widely used in game development). The lack of dynamic global variables might also affect Haskell's viability for game development by complicating things.

Links to code etc

https://github.com/yexiuzhou/CPSC312-Project1