Simulation and Modeling (CSCI 3010U)
Faculty of Science, Ontario Tech University
http://vclab.science.ontariotechu.ca
Discuss in class
Consider the code provided below. It implements the classes necessary to implement random walks. You are asked to complete the following two tasks:
Complete the following Walker class such that this walker takes one of the following 4 2d steps with equal probability (1,0), (-1,0), (0,1.1), (0,-0.9)
class WalkerUp(Walker):
def __init__(self, name):
__init__(self, name)
Walker.
def step(self):
return Walker.step(self)
Complete the following class that implements traps. When a walker reaches a trap it is magically transported to a random location.
class FieldWithTraps(Field):
def __init__(self, w, h, num_traps):
__init__(self)
Field.
def reset(self):
self)
Field.reset(
def move(self, walker):
self, walker) Field.move(
Here \(w\) and \(h\) defines the width and the height of the region where traps are located.
The exercise will be completed in class. Upload your thoughts, code, notes to the activity dropbox on course canvas.
Be prepared to show your work to the instructor.