Question: USING C++ ONLY Please fill out the while loop for this question. Following the question guidelines will be the included .h and .cpp files. BACKGROUND

USING C++ ONLY

Please fill out the while loop for this question. Following the question guidelines will be the included .h and .cpp files.

BACKGROUND

One of the most common problems in video games is determining the fastest route from 2 positions. In this assignment, you will look at how to determine that route efficiently using a simple graph that describes the connections between the nodes. The data file for this assignment will be formatted as follows:

Line 1: The number of nodes in the map (we will call this N).

Line 2 to N+1: The weights for the connections for each node in the graph. The value of -1 indicates there is no direct path between the current node (the row being read) and the target node (the column being read). Note that the value of 0 is possible, and the weight to go from any node to itself will always be 0.

Lines N+2 and following: Each line represents a pair of nodes. The first is the target position and the second is the current position. For each (current, target) pair, you must find the fastest route in the graph.

REQUIREMENTS 1. Complete the Game::FindFastest function in the game.cpp file to find the shortest path between positions.

2. The algorithm should be as close to linear time as possible!

game.cpp

USING C++ ONLY Please fill out the while loop for this question.

game.h

Following the question guidelines will be the included .h and .cpp files.

main.cpp

BACKGROUND One of the most common problems in video games is determining

Below is a sample input file

the fastest route from 2 positions. In this assignment, you will look

Example on how to find the shortest route

at how to determine that route efficiently using a simple graph that

To reclairfy only submit code in C++. Also only edit the code in the while loop in the game.cpp file where it says "// fill in algorithm to find lowest weight to target position from current position"

Thank you in advance

#include #include "game . h" 2 4 int Game: FindFastest (int currentPos, int targetPos) ant BumRows.ssoFar (nunRowa, INT AX)? s E std: :vector bestSoFar (numRows,INT_MAX) PriorityQueue toBeProcessed toBeProcessed.push (Progress (currentPos,0)) 7 10 while (!toBeProcessed.empty)&& bestsoFar [targetPos]INT MAX) 12? 13 14 15 16 17 18 // fill in algorithm to find lowest weight to target position from current position int weight -bestSoFar[targetPos] return (weight "game . h" 2 4 int Game: FindFastest (int currentPos, int targetPos) ant BumRows.ssoFar (nunRowa, INT AX)? s E std: :vector bestSoFar (numRows,INT_MAX) PriorityQueue toBeProcessed toBeProcessed.push (Progress (currentPos,0)) 7 10 while (!toBeProcessed.empty)&& bestsoFar [targetPos]INT MAX) 12? 13 14 15 16 17 18 // fill in algorithm to find lowest weight to target position from current position int weight -bestSoFar[targetPos] return (weight

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!