I was assuming the same thing, thanks for brining it to my attention.
the truth write is:
if ((LX == TX) && (LY < TY))
^^
{
ā¦
}
My if statement is fine but thor keeps running off the map on trial 3
i have tried adding a W movement with the SW movement but he still moves off screen. Am I missing something?
Same thing here. Not sure what the problem is.
It would be great to have the coordinate system briefly explained, as it is the first game that uses a coordinate system.
Due to my background, I automatically assumed that the X axis was horizontal from left to right and the Y axis vertical from bottom to top (I am sure many people make the same mistake). It took me some time to understand what was wrong.
Please help me on the logic of looping a test for thorās coordinates each time his energy changesā¦
Too complex I think. For any single move, Thor just has to decide whether to move diagonally or along just one axis.
So just have him make all his diagonal moves first.
Every move is [[[āNā or āSā or āā]]] concatenated with [[[āEā or āWā or āā]]].
You can get the first string with a compare, the second string with another compare, and then concat for the move. Same with updating his position for your own bookkeeping.
I solved two times with both Dynamic Programming and BFS.
Looks like I overthought the solution.
Where is my mistake?
No full code
Have you updated Thorās position?
Right! Thank you!
No full code
Timeout: your program did not provide an input in due time. Earth was destroyed!
how can i make it run faster?
break or continue?
At the coding areaā¦ it seems all the test cases are running successfully, but when I submit the code it shows all are wrongā¦ canāt understand the matter.
yeah continue
I did solve the problem and I see 100% but when I go back to the games page it looks like doesnāt solved. what should I do except clicking the submit button?
You donāt know how THIS phrase in particular was helpful, completed this because of it, thanks!
The loop runs infinite time and produces output. The game reads output one line at a time. So whenever you output a direction, game updates Thorās Position(By moving him in respective direction) and energy level(decreases by 1). This is known as game loop.
You can read more about game loops here :
Now as for the cerr part, you must know that there are three standard streams provided:
- standard input (cin in c++)
- standard output (cout in c++)
- standard error (cerr in c++)
Here in codingame ide, you can see standard error data just above each output you give(in this case directions).
I still donāt get how much crazy are the X, Y values that you are getting. Please give examples.
Iām just trying to figure out how to keep track of his X and Y position. I tried setting up two vars;
int TX, TY;
outside of
int main()
{
and setting them to the same as initialTX, initialTY if not yet set, then incrementing + or - depending on which direction is takenā¦ and setting up a ācerrā message to print what each X, Y location is at the end of each run through the while loopā¦ but instead of getting an updated position every time it prints a direction, Iām getting multitudes of crazy X, Y values even though itās moving only once.
what exactly is going on here? I donāt understand how the rest of the program is working - how this loop is getting called/used. anybody that could fill me in on the big picture, that would help, because I had a similar problem with another game.
I think the problem is that you are not appending a new line.
After every output (STDIN or STDERR) put a \n
or endl
Other wise it will keep on printing.And btw always provide a screenshot of the problem. It helps us help you