Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Background Information In an uncertain future, humankind wants to control the surface of the planet Omicron Persei 8, located out of the alpha centauri star

Background Information

In an uncertain future, humankind wants to control the surface of the planet Omicron Persei 8, located out of the alpha centauri star system. For this purpose, transceivers and certain type of robots are designed. Transceivers located to fixed locations, and robots are mobile and should be stay connected to the transceiver towers, otherwise, if robots cannot build a duplex connection (both transmitting and receiving signals) more than 60 seconds, it is assumed that the robot unit can be (or worse it is) captured by the aliens, and the units destroy themselves due to prevent any possible information leakage. Your task is to create a simulator to test the possible algorithms for this mission. In the planet Omicron Persei 8, the power of the electromagnetic waves used for communication decay linearly and inversely proportional to the distance from transceivers or robot units. A battlefield is composed of transceivers and the mobile units (robots)

. Transceiver: Transceivers (transmitter and receiver) (can also be think as base stations) are stationary and have fixed location. Every transceiver has a different transmitting power and minimum receiving power according to used components in them. Once a transceiver set up in the battlefield, then a local/internal time counter starts to run and count every second. Every transceiver should have a unique ID to build up separate communication channels.

Robots: While transceivers are stationary (fixed), robots can move depending on the class of the unit. Robots has their unique IDs, different than transceivers. Their transmitting power and minimum receiving powers are all same: transmitting power is 1 W and minimum receiving power is 10 mW. Since they move, they should have a velocity in meters/seconds (m/s). They also have status flag that shows dead or alive, and a counter that counts the disconnected time, if the connection is lost. According to trajectories, there are three types:Robot units share the properties of the Transceivers. They move with a constant speed in a constant direction, in other words they have a constant velocity. The velocity information is given when the robot unit is set up in the battlefield.

Guard : Guard units share the properties of the Robots. Moreover, guards move in a square trajectory and turn right with a given period. The default value for the period is set to 60 seconds

. Psycho : Psycho units share the properties of the Robots. However, their move and velocity are random, in addition, the changing frequency of the velocity is also random. The velocity a psycho can be 10 m/s {vx,vy} -10 m/s.

Battlefield: The battlefield should manage all the units, both transceivers and robots. Keep track of their status, position and other vital information related with the mission.

i want to write battle field class

Battle_Field class:

This class will hold information about the battlefield, including the list of transceivers, robots, and dead robots. It advances the time and update the information of all units properly, track the global time in seconds, and if a mobile unit does not communicate more than 60 seconds, it updates the status info of the unit from alive to dead and move the unit to dead robots list. The rest of the methods are given below.

Methods Explanation
__init__()

__init__ method should not take any parameters, it should create an instance of the Battle_Field class. Important data for this class is global time, the list of transceivers, robots, and dead robots. Global time should start from 0. >

>> field=Battle_Field()

add_transceiver(x,y,tpower,rpower)

This method should take x and y coordinates of the transceiver unit and transmitting and minimum receiving powers, then creates an instance of the Transceiver class and add it to the transceiver list. The default value for minimum receiving power is 1 mW.

>>> field.add_transceiver(0,0,10)

>>> field.add_transceiver(1200,0,1

5) >>> field.add_transceiver(500,500,12)

add_robot(x, y, vx,vy)

This method should take x, y coordinates of the robot unit in meters and the x and y components of the velocity of the robot unit in meter/seconds, then creates an instance of the Robot class and add it to the robot list.

>>> field.add_robot(10,25,10,0)

>>> field.add_robot(500,750,-10,10)

>>> field.add_robot(500,750,5,10)

add_guard(x,y,vx,vy,timer,period)

This method should take x, y coordinates of the guard unit in meters and the x and y components of the velocity of the robot unit in meter/seconds, period in seconds, and localtime, then creates an instance of the Guard class and add it to the robot list. Default value of the period is 60 s. Default value of the localtime is 0 s.

