Reference no: EM132210432
Question :
Write a program that opens a plotting grid window (labeled Lake Matlab) with its axis set to [-11 11 11 11 and the plots a circle of radius 10 with a black point style line.
This will represent the lake in which the boats can move about. Generate randomly (and save the coordinates of eight boats within this lake Repeatedly do the following 40 times:
1. Plot the boats (as diamond points with the following color requirements:
a) A boat whose distance is more than the square root of two from all other boats and whose distance is more than one from all lake boundary (shore) is Green
b) A boat whose distance is more than the square root of two from all other boats but whose distance is one or less from the lake boundary (shore is Magenta
c) A boat whose distance is exactly the square root of two or one from any other boat is Yellow
d) A boat whose distance is exactly zero from any other boat is Red (collision)
2. Delay for 0.5 second.
3. Move each boat on the lake by repeatedly modifying both the x-coord and y-coord by adding a randomly generated Integer in the range [-1, ij, until you have new values for x-coord and y- coord that does not put the boat on the shore.