Giter Site home page Giter Site logo

battleship's People

Contributors

jessawitzel avatar wwitzel3 avatar

Watchers

 avatar

battleship's Issues

Game Board Edit

Edit the game board to use O's for 'Ocean' instead of 'S' for 'Sea'.

Attack Function

Create a function that changes the gameboard to reflect 'X' instead of the current value at the hit site after you have made a guess/attack.

If you hit a ship site it should change the ship value from 'C' or 'U' or 'D' to 'X' but also put into a new list the ship value that you are losing.

hit_ships = []

Sank Function

Use the hit_ships and .count() to create a function that will print "You destroyed my [shipname]" when the count of a certain ship's value == the ship's size.

Use len() to print "Congratulations! You won!" if the length of hit_ships == sum of all of the placed ship's sizes.

Test Attack Function

Add tests that test the new attack function. Create variable hit_ships which is referenced in attack.

Print Opponent's Board

Create a function that allows a player to print their opponents board which shows the player's hits and misses.

Cleanup duplicate logic in Board

Currently in the Board class there is looping logic that is duplicated between place_ship and collides.

I recommend we create a method called get_sequence. This method would take the starting row, column, and sequence_size as well as the direction the sequence should be captured. get_sequence would return all of the values from that sequence in the board.

For example given the board below, if you wanted to get the sequence of C, you would call get_sequence(row=1, col=2, seq_sz=3, direction='NS') # NS (NorthSouth). Which would return a list of the values from that sequence, ['C', 'C', 'C'] allowing you to easily check for collisions when placing a ship.

SSSSS
SSCSS
SSCSS
SSCSS
SSSSS

Game Over?

If you sank a ship, check to see if all ships have been sank and if they have end the game. You win!

create sank_ships list = []
if sank(ship) == True, check length of sank_ships and if length is 5, end game.

Place Ship Input

Define a function that receives raw input from the player on where they want to place each ship and uses place_ship to alter the board.

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.