Q6 - WanderBot (1.25 points) Create a class called WanderBot. WanderBot is a bot that will...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Q6 - WanderBot (1.25 points) Create a class called WanderBot. WanderBot is a bot that will wander around randomly. Instance Attibutes: character string position - list of [int, int] moves list of list of [int, int] grid_size None or int Of these instance attributes, only character should be taken in as an input to __init_____, with a default value of 8982. Inside the init_ : self.character should be set as the chr of input character self.position should be set to starting position [0, 0] self.moves should be set as the list of possible moves, which are [[-1, 0], [1, 0], [0, 1], [0, -1]] self.grid_size should be initialized as None Add two methods to WanderBot: Method: wander This method will choose a random move from the possibilities, making sure that move is valid on the current grid. Procedure: Initialize a boolean variable has_new_pos as False Use a while loop, with the condition not has_new_pos Set a variable move as the output of calling random.choice on self.moves Add move to self.position, using add_lists (a function we created earlier), and assign the output to a new variable new_pos Call check_bounds on new_pos, also passing self.grid_size into check_bounds Assign the output of check_bounds to has_new_pos This will lead to exiting the loop when a valid new position has been assigned . Return new_pos Method: move No inputs (other than self) or outputs, just sets self.position to be the output of calling self.wander (). class WanderBot: def __init__(self, character-8982, position, moves, grid_size): self.character chr (character) self.position = [0,0] self.moves = [[-1,0], [1,0], [0,1], [0,-1]] self.grid_size = None def wander (self, manufacturer, model, year, mpg): has_new_pos= False while (not has_new_pos): move = random.choice (self.moves) new_pos= add_lists (move, self.position) has_new_pos=check_bounds (new_pos, self.grid_size) return new_pos def move (self): self.position=self.wander() : class WanderBot: def _init__(self, character-8982, position, moves, grid_size): self.character = chr(character) self.position = [0,0] self.moves [[-1,0], [1,0], [0,1], [0,-1]] self.grid_size = None def wander (self, manufacturer, model, year, mpg): has_new_pos = False while (not has_new_pos): move = random.choice (self.moves) new_pos= add_lists (move, self.position) has_new_pos=check_bounds (new_pos, self.grid_size) return new_pos def move (self): self.position=self.wander() File "/tmp/ipykernel_186/1704160856.py", line 2 def __init__(self, character-8982, position, moves, grid_size): SyntaxError: non-default argument follows default argument : assert WanderBot wbot assert wbot WanderBot () TypeError /tmp/ipykernel_186/27214554.py in 1 assert WanderBot ----> 2 wbot = WanderBot () 3 assert wbot. Traceback (most recent call last) Q6 - WanderBot (1.25 points) Create a class called WanderBot. WanderBot is a bot that will wander around randomly. Instance Attibutes: character string position - list of [int, int] moves list of list of [int, int] grid_size None or int Of these instance attributes, only character should be taken in as an input to __init_____, with a default value of 8982. Inside the init_ : self.character should be set as the chr of input character self.position should be set to starting position [0, 0] self.moves should be set as the list of possible moves, which are [[-1, 0], [1, 0], [0, 1], [0, -1]] self.grid_size should be initialized as None Add two methods to WanderBot: Method: wander This method will choose a random move from the possibilities, making sure that move is valid on the current grid. Procedure: Initialize a boolean variable has_new_pos as False Use a while loop, with the condition not has_new_pos Set a variable move as the output of calling random.choice on self.moves Add move to self.position, using add_lists (a function we created earlier), and assign the output to a new variable new_pos Call check_bounds on new_pos, also passing self.grid_size into check_bounds Assign the output of check_bounds to has_new_pos This will lead to exiting the loop when a valid new position has been assigned . Return new_pos Method: move No inputs (other than self) or outputs, just sets self.position to be the output of calling self.wander (). class WanderBot: def __init__(self, character-8982, position, moves, grid_size): self.character chr (character) self.position = [0,0] self.moves = [[-1,0], [1,0], [0,1], [0,-1]] self.grid_size = None def wander (self, manufacturer, model, year, mpg): has_new_pos= False while (not has_new_pos): move = random.choice (self.moves) new_pos= add_lists (move, self.position) has_new_pos=check_bounds (new_pos, self.grid_size) return new_pos def move (self): self.position=self.wander() : class WanderBot: def _init__(self, character-8982, position, moves, grid_size): self.character = chr(character) self.position = [0,0] self.moves [[-1,0], [1,0], [0,1], [0,-1]] self.grid_size = None def wander (self, manufacturer, model, year, mpg): has_new_pos = False while (not has_new_pos): move = random.choice (self.moves) new_pos= add_lists (move, self.position) has_new_pos=check_bounds (new_pos, self.grid_size) return new_pos def move (self): self.position=self.wander() File "/tmp/ipykernel_186/1704160856.py", line 2 def __init__(self, character-8982, position, moves, grid_size): SyntaxError: non-default argument follows default argument : assert WanderBot wbot assert wbot WanderBot () TypeError /tmp/ipykernel_186/27214554.py in 1 assert WanderBot ----> 2 wbot = WanderBot () 3 assert wbot. Traceback (most recent call last)
Expert Answer:
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Python and most Python libraries are free to download or use, though many users use Python through a paid service. Paid services help IT organizations manage the risks associated with the use of...
-
Samson Tile produces its product in two processing departments: Forming and Finishing. The following T-account shows the Forming Department's Work in Process Inventory at August 31 prior to...
-
1. Why might the U.S. government, which funds Social Security, Medicare, and unemployment insurance programs by taxing wages, desire to find a way to reduce self-employment and inhibit the growth of...
-
Relationship marketing, integrated marketing, internal marketing, and performance marketing are the four pillars of what concept?
-
Marijuana Use The percent of college students marijuana use for a sample of 95,761 students is shown in the pie chart. Find the probability of each event. (a) Randomly selecting a student who never...
-
Andrews Company has $80,000 available to pay dividends. It has 2,000 shares of 10%, $100 par, preferred stock and 30,000 shares of $10 par common stock outstanding. The preferred stock is selling for...
-
Lakeside Incorporated manufactures four lines of remote control boats and uses activity-based costing to calculate product cost. Activity Pools Machining Setup Quality control Estimated Total Cost $...
-
How are human and physical capital different from one another in the way they evolve from period to period?
-
Researchers dialogued with individual students on campus, but subsequent group interviews proved fruitless. Revise the following sentences to use plain language and familiar words.
-
Which of the following is the correct extract of the income statement of Islamic Bank of Jordan at the end of the 1st year? a. Profit/(loss) from Murabaha Financing (20,000) b. Profit/(loss) from...
-
As assistant to the vice president, you are to explore the possibility of developing internship programs with several nearby colleges and universities. Using Figure 2.5, suggest the best...
-
Although the remuneration seems low, it is commensurate with other pay packages. Revise the following sentences to use plain language and familiar words.
-
Why is it acceptable to use instant messaging abbreviations (such as BTW) and happy faces (emojis) in messages to friends but not in business messages?
-
Le Natures Internal Control Case Analysis Read this case study about Le Nature's problems. After readying Use a case format to address the seven questions 1. identify the parties impacted by quality...
-
A horizontal annulus with inside and outside diameters of 8 and 10 cm, respectively, contains liquid water. The inside and outside surfaces are maintained at 40 and 20oC, respectively. Calculate the...
-
What happens when you enter the /imports command in a new JShell session?
-
Write an application that inputs a line of text and a search character and uses String method indexOf to determine the number of occurrences of the character in the text.
-
Write an application that inputs a line of text and displays the longest word (the word that has the maximum number of characters) in that sentence.
-
Financial items for George Karatsis IT Services on 31 May 2024 are presented below in alphabetical order. Required (a) Prepare a statement of financial position similar to the one in figure 2.2. (b)...
-
Rebecca Tallance operates a rent a dress business from her home. She keeps her accounting records for business activities completely separate from her records for personal activities. At 30 June...
-
During the year ended 30 June 2024, Skilled Services, a provider of temporary secretary personnel, had collected receipts from clients for a total value of \($250000.\) Wages of \($136000\) had been...
Study smarter with the SolutionInn App