My take on a classic pencil and paper game with Python. The main challenges here are:  
  • 1) To create a competitive AI that can make good logical choices.
       Possible look into implementation of pre-made algorithms.
  •  
  • 2) Integrate everything with a smooth GUI/User experience using Qt for python.
       I don't have much experience with GUI architecture, probably will be the most challenging part to do right.
  • The Rules:


    Thursday, June 18, 2020
    ===============================

    Over the years there have been couple of variations of the game BattleShip from what the wikipedia page tells me.
    The Samuel Bednar version seems to be quite an interesting choice and the one that I will be model the game after.

    Setup the following ships on your 10x10 grid:

    Fleet of Ships

    Ship Size Quantity
    Carrier 5 1
    Battleship 4 1
    Cruiser 3 1
    Destroyer 2 2
    Submarine 1 2

    Each round the player will fire a number of salvos corresponding to the number of ships that are alive.
    The selection of grid spaces to attack will happen during the turn, the shots will be fired simultaneously at the end of the turn. The player will find out if he had hit something at the end of his turn.

    (Since a player has multiple shots during a given turn [unless he has 1 ship left], I think it's for the best that he only finds out at the end of the turn whether they hit. Otherwise it will give a big disadvantage to the player who starts second.)

    The player who kill all his enemy's ships will win

    Figure 1. : A typical pen-and-paper version of the game.

    The Back-end:


    Saturday, June 06, 2020 (updated: June, 18)
    ===============================

    I want this project to have a fully functional back-end before I start my work on the GUI. The idea is to have a class called Player,
    this class will have a grid setup function that will be ran during its __init__ method.

    A PC subclass will inherit Player, with an addition of random module, and therefor the pc can setup run its own own ships setup by using random inputs.
    (I don't think its necessary to add logic to ship placement since randomizing their locations seems like a fine strategy for me.)

    Ship will be another class shared by both player/pc, they will have all the info allocated to each ship (its position etc..), and will be used to update ships status on the grid.



    Figure 2. : Ship testing placement.

    Saturday, June 21, 2020
    ===============================

    The structure for the back-end in mostly completed. Only minimum AI has been implemented so far, the opponent
    will not shoot at previous location he shot in before. Other then that all the PC selection is random so far.

    The work towards building a GUI for the game has started.

    Figure 3. : Back end object interaction overview.

    Saturday, July 07, 2020 (updated: Aug, 03)
    ===============================

     The GUI development so far has been a bit slow due to other work getting in the way and the fact that I'm pretty new the the Qt framework.

    The setup interface is almost done. The interface uses the same back-end logic,
    a) takes one anchor point
    b) generates all possible end location based on the ships length.
    The only adjustment made to the back-end was how it receives the user inputs.

    The button grid is generated via a for loop and placed in a QButtonGroup with an ID based on it's location. I use this button id to do most of the manipulations.



    Figure 4. : Setup GUI screen.

    Saturday, June 21, 2020
    ===============================

    The structure for the back-end in mostly completed. Only minimum AI has been implemented so far, the opponent
    will not shoot at previous location he shot in before. Other then that all the PC selection is random so far.

    The work towards building a GUI for the game has started.

    Figure 5. : Back end object interaction overview.

    Friday, December 11, 2020
    ===============================

      Configuration for GUI interface with PyQt5

    Figure 6. : Splash screen GUI.
    Figure 7. : Setup GUI.