ViZDoom
ViZDoom copied to clipboard
hard time using delta movements
Hi! So I'm trying to move a player using the delta move left right, and the forwards backwards keys. basically the purpose is to move while rotating. I've started with rotating a bit then trying to move parallel to the y axis. Using the player angle from the game variables, with some simple sin cos. problem is, it doesn't really move as it should. I don't know what it is, I've printed the vectors and they are correct. when I want to move in a 45 degree angle, it works. but as soon as I add a little bit of rotation it messes up. Did someone encounter the same issue?
using build 1.1.8 on windows (basic.py)
Hi @TheNamesItay, I think it's not an issue, delta buttons basically move agent each tic with respect to its current position and rotation, so if you combine TURN_LEFT_RIGHT with MOVE_LEFT_RIGHT or MOVE_FORWARD_BACKWARD, you should expect an arc kind of movement. If you include the example, I can confirm if it works as expected. I'm not sure from your description, what type of movement you want to achieve exactly, but probably you should interweave actions with TURN and MOVE.
Thanks for answering @mwydmuch! the thing is, there is no arc its just not moving in the angle I expected. included here is the example, sorry if its super messy as its just a play around file, tried to tidy it up a little. basically when the episode starts it calls move_test() which rotates for a few ticks and then it's supposed to move only on the y axis. after that it displayed the movement on a graph. Could you run it just once to see if it makes sense?
Hmm I ran the example and based on what you wrote it works as expected (turns a little and then only moves on one axis). I was not able to plot out results though because I have an older version running (haven't updated Python to correct sub-version for Windows binaries), so I base my observation on how the character moved.
Could you clarify what the results should look like vs. what we are getting now?
Yeah sure! so after moving the output was:
angle from start: -- 174.06928932420016 angle from last: -- -95.92932088410332 diff on X axis: -1.41937255859375 diff on Y axis: -13.666580200195312
diff from START X axis: -11.549514770507812
diff from START Y axis: -111.17948913574219
expected:
angle from start: -- -540 (-180 basically) angle from last: -- -90 diff on X axis: 0.0 diff on Y axis: -16.664016723632812
diff from START X axis: 0.0
diff from START Y axis: -135.40740966796875
there is still some unwanted movement on the X axis (moved around 11.5 units for some reason).
I also checked the example and it works correctly. You rotate the agent by 20 degrees first (in first 20 ticks) and after this based on the agent's angle (340 degrees) you move only left-right and forward-backwards for the rest of the episode, the angle stay the same so this will not generate arc-like/sine/cosine movement.
One unit in Doom is a very small measurement so I think we might be looking at random noise (or computation errors) from the environment here. Also note that that movement includes acceleration, so you can not immediately stop or go at full speed, which causes problems when moving.
@mwydmuch yes I know, what im trying to achieve is going in a straight line regardless of the players angle. in this example the goal is to only move on the y axis, which for some reason i cant manage.
ugh, @Miffyli that was the answer i was hoping i would not get. i doubt its noise though, as its walking in a straight line on the whole path. so for every single movement the offset angle is the same.
@TheNamesItay, now I understand what you are trying to achieve. Unfortunately, it may be a bit tricky due to how the Doom engine works. MOVE_LEFT_RIGHT and MOVE_FORWARD_BACKWARD pass "target velocity" value to the engine. First, the agent accelerates to that velocity (it takes few ticks), when it reaches the target velocity it keeps it. There is also a friction parameter of the surface that cause deacceleration. The whole physics of the engine is very arcade-ish. Another problem is that Doom engine uses ints for many of its calculations, and the values of delta buttons are rounded to ints at some point, probably losing the required precision for your task.
@TheNamesItay I'm don't know what kind of task you are trying to implement, but maybe you should try to do it in ACS script. This will allow you to move the agent directly to the calculated coordinates.
right now im just playing around trying to get familiar with the system for an upcoming ai project, the goal for now is to make rotation and movement sort-of independent of each other (for example following a trajectory while aiming on enemies), basically like how a tanks turret is independent. are acs scripts legal in the competitions? just out of curiosity
@mwydmuch (forgot to @)
@TheNamesItay ACS scripts aren't allowed in the competitions, they're part of the map and map for the competition is always provided and can't be modified. If you want to make an agent moving like a tank and you can accept some inertia and inaccuracy, I believe your approach is a good one. It'll work better with higher velocities since rounding is less significant then. If you change -5 and 5 in this line do([0,0,0,0, -5 * sin(state.game_variables[3]), 5 * cos(state.game_variables[3])])
to some higher values, you'll see that it behaves more as expected.
@mwydmuch yeah you're right! I replaced it with some greater values and it was way more accurate. I'm kinda worried that's a bit much for normal gameplay, but I guess ill figure it out. thank you a lot, @mwydmuch and @Miffyli.
Closing this issue, because it was answered.