Hidden WordScanner
Private scans · No account required

DuckieDai Battleship

A one-player Battleship game on a 5 by 5 grid: find three hidden ships by row and column before you run out of 10 misses.

games · MIT License

Overview

A one-player Battleship game on a 5 by 5 grid: find three hidden ships by row and column before you run out of 10 misses.

  • Owner-tested on a TI calculator
  • Version 1.0.0
  • 1898 bytes
  • Uses random

Before you run it

  • TI-84 Plus CE Python · No calculator OS or Python App version has been verified.
  • TI Connect CE .py transfer to the Python App; the owner's transfer details were not recorded
  • Three ships, 3, 2, and 2 squares long, are hidden at random on a 5 by 5 grid for every game, across or down.
  • Ships never overlap but may touch each other.
  • A shot is typed as row,col with whole numbers from 1 to 5, such as 2,3.

Play it here first

Play a full round right here before you download. The screen below runs the same steps as the calculator game: type your answer in the box under it and press Enter, just as you would on the calculator. Each round picks a new secret, and nothing you type is saved.

JavaScript is required for the optional browser simulation. Source viewing and downloading remain available without it.

Simulation boundary: This preview uses a reviewed browser adapter. It does not execute the downloaded Python and does not prove TI-Python or calculator compatibility.

How to play

How to play Battleship

About the game

The calculator hides three ships on a 5 by 5 grid: one 3 squares long and two 2 squares long. Each ship lies in a straight line, across or down. Fire at squares by row and column to find all 7 ship squares.

You can miss 10 times. Sink every ship before the tenth miss to win; run out of misses and the game is over. Ships never overlap, but they can touch each other.

Controls

row,col
fire at a square: the row number, a comma, then the column number, such as 2,3
Q
quit the game
enter
fire, or move on from a result screen
Y
play another game; any other answer ends the program

How to play

Tips

Good to know

Exact reviewed bytes

Source code

Download .py

View source below, copy it when JavaScript is available, or download the exact .py bytes.

  1. # DuckieDai(TM) Battleship
  2. # TI-84 Plus CE Python
  3. from random import randint
  4. def clear():
  5. print('\n'*8)
  6. def intro():
  7. print('DUCKIEDAI(TM)')
  8. print('BATTLESHIP')
  9. print(' __')
  10. print(' ___(o )> quack!')
  11. print(' \\ <_. )')
  12. print(" `---'")
  13. print('by DuckieDai')
  14. print('hiddenwordscanner.com')
  15. input('Press Enter ')
  16. clear()
  17. def ships():
  18. used=[]
  19. for size in (3,2,2):
  20. while 1:
  21. d=randint(0,1)
  22. r=randint(0,4-(size-1)*(1-d))
  23. c=randint(0,4-(size-1)*d)
  24. cells=[]
  25. for i in range(size):
  26. cells.append((r+i*(1-d),c+i*d))
  27. if all(p not in used for p in cells):
  28. used+=cells
  29. break
  30. return used
  31. def board(fired):
  32. print(' 1 2 3 4 5')
  33. for r in range(5):
  34. s=str(r+1)+' '
  35. for c in range(5):
  36. s+=fired.get((r,c),'.')+' '
  37. print(s)
  38. def play():
  39. wins=0
  40. losses=0
  41. limit=10
  42. while 1:
  43. target=ships()
  44. fired={}
  45. hits=0
  46. misses=0
  47. quitgame=False
  48. while hits<7 and misses<limit:
  49. clear()
  50. print('HITS',hits,'/7 MISS',misses,'/10')
  51. board(fired)
  52. print('X=hit o=miss')
  53. s=input('Row,col? (q=quit) ')
  54. if s.lower()=='q':
  55. quitgame=True
  56. break
  57. try:
  58. a,b=s.split(',')
  59. r=int(a)-1
  60. c=int(b)-1
  61. if r<0 or r>4 or c<0 or c>4:
  62. msg='Use 1 to 5'
  63. elif (r,c) in fired:
  64. msg='Already fired!'
  65. elif (r,c) in target:
  66. fired[(r,c)]='X'
  67. hits+=1
  68. msg='HIT!'
  69. else:
  70. fired[(r,c)]='o'
  71. misses+=1
  72. msg='MISS!'
  73. except:
  74. msg='Enter row,col'
  75. clear()
  76. print(msg)
  77. print('Misses left:',limit-misses)
  78. input('Press Enter ')
  79. if quitgame:break
  80. clear()
  81. if hits==7:
  82. print('ALL SHIPS SUNK!')
  83. print('QUACK QUACK!')
  84. wins+=1
  85. else:
  86. print('OUT OF MISSES!')
  87. losses+=1
  88. print('Wins:',wins,'Losses:',losses)
  89. board(fired)
  90. input('Press Enter ')
  91. clear()
  92. if input('Again? Y/N ').upper()!='Y':break
  93. clear()
  94. print('DuckieDai(TM)')
  95. print('hiddenwordscanner.com')
  96. intro()
  97. play()
Filename
BATTLE.py
Size
1898 bytes
SHA-256
c917be46318cdd68df1803e9fe2d7f99c15f3ceee07b97b0986b7f2b03eae8d5

Usage

Inputs

  • A shot as row,col, such as 2,3
  • Q to quit the game
  • Y to play again, anything else to stop

Outputs

  • The grid with X for hits and o for misses, with hits out of 7 and misses out of 10
  • HIT or MISS after each shot, with the misses left
  • ALL SHIPS SUNK or OUT OF MISSES, then the win and loss totals

Units: Grid squares; no units.

Assumptions and limitations

Assumptions

  • Three ships, 3, 2, and 2 squares long, are hidden at random on a 5 by 5 grid for every game, across or down.
  • Ships never overlap but may touch each other.

Constraints

  • A shot is typed as row,col with whole numbers from 1 to 5, such as 2,3.
  • A shot outside the grid, at a square already fired on, or typed another way does not count as a miss.

Known failures

  • The game does not say when a single ship has sunk; it counts hits up to 7.
  • The win and loss totals reset when the program is started again.

Compatibility and review

Review status
Owner-tested on a TI calculator
Tested on
Owner reports personally playing this game on a TI-84 Plus CE Python calculator; the test date, OS version, and Python App version were not recorded
What happened
Owner reported pass on the calculator. The file is published exactly as provided; this exact file has not yet been rerun on a calculator.
Dependencies
random
Suggested calculator name
BATTLE — you can give it another valid, unique name when you transfer it
Desktop test cases
Not available for this interactive-only source

This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.

Transfer and launch

Download the .py file, send it to your calculator with TI Connect CE as BATTLE or another name, then open the Python App and start a game. Press [on] to stop at any time. This release has no verified calculator OS or Python App version; treat transfer and execution as unverified until independently tested.

Full installation and troubleshooting guide. Check your teacher's or exam's rules before using any program.

Version history

Enjoying a DuckieDai game? Every game and program here is free. If you would like to say thanks, you can leave a tip on Cash App ($duckiedai214) or read what tips pay for.

Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.

Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters, and so does a Yes or No answer about whether the program worked. Your browser notes that you answered; that note is never sent to the site. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.