MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / showInstructions

Function showInstructions

src/gamesbyexample/sonar.py:123–173  ·  view source on GitHub ↗

Display the game instructions.

()

Source from the content-addressed store, hash-verified

121 print('from 0 to 14.')
122
123def showInstructions():
124 """Display the game instructions."""
125 print('''Instructions:
126You are the captain of the Simon, a treasure-hunting ship. Your current
127mission is to use sonar devices to find 3 sunken treasure chests at the
128bottom of the ocean. But your sonar only finds distance, not direction.
129
130Enter the coordinates to drop a sonar device. The ocean map will be
131marked with how far away the nearest chest is, or an X if it is beyond
132the sonar device's range. For example, the C marks are where chests are.
133The sonar device shows a 3 because the closest chest is 3 spaces away.
134
135 1 2 3
136 012345678901234567890123456789012
137
138 0 ~~~~.~...~.~..~~~..~.~~..~~~..~.~ 0
139 1 ~.~.~..~~.~...~~~...~~.~.~~~.~~~~ 1
140 2 .~.C..3.~~~~.C.~~~~.....~~..~~~.. 2
141 3 ........~~~.....~~~.~.....~.~..~. 3
142 4 ~.~~~~.~~.~~.C.~..~~.~~~.~...~..~ 4
143
144 012345678901234567890123456789012
145 1 2 3
146(In the real game, the chests are not visible in the ocean.)
147
148Press Enter to continue...''')
149 input()
150
151 print('''When you drop a sonar device directly on a chest, you
152retrieve it. The other sonar devices update to show the distance to the
153next nearest chest. The chests are beyond the range of the sonar device
154on the left, so it shows an X.
155
156 1 2 3
157 012345678901234567890123456789012
158
159 0 ~~~~.~...~.~..~~~..~.~~..~~~..~.~ 0
160 1 ~.~.~..~~.~...~~~...~~.~.~~~.~~~~ 1
161 2 .~.X..7.~~~~.C.~~~~.....~~..~~~.. 2
162 3 ........~~~.....~~~.~.....~.~..~. 3
163 4 ~.~~~~.~~.~~.C.~..~~.~~~.~...~..~ 4
164
165 012345678901234567890123456789012
166 1 2 3
167
168The treasure chests don't move around. Sonar devices can detect treasure
169chests up to a distance of 9 spaces. Try to collect all 3 chests before
170running out of sonar devices. Good luck!
171
172Press enter to continue...''')
173 input()
174
175
176print('Sonar, by Al Sweigart al@inventwithpython.com')

Callers 1

sonar.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected