3 registered members (NewbieZorro, TipmyPip, 1 invisible),
19,045
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Mathmatical AI vectory question?
[Re: Error014]
#206720
05/15/08 09:24
05/15/08 09:24
|
Joined: Nov 2004
Posts: 862 Australia
DavidLancaster
OP
User
|
OP
User
Joined: Nov 2004
Posts: 862
Australia
|
Your first attempt Error014 really confused me, I don't think it needs to be complex but you gave me the basic idea of calculating where the ball and player will be.  I'm sorry for confusing you, but math-wise, that approach should be pretty okay, I think! Maybe if you could put your confusion into specific questions, I could help you? Honestly, it's actually not that hard. If you understand the graphics and the general concept, you can pretty much take the rest for granted, as thats just "putting it in math-speak" and then getting the proper conditions for "t". I know that it looks confusing, but isn't it at least worth a try? You just need to convert the last line into script (by which I mean: replace "|v_b|" with "vec_length(v_b)", and "x²" with "x*x"), but then, you should have a working piece of code! It's not a guarantee, mind you, but I still don't see a rpoblem with the math, and I do think that its worth a try. We can try simplyfing it when we find that it works generally. Found some time to test out your code error, couldn't get it to work, thanks for all your effort. Let me know if you see anything wrong with the code:
my.time_to_ball = (sqrt(-pow(ball_ent.x,2) * (pow(ball_velocity.y,2)-pow(vel_p,2))+ 2*ball_ent.x*(ball_ent.y*ball_velocity.x*ball_velocity.y + my.x*(pow(ball_velocity.y,2) - pow(vel_p,2)) - my.y * ball_velocity.x*ball_velocity.y)-pow(ball_ent.y,2)*(pow(ball_velocity.x,2)-pow(vel_p,2)) - 2*ball_ent.y*(my.x*ball_velocity.x*ball_velocity.y-my.y*(pow(ball_velocity.x,2)-pow(vel_p,2))) - pow(my.x,2)*(pow(ball_velocity.y,2)-pow(vel_p,2))+ 2*my.x*my.y*ball_velocity.x*ball_velocity.y - pow(my.y,2)*(pow(ball_velocity.x,2)-pow(vel_p,2)) ) - pow(my.x,2)*(pow(ball_velocity.y,2)-pow(vel_p,2)) + 2*my.x*my.y*ball_velocity.x*ball_velocity.y - pow(my.y,2)*(pow(ball_velocity.x,2)-pow(vel_p,2)) );
|
|
|
Re: Mathmatical AI vectory question?
[Re: DavidLancaster]
#206797
05/15/08 18:59
05/15/08 18:59
|
Joined: Jul 2002
Posts: 3,208 Germany
Error014
Expert
|
Expert
Joined: Jul 2002
Posts: 3,208
Germany
|
Uhm. Well. Err.
Okay, so I had to trick the forum by clicking on "Quote", just so I got the complete line.
I then tried to check it and got confused about a billion times. I think there was a mistake, though, but I can't be sure.
I did a quick Replace on it on Notepad .... probably the same you did .... and this is what I got. I'm not putting it in code-tags since that will cut part of the line.
(sqrt( - pow(ball_ent.x,2) * (pow(ball_velocity.y,2)-pow(vel_p,2)) + 2*ball_ent.x*(ball_ent.y*ball_velocity.x*ball_velocity.y + my.x*(pow(ball_velocity.y,2) - pow(vel_p,2)) - my.y * ball_velocity.x*ball_velocity.y) - pow(ball_ent.y,2)*(pow(ball_velocity.x,2)-pow(vel_p,2)) - 2*ball_ent.y*(my.x*ball_velocity.x*ball_velocity.y-my.y*(pow(ball_velocity.x,2)-pow(vel_p,2))) - pow(my.x,2)*(pow(ball_velocity.y,2)-pow(vel_p,2)) + 2*my.x*my.y*ball_velocity.x*ball_velocity.y - pow(my.y,2)*(pow(ball_velocity.x,2)-pow(vel_p,2)) ) - ball_ent.x*ball_velocity.x - ball_ent.y*ball_velocity.y + my.x * ball_velocity.x + my.y*ball_velocity.y )/(pow(ball_velocity.x,2)+pow(ball_velocity.y,2)-pow(vel_p,2))
Huh.
I assumed:
s_b = ball_ent.x s_p = my.x v_p = A positive number holding the length of the velocity-vector of the player (i.e., how fast can he run) v_b = ball_velocity.x
If its not working, it might be because one of those values is wrong...
(or maybe we're leaving acknex variable-range)
No idea if its true, no idea if its going to work. A computer actually solved that mathematical line for me. I only thought up the approach.
Perhaps this post will get me points for originality at least.
Check out Dungeon Deities! It's amazing and will make you happy, successful and almost certainly more attractive! It might be true!
|
|
|
Re: Mathmatical AI vectory question?
[Re: Error014]
#206914
05/16/08 14:17
05/16/08 14:17
|
Joined: Apr 2008
Posts: 235 TEXCOORD3
Foxfire
Member
|
Member
Joined: Apr 2008
Posts: 235
TEXCOORD3
|
Just use simple calculus: set the players direction to a Euler angle equal to dy/dx of the ball's path. Can't get easier than that.
Last edited by Foxfire; 05/16/08 14:18.
http://www.groundtacticsgame.com/Alienware m17x R Custom laptop specs: Intel Core 2 Extreme Quad CPU Q9300 2x Nvidia 280GTX 2GB vram 6GB ddr3 memory@ 1333Mhz 512GB SSD 1200p 17' screen runs Crysis Warhead on max settings at 1200p at 90 fps
|
|
|
Re: Mathmatical AI vectory question?
[Re: Foxfire]
#214558
07/05/08 11:19
07/05/08 11:19
|
Joined: Nov 2004
Posts: 862 Australia
DavidLancaster
OP
User
|
OP
User
Joined: Nov 2004
Posts: 862
Australia
|
Just use simple calculus: set the players direction to a Euler angle equal to dy/dx of the ball's path. Can't get easier than that. That sounds easy, I'd have no idea how to code that though, any ideas? Thanks!
|
|
|
Re: Mathmatical AI vectory question?
[Re: DavidLancaster]
#214615
07/05/08 18:49
07/05/08 18:49
|
Joined: Jan 2007
Posts: 2,247 Deutsch Niedersachsen
Puppeteer
Expert
|
Expert
Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
|
i have coded a solution but it wont work because i use a linear ball speed... (EDIT: and my solution is still unfinished yet)
Last edited by Puppeteer; 07/05/08 18:50.
|
|
|
|