>>> field.add_guard(40,58,10,10)

>>> field.add_guard(1000,0,10,0)

>>> field.add_guard(750,800,-10,0)

add_psycho(x, y)

This method should take x, y coordinates of the psycho unit in meters, then creates an instance of the Guard class and add it to the robot list.

>>> field.add_psycho(-10,60)

>>> field.add_psycho(20,320)

>>> field.add_psycho(500,1020)

>>> field.add_psycho(750,300)

>>> field.add_psycho(-300,320)

>>> field.add_psycho(0,0)

get_transceivers()

This method is a yield method and will return the instances of the transceivers one by one as it is called

. >>> for e in field.get_transceivers():

... e.get_id()

... e.get_coordinates()

... e.get_tpower()

...

0

(0, 0)

10

1

(1200, 0)

15

2

(500, 500)

12

get_robots(self)

This method is a yield method and will return the instances of the robots one by one as it is called. >>> robotlist=[]

>>> for e in field.get_robots():

... e.get_id()

... e.get_coordinates()

... e.get_velocity()

... e.get_tpower()

... e.get_status()

... robotlist.append(e)

...

0

(10, 25)

(10, 0)

1

True

1

(500, 750)

(-10, 10)

1

True

2

(500, 750)

(5, 10)

1

True

3

(40, 58)

(10, 10)

1

True

4

(1000, 0)

(10, 0)

1

True

5

(750, 800)

(-10, 0)

1

True

6

(-10, 60)

(1.3244743561870607, 8.184241301280395)

1

True

7

kill_robot(robot)

This method takes an instance of robot class, change its status to dead, moves the instance from robot list to dead robots list.

>>> field.kill_robot(robotlist[-1])

get_deadrobots(self)

This method is a yield method and will return the instances of the dead robots one by one as it is called

. >>> for e in field.get_deadrobots():

... e.get_id()

... e.get_coordinates()

... e.get_velocity()

... e.get_tpower()

... e.get_status()

... 11 (0, 0) (-8.640836566874487, -4.231309190073986)

1

False

>>> plist=[]

>>> for e in field.get_robots():

... plist.append(e.get_id())

... >>> print(plist)

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

>>>

remove_robot(robotid)

This method takes the ID of a robot unit as integer and remove it from the battlefield. If the ID is not in the list of robots or the robot unit is already dead, it stops silently.

>>> field.remove_robot(4)

>>>

>>> plist=[]

>>> for e in field.get_robots():

... plist.append(e.get_id())

...

>>> print(plist)

[0, 1, 2, 3, 5, 6, 7, 8, 9, 10]

>>>

>>> plist=[]

>>> for e in field.get_deadrobots():

... plist.append(e.get_id())

... >>> print(plist)

[11]

>>>>>> field.remove_robot(12)

>>>

>>> plist=[]

>>> for e in field.get_robots():

... plist.append(e.get_id()) ...

>>> print(plist)

[0, 1, 2, 3, 5, 6, 7, 8, 9, 10]

>>> >>> plist=[

] >>> for e in field.get_deadrobots(): .

.. plist.append(e.get_id())

...

>>> print(plist) [11]

>>> >>> field.remove_robot(11)

>>> >>> plist=[]

>>> for e in field.get_robots(): ... plist.append(e.get_id()) ...

>>> print(plist) [0, 1, 2, 3, 5, 6, 7, 8, 9, 10]

>>> >>> plist=[]

>>> for e in field.get_deadrobots():

... plist.append(e.get_id())

... >>> print(plist) [11] >>>

remove_transceiver(trid)

This method takes the ID of a transceiver unit as integer and remove it from the battlefield. If the ID is not in the list of transceivers, it stops silently. >>> field.remove_transceiver(2)

>>>

>>> for e in field.get_transceivers():

... e.get_id()

...

0

1

>>>

progress_time()

This method increases the global time by 1 s, and updates information of the all units in the battle field, e.g., location, velocity, status, etc. It should determine if a robot unit is disconnected to transceivers, count the disconnected time and kill the robot unit if it is necessary. (i.e. when thedisconnected time is more than 60 seconds.) >>> for t in range(0,100):

... field.progress_time() ...

>>> for e in field.get_robots():

... e.get_id()

... e.get_coordinates() .

.. e.get_velocity() .

.. e.get_localtime() ... 0 (1010, 25) (10, 0) 100 3 (1020, 258) (10, -10) 98 5 (160, 1210) (0, 10) 100 6 (-467.98963784057054, 561.3554601689915) (-2.1699251412935467, 2.2042403694388124) 100 7 (-355.31694453664517, 2.959241230324075) (-9.005021674480796, 6.429716114905737) 100 9 (24.443531362925544, 825.8590014386745) (-8.803137727443325, -0.2879545026354222) 99 10 (-424.31012125603405, 901.6672578627087) (3.012620921307711, 0.8172815797196868) 100 >>> for e in field.get_deadrobots(): ... e.get_id() ... e.get_coordinates() ... e.get_velocity() ... e.get_localtime() ... 11 (0, 0) (-8.640836566874487, -4.231309190073986) 0 8 (513.1134371398435, 1036.0747414608418) (0.21497437934167962, 0.2635203518170677)

__str__()

This method will return the number of units in the following format as string.

>>> print(field)

Number of transceivers: 2

Number of robots (alive): 7

Number of dead robots: 4

create_report() This method will return the global time information, number of units, then the status of transceiver, robot, and dead robot units in the following format as string. >>> print(field.create_report()) Time: 100 s Number of transceivers: 2 Number of robots (alive): 7 Number of dead robots: 4 Class: Tower Tower number: 0 Coordinates: Transmitting Power: 10W Min. Receiving Power: 1.0mW Class: Tower Tower number: 1 Coordinates: Transmitting Power: 15W Min. Receiving Power: 1.0mW Class: Robot Robot number: 0 Current Coordinates: Current Velocity: Transmitting Power: 1W Min. Receiving Power: 10.0mW Status: Alive Class: Guard Robot number: 3 Current Coordinates: Current Velocity: Transmitting Power: 1W Min. Receiving Power: 10.0mW 22 Status: Alive Class: Guard Robot number: 5 Current Coordinates: Current Velocity: Transmitting Power: 1W Min. Receiving Power: 10.0mW Status: Alive Class: Psycho Robot number: 6 Current Coordinates: Current Velocity: Transmitting Power: 1W Min. Receiving Power: 10.0mW Status: Alive Class: Psycho Robot number: 7 Current Coordinates: Current Velocity: Transmitting Power: 1W Min. Receiving Power: 10.0mW Status: Alive Class: Psycho Robot number: 9 Current Coordinates: Current Velocity: Transmitting Power: 1W Min. Receiving Power: 10.0mW Status: Alive Class: Psycho Robot number: 10 Current Coordinates: Current Velocity: Transmitting Power: 1W Min. Receiving Power: 10.0mW Status: Alive Class: Psycho Robot number: 11 Current Coordinates: Current Velocity: Transmitting Power: 1W Min. Receiving Power: 10.0mW Status: Dead INF 211 - Algorithms and Programming I - Electronics Engineering - Gebze Technical University - Fall 2022 23 Class: Psycho Robot number: 8 Current Coordinates: Current Velocity: Transmitting Power: 1W Min. Receiving Power: 10.0mW Status: Dead Class: Robot Robot number: 2 Current Coordinates: Current Velocity: Transmitting Power: 1W Min. Receiving Power: 10.0mW Status: Dead Class: Robot Robot number: 1 Current Coordinates: Current Velocity: Transmitting Power: 1W Min. Receiving Power: 10.0mW Status: Dead

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions

Question

Prove Equation (5.22).

Answered: 1 week ago