Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 11th, 2002, 10:58 PM
Jonathon's Avatar
Jonathon Jonathon is offline
T-Shirt Tragic
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2001
Location: Melbourne, Australia
Posts: 886 Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 6 h 53 m 39 sec
Reputation Power: 320
Send a message via Skype to Jonathon
moving target algorithm needed.

Hi all,
I've started to play a game called Robocode.
It's a java game where you get to program your robot's AI to attack and avoid being attacked. ...
trouble is whenever I lock on to a target and fire, the target has moved on by the time my bullet gets to its location.

I know the target's initial location, its direction and speed.. the target's acceleration is 0.

I know my location, and the speed of my bullet... the bullet velocity is constant.

What I need to know is the approximate location of the target if it continues its course.

The closest thing I could find was a moving target equation for quake robots which involved three dimensional space, accelleration and quadratic equations .. (my math sucks).

any ideas?

Reply With Quote
  #2  
Old January 12th, 2002, 10:07 PM
dcaillouet's Avatar
dcaillouet dcaillouet is offline
Big Endian
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2001
Location: Fly-over country
Posts: 1,172 dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 16 h 29 m 5 sec
Reputation Power: 29
Go to the following link and download some of the robots and look at their source code. Squigbot v2.8 just won 6 out of 6 on my machine. You might want to take a look at its targeting.

http://robocode.diverman.com/botdownloads/page=1

Reply With Quote
  #3  
Old January 15th, 2002, 03:22 AM
Thrasher Thrasher is offline
Canta como rafaé
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Location: Barcelona
Posts: 74 Thrasher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Send a message via ICQ to Thrasher
As you say, one solution is to calculate the function that describes the last movements of the player and then guess its next position.

This function can be calculated, AFAIK, with interpolation functions like polynomials and splines. Depending of the number of points you want to sample, the function degree rises (with 4 points, it's a polynomial of degree 3, a cubic one).

With this function you can predict the next value (it would be more or less accurate depending on the separation with the last point).

You can see an active example at

http://www.wam.umd.edu/~petersd/interp.html


The problem here is how to make it useful for 3D, because in the applet you'll see that you cannot turn. Maybe it involves having an interpolation function for each axis.

I suggest you try to make this set of functions depending on time, not on pairs of axis.

pos_X (t) = prediction interpolation function in time t
pos_Y (t) = prediction interpolation function in time t
pos_Z (t) = prediction interpolation function in time t

Hope it helps
__________________
Thrasher



'Y se ahogaron los dooos
No eran duros pa pagar, cuñaaoo !!'
El vagamundo - El risitas y su cuñao

Reply With Quote
  #4  
Old February 1st, 2002, 12:18 AM
gralves gralves is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Location: Sao Paulo - SP - BRAZIL
Posts: 1 gralves User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi,

There's a simple equation that will do the trick.

Since the aceleration is 0, and it's the second time derivative of space you have this dif. eq:

d^2S
------ == 0
dt^2

The solution is :

S = S0 + V0 * t

This solution is also valid for multidimensional spaces. So, if I understood the problem right your solution would be :

Sx = S0x + V0x * t
Sy = S0y + V0y * t

where S0x is the initial position of the target projected on the x axis. V0x is its speed on the x axis and t is the time.

If you have your speed &/| position on polar form (a magnitude and an angle) you can convert to the cartesian form (the one with the x and y axis) using this expression :

x = M sin A
y = M cos A

Where M is the magnitude and A is the angle. X and Y are the cordinates on the cartesian form.

To convert back to polar form
M = sqrt ( x^2 + y^2)
A = arctg (y/x)

I hope this helps you.

Sorry for the poor english... It's not my primary language... I must have mixed up at least one mathematical term here (they tend to differ a lot between diferent languages), but I hope someone can spot it and correct if it's wrong.
Comments on this post
JimmyGosling agrees!

Reply With Quote
  #5  
Old February 2nd, 2002, 12:42 AM
Michael_Bray Michael_Bray is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Sydney, NSW, Australia
Posts: 40 Michael_Bray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Send a message via ICQ to Michael_Bray
You got the mathematical terms correct from what I read.
__________________
Cheers,
Michael Bray

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > moving target algorithm needed.

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap