You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ProjectScreen(1, PROJ, "We have a winner!!!", self.bs_win),
77
77
ProjectScreen(1, PROJ, "YOU SAX!!!", None),
78
78
ProjectScreen(1, PROJ, "Next time, try to aim *inside* the ocean", None),
79
79
ProjectScreen(1, PROJ, "\"Insanity: doing the same thing over and over and expecting different results\" - Albert Einstein", None),
@@ -97,7 +97,6 @@ def s_init(self, unitNum):
97
97
defp_init(self, unitNum):
98
98
self.new(0)
99
99
s="self.proj_"+str(unitNum)+"()"
100
-
print(s)
101
100
exec(s)
102
101
self.master.geometry(self.homeBounds)
103
102
@@ -218,9 +217,24 @@ def bs_empty_list(self):
218
217
219
218
defbs_board_list(self):
220
219
self.new_proj(1, 2)
221
-
self.multiLbl("""Now we need to make the list store where the ship is and where you fired and stuff so let's get right to the Chase. Or Wells Fargo. Or whatever bank you use. So, there's this thing I haven't told you. Actually two things. Number 1: If there's a list inside a list, it's called a 2-dimensional list or a 2D list. A list in a list in a list is a 3D list. Etc, etc, etc. The other thing is that you can create lists with multiple copies of the same value by wrapping it in square brackets (as in to create a list of one item) and multiplying it by a certain amount. Let me give you an example. Let's say you wanted a list with 3 "O"s stored in cheerios. You could initialize it like this: cheerios = ["O", "O", "O"] or you could initialize it like this: cheerios = ["O"]*3 and still get the same result. We'll use this when making our board. Instead of doing a manual 2D array and stuff, we're going to do it like this:\nrows = 5\ncols = 5\n board=[["O"]*5]*5 and you will get [['O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O']]""")
220
+
self.multiLbl("""Now we need to make the list store where the ship is and where you fired and stuff so let's get right to the Chase. Or Wells Fargo. Or whatever bank you use. So, there's this thing I haven't told you. Actually two things. Number 1: If there's a list inside a list, it's called a 2-dimensional list or a 2D list. A list in a list in a list is a 3D list. Etc, etc, etc. The other thing is that you can create lists with multiple copies of the same value by wrapping it in square brackets (as in to create a list of one item) and multiplying it by a certain amount. Let me give you an example. Let's say you wanted a list with 3 "O"s stored in cheerios. You could initialize it like this: cheerios = ["O", "O", "O"] or you could initialize it like this: cheerios = ["O"]*3 and still get the same result. We'll use this when making our board. Instead of doing a manual 2D array and stuff, we're going to do it like this:\nwidth = 5\nheight = 5\n board=[["O"]*height]*width and you will get [['O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O']]""")
222
221
223
222
defbs_print_board(self):
224
223
self.new_proj(1, 3)
225
224
self.multiLbl("""We need a method to print out the board good because we don't want it looking like [['O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O'],['O', 'O', 'O', 'O', 'O']]. We want to join it. So the function called print_board which will take one argument, board and will have a for loop in which we are doing a command *for row in board*. The command is a method I haven't told you about yet. It's called join. The syntax is like this: str.join(list). For example, we want to print O O O O O where it's currently printing ['O', 'O', 'O', 'O', 'O'] so we do " ".join(board) to join the board with spaces. That is our command in the for loop.""")
226
-
225
+
226
+
defbs_hide(self):
227
+
self.new_proj(1, 4)
228
+
self.multiLbl("""Let's "hide" the ship. To do this, we need to have a few lines of code. First we need to do this thing called import-ing. To import, you can either do import module_name or from module_name import what_you_want_from_the_module (or you can add as what_you_want_to_called). So we need to do a from module_name import what_you_want. We want to import randint from random. Soooo, just use your logic and from random import randint. Then you need to set a variable *col =* to a *randint* from *(0* to *height-1)* and set *row =* to a *randint* from *(0* to *width-1)*. Then you have the locations of the ship""")
229
+
230
+
defbs_seek(self):
231
+
self.new_proj(1, 5)
232
+
self.multiLbl("""Let's "seek" the ship. To do this, we need to ask the user for *input()*. Let's set a variable called *row_guess =* to *input("Guess row: ") and set *col_guess =* to *input("Guess column")*. Then we have a guess that literally does nothing (so far).""")
233
+
234
+
defbs_debug(self):
235
+
self.new_proj(1, 6)
236
+
self.multiLbl("""It's not cheating. It's debugging. You should really *print* the *row* and *col*.""")
237
+
238
+
defbs_win(self):
239
+
self.new_proj(1, 7)
240
+
self.multiLbl("""To make a winning condition you need to test *if guess_row == row and guess_col == col:* and inside the *if* you should *print("something like \\"We have a winner\\"")*.\n\n\nP.S. \\ means escape a character, e.g. \\n means new line, \\\\ means a backslash, \\t means a tab, etc.""")
0 commit comments