Question
Programming Question: Drone Surveillance Game in C Please help! No idea how to do any of this. All information is given below. The program should
Programming Question: Drone Surveillance Game in C
Please help! No idea how to do any of this. All information is given below. The program should all be in C
The link below gives the DroneWars.h header file and the libsimulator.a .
https://filesender.internet2.edu/?vid=70bec0ce-3cfa-1b48-6337-00001d7c29af
12.3 Game Programming: Drone Surveillance Challenge 12.3.1 The Rules
The object of the drone surveillance game is to guide a drone to survey the most of a square grid world. The agents begin in a random location of the grid-world and can see every adjacent square, forming a 3-by-3 "vision" matrix centered around them. Cells with a value of 1 contain obstacles and cannot be entered.
On each turn, the agent function is called with a structure containing the current vision matrix and information about the challenge to be solved. If the agent answers the challenge correctly, it is allowed to move.
Moves are indicated by the numbers 1-4 corresponding to the cardinal directions, beginning with north and proceeding clockwise. So to move south, and agent would return 3 and to move west it would return 4. An agent only moves if they correctly answer the challenge and request a valid move (not into an obstacle).
The game engine tracks all cells that have been seen by an agent; the agent that has surveyed the plurality of the gird-world by the end of the nal round wins. The number of rounds and size of the world can be altered by command-line arguments.
12.3.2 The Tools
The main function of the program is included in the compiled libsimulation.a library, you do not need to include one in your code. By modifying the DroneWars.c code and utilizing the DroneWars.h header, you will write:
1. Two "agent" functions that take in a header dened structure with game information, place the required data at a location pointed to by the answer pointer, and then return their desired move
2. A display function that takes 2 le pointers to the map of the agents explored area and uses gnuplot to display a map (either in the console or by producing image les) with obstacle cells colored dierently then free cells.
12.3.3 The Twist
Much of the meat of this exercise comes from determining how to interface with the game from the header le - navigating the structures, unions, enums and pointers that it entails.
12.3.4 Challenges
Calculation Given a string of a mathematical expression, return the integer value (Hint: Use popen())
Sub-String Given 2 strings, return a pointer to the beginning of the rst occurrence of that string (Hint: Use strstr())
Range Given two integers, return the range between them as an integer
Mean Given an array of oats and the number of oats in the array, return the arithmetic mean as a oat
Minimum Given an array of oats and the number of oats in the array, return the minimum value as a oat
Maximum Given an array of oats and the number of oats in the array, return the maximum value as a oat Reverse Given a string, return a string that is the reverse (Hint: Use strlen())
Find Given a string and a char, return the integer index of the position of the rst occurrence (Hint: Use memchr)
Tokenize Given a string, tokenize it by whitespace and return a pointer to a malloced 1-D array of the token strings.
12.3.5 Magic Key Words To assist with research into topics not previously covered, the following key-words are provided:
Void Pointers
C Unions
This is the given DroneWars.c file
// A simple program that computes the square root of a number #include #include "DroneWars.h"
int Agent_1(struct Round round) {
return 1; }
int Agent_2(struct Round round) {
return 2; }
void Display(FILE *agent_1_board, FILE *agent_2_board) {
char buf[255]; fgets(buf, sizeof buf, agent_1_board); printf("First line of agent_1_board: '%s' ", buf);
}
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