Homework Help . How to make a route to find the most amount of coins in a certain amount of moves ?

Hi everyone ! I've been struggling with my last part of my homework so basically i have a grid that is N amounts of squares then i have the coordinates of my hero that are x,y , then we have D the maximum amount of moves the hero can make , P for the gold coins and p1 , p2 to pP the list of coordinates of the coins . So basically i have to find the optimized route to get the most coins possible . The hero can move in all direction (see the first picture .) and if they are two or more coins in his range he has to use a magic compass that scan the north , west and south-east and then where there are the most amount of coins the hero will go . and the response must be the coordinates that the hero moves and at the end the coins he gains . i've done this much so far so i've got the list of coins and the coordinates and all the variables that i need but then i have no idea how i can setup the optimized route for the coins . Thanks for the help ^^
14 Replies
JakenVeina
JakenVeina•2y ago
I don't fully understand your constraints does the hero know about all the coins, or just the adjacent ones? what does the magic compass reveal? where in this process are you making a decision?
Potato_Boy🦉
Potato_Boy🦉OP•2y ago
okay so he know's about all the coins but if they are two or more coins near him he uses the magic compass to decide which one he should go after the magic compass scan the areas and counts the coins that are in each direction and the direction where there are the most coins is where the hero will move too . basically the work is that i have a txt file with all the settings and moves and in the end the results must be the same sorry if i don't answer right my english isn't the best
JakenVeina
JakenVeina•2y ago
so, you're not really finding an optimal route you're just being given an algorithm, and expected to implement it is there anything in particular you're stuck on?
Potato_Boy🦉
Potato_Boy🦉OP•2y ago
well i don't know how to scan for the coins next to the hero basically and then how to scan with the magic compass
JakenVeina
JakenVeina•2y ago
what do your data structures look like?
Potato_Boy🦉
Potato_Boy🦉OP•2y ago
it looks something like this
Potato_Boy🦉
Potato_Boy🦉OP•2y ago
it looks something like this and the output must looks like the second one
JakenVeina
JakenVeina•2y ago
no in code how are you modeling your data
Potato_Boy🦉
Potato_Boy🦉OP•2y ago
that's all of the code i have for now all the data is N = Int32.Parse(data[0]); string[] coord = data[1].Split(','); X = Int32.Parse(coord[0]); Y = Int32.Parse(coord[1]); D = Int32.Parse(data[2]); P = Int32.Parse(data[3]); int Coinvar = 4; var Coins = new List<string>(); int c = 0; for (c=0;c<P;++c) { Coins.Add(data[Coinvar]); Coinvar += 1;
Accord
Accord•2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
JakenVeina
JakenVeina•2y ago
well, that's a good start so, what do we have X and Y are the coordinates of the player? D is, uhh, the distance the player can move? N and P are....? what is Coinvar? and how are coins represented as a string?
Potato_Boy🦉
Potato_Boy🦉OP•2y ago
N is the size of the grid and P is the amount of coins . coinvar is for the list so that its adds all the coins to the list but i am not sure if its the correct methode . and the coins are represent with their xy coordinates like 1,0 for exemple where x is 1 then there is a , and then we have y is 0 .
Accord
Accord•2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server