Battleship Python Game

1. Appearance (View Component(s)) - (5pts matching appearance):

 

Two Panels (either extended or QWidgets base):

– (1pt) Must use QWidget to display user positions (grid 10x10)

– (1pt) Must use QWidget to contain Buttons for guessing enemy location

 

User Mouse Interaction on Canvas

 

–  (2pt) Click to add grid to user placement (17 spots must be placed)

–  BONUS POSSIBLE (5 pts): add ships as denoted by the game in order of their size (5,4,3,3,2). Hint use left/right mouse button for vertical/horizontal placement.

–  (1pt) Disable user action, when all 17 spots are placed.

 

User Interaction on Frame/Buttons

– (1pt) Disallow interaction until all 17 spots are added in above panel.– When button clicked:

 

∗  (3pt) reference enemy placement loaded from file (see below), if hit/miss note accordingly (via text: for miss, X for hit; or via background color)

∗  (1pt) Nothing happens if pressed from before

∗  (2pt) Check if win, i.e. hit all 17 enemy spots

∗  (2pt) AI player randomly chooses a spot of yours that was not tried before

*  (2pt) Provide a Label informing the user what they are to do, place ships, take turn,...

 

 

2. Game Logic (Model Component(s)) - (5pts matching behavior)

 

(3pt) Upon initalization load battleship 0.txt into a data structure of some kinds (list/dictionary/etc)...file IO

 

Adding ships:

 

–  (1pt) Uses virtual functions on placement panel

–  (1pt) Changes appearance, but stores placement for AI check (list/dict/etc)

–  (1pt) Disallow multiple placement on single spot (or overlap if doing bonus)

–  (1pt) Must inform user how many spots are left to place (counts/length of somekind)

 

User Move (points assigned above):

 

– Checks stored spots of AI positions, updates accordingly

– Checks for win condition

 

AI Move:

 

– (1pt) Triggered immediately after non-winning user move– (2pt) Randomly chooses a spot not yet tried

– (1pt) Displays AI hit miss on canvas

 

 

3. Controller and Other requirements

 

• (1pt) Must use external QtWidgets module

• (1pt) Must extend from at least 1 QtWidget class

• (1pt) Must use either a list or dict to store the player/ai board state

Need a custom answer at your budget?

This assignment has been answered 6 times in private sessions.

Or buy a ready public solution below.

Buy ready solution

Solution previews

© 2020 Codify Tutor. All rights reserved