#
#  Executes target seeking random walk inside a
#  confining boundary(rectangle). Conducts and 
#   plots up to 5 random walks
#
#  Following parameters can be changed:
#    1- Size and location of boundary
#    2- Size and location of target
#    3 -Starting location for random walk 
#
import sys,random
import numpy as np
import randwalk2d_mod as rw2d
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle  # Used to draw rectangle
random.seed(None)        # Seed generator, None => system clock
#
#   Enter number of walks to plot and check entered value
#
num_walks = int(input('Enter number of walks to do (1-5) :  '))
max_steps = 10000
#  
#  Set up confining box, target , starting point for walks, 
#      and random step function
#  
boundary    = rw2d.setup_box((0.0, 0.0), 40, 40)
################################################################
#
#  YOUR CODE GOES HERE to set up target within box. Be careful where
#    you put it and how big you make it.
#  Format will be (using setup_box):
#    target = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
#
################################################################
start_loc   = ( 0.0, 0.0)
rand_function = rw2d.rand_angle

#  Allows each walk to use a different color/line type on plot 
line_type = ['r-','c-','k-','g-','m-'] 
#
#  Perform loop for each walk and plot with different color(line_type):
# 
for i in range(num_walks):      
#################################################################
#  ADD call HERE to the proper routine in randwalk2d_mod to conduct
#  random walk with target.  
#  Format will be:
#     xwalk1,ywalk1,steps_taken,target_reached = xxxxxxxxxxxxxxxx
#
################################################################# 

    plt.plot(xwalk1, ywalk1, line_type[i],label='wk'+str(i+1)+' '+      \
            str(steps_taken))
    plt.plot(xwalk1[-1],ywalk1[-1], 'b*', ms=8)  # Large * to mark end of walk
#  
#  Draw boundary and target on graph and set size of graph (xlim,ylim)
#  Create bold lines through walk starting point
#
rw2d.draw_boundary(boundary,start_loc)
rw2d.draw_target(target)
#  Set plot title , legend, and grid 
plt.title('2D walks inside box w/ target (' +str(num_walks)+ ')' )
plt.legend(loc="upper left")
plt.grid(True)
plt.show() 


