#
#  Executes random walk inside a confining
#  boundary(rectangle).Following parameters can be changed:
#    1- Size and location of box
#    2 -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 = 1000
#  
#  Set up confining box, target , starting point for walks, 
#      and random step function
#  
box    = rw2d.setup_box((0.0, 0.0), 40, 40)
start_loc   = ( 0.0, 0.0)
#  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):      
    xwalk1,ywalk1 = rw2d.random_walk_box(max_steps, start_loc, box)
    plt.plot(xwalk1, ywalk1, line_type[i],label='wk'+str(i+1))
    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(start_loc, box)
#  Set plot title , legend, and grid 
plt.title('2D walks inside box (' +str(num_walks)+ ')' )
plt.legend(loc="upper left")
plt.grid(True)
plt.show() 


