Git Product home page Git Product logo

battleship_engine's Introduction

Battleship Game Engine

by SeokJun Bing (aka Jun)

Coded in python2.7 environment

Files

./game.py contains the Game class which is the engine of the game that initializes Player and Ship classes. Contains an example that does a basic test run of the game and highlights usage.
./player.pycontains the Player class. Responsible for the main bulk of game logic and rules.
./ship.pycontains the Ship class

Statisfies the following requirements

  • Allow to start a new 2-player game (i.e. each player places their pieces)

  • Ability to return the board-states at any point in time (i.e. which cells are occupied/hit/sunk)

    • game.get_player1_boards() and game.get_player2_boards() returns nested lists
    • game.pretty_print_player1_boards() and game.pretty_print_player2_boards() prints ascii representation of the boards
  • Allow players to take turns shooting at a 1x1 target cell

    • game.take_turn(coordinate)
      • automatically decides whose turn it is and shoots at coordinate
  • Ability to signal when a ship is sunk

    • Whenever a ship is sunk a message is printed to stdout.
      • E.g. Sam's Destroyer is sunk
  • Ability to signal when someone wins or loses

    • When all of a player's ships are sunk a message is printed to stdout.
      • E.g. Game Over: John wins, Sam loses
    • game.is_game_over() returns a boolean indicating if the current game is finished
  • Ability to play on a default 10 by 10 board with these default ships.

    • Carrier - 1x5
    • Battleship - 1x4
    • Submarine - 1x3
    • Cruiser - 1x2
    • Destroyer - 1x2
  • Extensibility

    • Able to use board sizes other than 10 by 10
      • Board size is an input to the Game class initializer
      • Can also use non-square board sizes such as 10 by 15
    • Able to use custom ships such as a 2x2 Petrol piece and/or multiple pieces
      • game.add_custom_ship() allows addition of new ships of any size

battleship_engine's People

Contributors

seokjunbing avatar

Watchers

 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.