battleship game... click and drag your pieces to the board, battle the computer
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


    A simple game of Battleship that used the pygame library.  Lets you drag
your ships on your board and then play against the computer.  The computer,
once a hit has been made on your ship, will click in a line pattern until it
has blown it up.  There's some room for improvement when it's guessing ship 
location for sure, but once a ship has been hit and not yet sunk, the algorithm
is comparable to how a human would do it...(except in a few special cases where
the find_neighbor() function is called.)
    The correctness of the placement of the user's ships is checked by using 
set() union operations on the center dots of each tile and the rectangle 
collision functions from pygame.
    My own ship object rotation function was created to rotate a ship while
it is being dragged by the mouse.  Some of the click and drag methods within the
Ship class will be handy for future click-and-drag games, like Chess or
    Python's dictionaries make it easy to have "struct" "data members"... The 
name of the data member is just the key.  This was used in creating the board
which is comprised of a 2D list of a dictionary with all the bool data members
needed that give the state of the boards: 'ship', 'clicked', and 'sunk' were 
used to communicate with the display function to figure out which clip is to
be used.
    Feel free to use this code and offer simplifications for the click and 
drag and rotations.  Also, I'm not 100% sure of the compatibility of other 
Operating Systems with this code.
    Andrew Hoyle 12/31/12