Question
(continuation of previous question) 3. RandomRobots.java program Build RandomRobots.java, which generates a given number of robots (10 in the example below) in a given grid
(continuation of previous question)
3. RandomRobots.java program
Build RandomRobots.java, which generates a given number of robots (10 in the example below) in a given grid size (20 x 20 in the example below), and after presenting them as they initially appear, he moves them sequentially until each one has reached the end of its course, and when it does it presents the final end of each robot. Initially each robot is placed at random, but each in a different position. The following example of using the program demonstrates the function of the toString () method:
The paths and endings of the various robots are also presented visually (using it StdDraw), as shown in the image above for this example. Grid, in gray, on white canvas, created from the beginning by the program RandomRobots. Then through the activations of the move reference method, it is painted gradually the course of each robot. Finally, the RandomRobots program adds full circles in the places where the robots ended up, with the following colors:
green meaning live set managed to escape, red which means it has been destroyed (in every red position it must have ended up, leading to destruction, at least two robots) and black which means that is alive but trapped. Finally the RandomRobots program signals with smaller ones full circles, in orange, the starting points of the robots. In the example above, the three of the ten robots managed to escape and stay alive. One in fact had been placed outside from the beginning, and of course remained there. One robot ended up self-trapping, while the other six were destroyed, namely there were three conflicts in pairs. In fact, in such a case, the conflict took place in an external position (which under other circumstances it would lead to the escape of the first robot to arrive there).Below are some other examples of visual presentation of the courses and extensions of the relevant robots (via the RandomRobots program):Sjava Random Robots 10 20 ROBOTS AT INITIAL STATE Robot RO is positioned at (1,4) The robot is alive Robot Riis positioned at (1,3) The robot is alive Robot R2 is positioned at (2,12) The robot is alive Robot R3 is positioned at (19,11) The robot is alive Robot R4 is positioned at (17,5) The robot is alive Robot R5 is positioned at (5,15) The robot is alive Robot R6 is positioned at (10,2) The robot is alive Robot R7 is positioned at (13,0) The robot is alive and has escaped Robot R8 is positioned at (17,11) The robot is alive Robot R9 is positioned at (11,8) The robot is alive ROBOTS AT FINAL STATE Robot RO is positioned at (10,14) The robot is dead It has moved as follows: - From position (1,4) to position (2, 4) From position (2,4) to position (3,4) - Fron position (3,4) to position (3,3) Pron position (3,3) to position (4,3) - Fron position (4,3) to position (4,4) - Fron position (4,4) to position (4,5) - Fron position (4,5) to position (4,6) - Fron position (4,6) to position (4,7) - From position (4,7) to position (4,8) - Fron position (4,8) to position (4,9) - From position (4,9) to position (5,9) - Fron position (5,9) to position (5,10) - Fron position (5,10) to position (6,10) - From position (6,10) to position (7.10) - Fron position (7,10) to position (8,10) - From position (8,10) to position (9,10) - From position (9,10) to position (10,10) - From position (10,10) to position (10,11) 10 3030 ( -) 5 2020 ( , , )
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started