Question
C++ or Java programming question (Please help if you can) Simulation of two people wandering trying to find each other 1. Prompt the user to
C++ or Java programming question (Please help if you can)
Simulation of two people wandering trying to find each other
1. Prompt the user to enter map coordinates A units wide and B units tall (2 <= A <=50, and 2 <= B <= 50) (the coordinates may not be the same) that will then create a rectangular map that the two characters will navigate through. One character starts in the upper left hand corner and the other starts in the lower right hand corner. The characters try to move from one cell in the grid to another cell in the grid simultaneously. Time units are integers; time starts at 0 and is incremented by one at each time step. At each time unit, each person tries to move one unit by randomly choosing one direction ( most likely through a random number generator) , either North, South, East, West, Northeast, Northwest, Southeast, or Southwest. The grid is surrounded on all four sides by the impossible barrier. So, if the randomly selected direction takes the person into the barrier, they just stay at the same place they were at the start of that time unit. For example, since character 1 starts in the upper left corner of the grid, if character 1 randomly decides to go North, West, Northwest, Southwest, or Northeast, then character 1 will not move out of the upper left corner on that turn. However, if character 1 randomly decides to go any of the other three directions, then character 1 will actually move to a new cell. Simulate the random moves of the two characters until they either end up in the same cell (stop program) or do not meet after 1,000,000 time units (stop program)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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