Giter Site home page Giter Site logo

cognitivescale's Introduction

Design

The general approach of this design has several classes:

  • Board: The model of the overall game. The Board is responsible for loading itself from a string, printing a z-slice, computing scores, holding the game pieces, and applying ship commands (movement and firing)
  • Point[23]d: Convenience classes for storing 2d and 3d points. In interest of time and complexity, I didn't use a more generic system for coordinates -- a more detailed implementation would be able to handle multiple coordinate systems abstracting away the details of each.
  • FiringPattern: A convenience class for applying firing pattern lists. Since "firing" a torpedo is really just placing it over a mine in the board, there's not a whole lot of logic here. It's essentially just shorthand for a Seq. In a more complex system, there would likely be several functions here for calculating trajectories, etc.
  • Ship: Responsible for taking a set of commands and calling board functions to apply them.

The Board responds to commands in a command "queue" which is a List of Lists of BoardCommands. When each List of Commands is complete the Board will score, print, and drop the ship, returning the resultant board. This message passing is the easiest way to ensue type safe manipulation of global data. When done properly, it's not overly heavy in memory usage, but for large data sets it is likely not effecient.

Note the Unit tests are not executing properly. This began very late in the project, and I have not had a chance to clean it up.

Running the application can be easiest accomplished with: sbt "run <board file> <script file>" Note the quotes are important. This project assumes you are running sbt 0.13.5 or higher with scala 2.10 or higher and was tested with sbt 0.13.8 and 2.10.3.

cognitivescale's People

Contributors

nrigney avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.