Reference no: EM133381073
Computer Networking
Problem Description
Review the solution to the 2D-Random Walk problem from Ex1 and make required correction to your Ex1 solution.
Importing the necessary functions from Ex1 write a program that simulates an experiment entailing 100 trials of the random walk. Your program shall output the simulation results to a csv file. The file must contain the trial number and number of steps taken in each trial.
For each trial display a trace of the path taken using the turtle module. Additionally display the number of trials and the average number of steps taken in each trial on the turtle screen.
Your program shall minimally define and use the following functions (descriptions are provided in the given template script):
• reset(): Puts the turtle at the center and sets the heading to 0, without tracing the turtle's path. Additionally, shall reset the turtle's pen color to a random color for tracing the path taken in the next walk
• experiment(num_trials=100, top_speed=False) -> list: Repeats the random walk for the given number of trials. If top_speed is set to True uses the turtle module's tracer function to speed up the animation (NB: recommended value for tracer is 20). The function shall return a nested list with trial number and steps taken in each trial ex. [[1, 90], [2, 112], ..., [100, 240]]
• write_results(results, file='rwalk.csv'): Takes results from the experiment function and displays the number of trials and average steps taken in each walk on the turtle screen. Additionally, writes the full results i.e. trial number and steps to a csv file. Header of csv file must be a descriptive string depicting the data in each column ex: 'Trial #', 'Number of steps'