Essay Help Services

CSP2151 | Assignment 2 A Mini Programming Project | IT

Home Recent Questions CSP2151 | Assignment 2 A Mini Programming Project | IT

Tasks:

Design and implement a program that can do the following various tasks to manage the simulation of a robotics competition.

Your program should first load the information of up to 10 robots from a file named “Robot.txt” and store the information into an array of structures for robots. The minimum requirement for the data structure representing a robot can be found in Section (1). The program then displays all available robot information stored in the array of structures.

Next, the program should display a menu that allows the user to navigate through and execute the following options:

• Search a robot

• Input/update robot information

• Simulate a robot against a human opponent

• Display simulation results

• Display winners

• Save robot information

• Save all results

• Exit

The “Search a robot” feature should allow the user to search for information on a robot by its Robot_Name. If found successfully, the information stored in the related entry/entries in the robot array should be displayed. Otherwise, an error message should be displayed.

As a special case, if the robot name entered is “all”, it displays information for all robots.

The “Input/update robot information” feature allows the user to input or updates the information of a robot. It prompts the user to input a Robot_Number. If the Robot_Number entered matches an existing robot, the information entered is used to update the information of the robot stored in the array of robots. Otherwise, a new entry is created in the array of robots and information is stored therein in the array.

The “Simulate a robot against a human opponent” feature should allow the user to select a robot from the array of robots, and then simulate robot combat against a human opponent. This

feature can also be named “robot test”. Detailed simulation task is described in Section (2).

The “Display simulation results” feature should allow the user to choose a robot (e.g., by the robot name) and display all test simulation results of the robot. If the robot has not been tested yet (i.e., no simulation result was recorded), the program should inform the user that they must test that robot before displaying any results of the robot. If multiple robots have the same name, all test results of robots with that name should be displayed.

(1) Data structures for Robots

Referencing the Robot structure defined in your Workshop 3, define a new structure to represent a robot for this simulation purpose. Your Robot structure should include at least 6 fields, including Robot_number, Robot_name, Year_Manufactured, Top_speed, Mass, Best_score. You may add any extra field/s as you need.

(Note: The Best_score field should be initialized 0.0 for all robots).

(2) Robot combat test simulation

This task simulates a robot combat scenario, completing calculations on various data items, and storing and displaying test/simulation result.

Robot combat test simulation can be done under random conditions (i.e., conditions are randomly generated automatically within a reasonable value range), or by manually entering a set of test conditions or a (weighted) combination of the above two cases (called hybrid conditions). - Due to time and workload constraints, we only perform a version of hybrid conditions case in this assignment (that is, some test conditions are entered manually while others are generated randomly).

As a special case, if the robot name entered is “all”, it should display the test results of all robots that have been tested. If none of the robots has been tested, an error message should be displayed.

The “Display winners” feature should display an error message if no robot has been tested. Otherwise, it should display the top one robot in speed (one with the highest speed), the top one robot in strength and the top one robot in combat-effectiveness (i.e., a total of 3 results) of all robots that have been tested.

The “Save robot information” feature should extract all robot information stored in the robot array and save them back to the “Robot.txt” file (for future use). For simplicity, only up to 10 records of robot information are required to save.

The “Save all results” feature should display an error message if no robot has been tested. Otherwise, it creates a file, named “Result.txt”, and save the names and test results for all robots that have been tested, to the file.

(1) Data structures for Robots

Referencing the Robot structure defined in your Workshop 3, define a new structure to represent a robot for this simulation purpose. Your Robot structure should include at least 6 fields, including Robot_number, Robot_name, Year_Manufactured, Top_speed, Mass, Best_score. You may add any extra field/s as you need.

(Note: The Best_score field should be initialized 0.0 for all robots).

(2) Robot combat test simulation

This task simulates a robot combat scenario, completing calculations on various data items, and storing and displaying test/simulation result.

Robot combat test simulation can be done under random conditions (i.e., conditions are randomly generated automatically within a reasonable value range), or by manually entering a set of test conditions or a (weighted) combination of the above two cases (called hybrid conditions). - Due to time and workload constraints, we only perform a version of hybrid conditions case in this assignment (that is, some test conditions are entered manually while others are generated randomly).

At the start, the function prompts the user to choose one robot from the available robots. It then prompts the user to enter three test conditions (including the finish_line_distance, finish_line_time, and strength, of the robot) for the test simulation.

The test conditions are set as follows and must comply with the listed restrictions:

• finish_line_distance

o Measured in meters (of float data type)

o Must be greater than or equal to 0.0

• finish_line_time

o Measured in second (of float data type)

o Must be greater than 0.0

• strength

o Is the number of objects the robot can lift (of int data type)

o Must be in the range from 0 to 100

If the user enters an invalid value for any test condition, the program should print an error message, together with the data entered, and continue to prompt the user again until a valid value is entered.

Based on the information entered, the simulation calculates various data items, including speed and combat_effectiveness of the robot participating in the simulation. The simulation is done the same way as that described in Workshop 2, plus the following further tasks: It then compares the current combat_effectiveness value with the value stored in the Best_score field in the related entry of the robot array. If the current combat_effectiveness value is greater than that entry value, it offers an opportunity to the user to accept (thus to replace the Best_score of the relevant robot) or discard the result.

Finally, it displays the simulation results (together with test conditions) in a properly designed table.

It then offers the option of saving this output to the results array before starting a new simulation or quitting.

Bonus Mark (up to 5 marks):

Additional work and effort to improve the program and make it more useful can be worth bonus marks. Bonus marks are not required and will not improve your grade above 100% available marks.

Examples of features that may be worth bonus marks:

• Advanced search features (search for all simulation/test results above a threshold)

• Non-case sensitive search of information based on robot name

• Use multiple files effectively with appropriate use of header files and good separation of concerns.

• Graphical user interfaces, animations or colors.

• Ask your tutor if you have other ideas!

NOTE: The Workshops have been working up to this point to provide you with a base program of your own work that should give you the best possible opportunity for completing this assignment. You should look at how these Workshops have developed your work for a guide on how to structure your final assessment.

Similar Posts

Order Now

Latest Reviews

Facebook

Payments And Security