The Daily Click ::. Forums ::. General Chat ::. Math equations & A.I.
 

Post Reply  Post Oekaki 
 

Posted By Message

eyeangle



Registered
  12/06/2003
Points
  1683
28th February, 2008 at 03:40:28 -

Is there a mathematical equation for anything to do with AI in video game?

For example, just recently I was told that to make an object float up and down it equal:
Set Y positiion to 380+(Sin(timer/2)*3)

Could you use a single equation to make a bird fly around the sky and swoop down to get you when you're close?
Or have a man walk around and shoot at you when you are near?

Could you say that anything can be down in a game with 1 single equation/forula?

 
theonecardgame.com

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
28th February, 2008 at 04:07:03 -

Is that a trick question?

Well, I think for the floating object, you could replace any of the numbers there. The '2' can be changed to change frequency, 3 for distance, 380 for initial value.

Assuming 640*480 resolution...


Could you use a single equation to make a bird fly around the sky and swoop down to get you when you're close?


Equation for the floating, swooping or detecting?

Floating:
Set Y position to 20+(Sin(timer/2)*3)
Set X position to 320 + (Sin(timer/10)*100)

Swooping:
(disable above actions)
Set Y position to 20+Abs(timer-5)*30 -> five second swoop if your timer is in seconds

Detecting:
Um.. XPosition("Bird") + 20 > XPosition("You") AND XPosition("Bird") - 20 < XPosition("You")



Or have a man walk around and shoot at you when you are near?


Walk around: See 'floating' above.

Detecting: Sqrt((XPosition("Man")-XPosition("You"))pow 2+(YPosition("Man")-YPosition("You"))pow 2) is < 100

Shoot:
Create bullet at action point of Man
Always: Bullet looks at You. Set speed to 100. (There's your 360 degree bullet movement )



Could you say that anything can be down in a game with 1 single equation/forula?


If only everything in life could be done with just one formula... Nope, see "Floating" above. Two formulas


Haha, I was writing an article on using formulas to do stuff. But I got lazy drawing all the graphs and examples and stuff. Maybe I'll do it now, seeing that there's at least one person who'll read it

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
28th February, 2008 at 04:13:19 -

Lol, that was longer than it should be. When I start spouting random formulas like that, it's time to get back to work on my game or write an article I'll point to the next time someone starts a thread like this

Warning: Formulas untested, use at your own risk.

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
28th February, 2008 at 04:54:00 -

in other news. NO. theres no such thing as a single formula ai unless you want it to do a single simple task.
when you get into flying, swooping when near, etc. you have to seperate them so the ai works right.
also. not everyhing can be reduced to formulas. formulas usually define a limited function. linear, waves, quadratics, etc.
programming ai behaviours is different, but may include formulas/functions.

 
n/a

eyeangle



Registered
  12/06/2003
Points
  1683
28th February, 2008 at 05:41:15 -

Thanks Muz!

Your article on formulas would be so helpful! I have 12 different enimies (well 11 now) that I need forulas for and I have no idea what they are. So that article would be great.

I tested you formulas above and the Man one works perfectly but the bird suddenly disappears when it swoops. But it floated properly. And for the bird detecting I just used the detecting for the man you wrote because sometimes you're above it or any direction of it.

 
theonecardgame.com
   

Post Reply



 



Advertisement

Worth A Click