Don't have an account? Register now to chat, post, use our tools, and much more.
Online Users
There are 88 users online: 4 members, 53 guests and 31 bots.
Members: don, GISdude, xologist.
Bots: VoilaBot (2), Spinn3r (1), MSN/Bing (1), Magpie Crawler (4), VoilaBot (1), Googlebot (20), MSN/Bing (2).
SAX
 » Goto page 1, 2, 3  Next
Author Message
KermMartian

Joined: 14 Mar 2005
Posts: 55764
Location: Earth, Sol, Milky Way

Posted: 22 Feb 2011 09:34:33 pm    Post subject:

souvik1997 wrote:
KermMartian wrote:
 souvik1997 wrote: Progress?
Haven't had an ounce of free time, I'm afraid. Other than that, though, I'm hoping Sunday and Monday I'll have time to work on this and Obliterate. Feel free to nag me (all of you) so I do so!

Nag.
I shall consider myself properly nagged. In the meantime, anyone want to check my equations?

> Given: fixed (x1,y1)
> Given: fixed (x2,y2)
> Given: theta

For v0, such that v0x = v0*cos(theta) and v0y = v0*sin(theta):

Q = [(cos(theta))^2]/[(x2-x1)^2]
R = a/2
S = (y2-y1) - (x2 - x1)*[sin(theta)/cos(theta)]

v0 = QR/S
_________________

qazz42

Vampire Killer

Joined: 07 Apr 2010
Posts: 4177

 Posted: 22 Feb 2011 09:38:12 pm    Post subject: err, this is off topic and noobish, but 1. what type of math is that? 2. what grade do you learn that in? my brain hurts from looking at it._________________
souvik1997

Guru-in-Training

Joined: 19 Apr 2010
Posts: 2870

 Posted: 22 Feb 2011 09:38:47 pm    Post subject: It looks like vector math._________________CALCnet Tournament-38% deviantArt
KermMartian

Joined: 14 Mar 2005
Posts: 55764
Location: Earth, Sol, Milky Way

 Posted: 22 Feb 2011 10:00:56 pm    Post subject: It's one solution to the parabolic motion equations in 2D expressed as Cartesian coordinate pairs._________________
elfprince13

OVER NINE THOUSAND!

Joined: 23 May 2005
Posts: 10234
Location: A galaxy far far away......

Posted: 22 Feb 2011 10:07:04 pm    Post subject:

 KermMartian wrote: I shall consider myself properly nagged. In the meantime, anyone want to check my equations? > Given: fixed (x1,y1) > Given: fixed (x2,y2) > Given: theta For v0, such that v0x = v0*cos(theta) and v0y = v0*sin(theta): Q = [(cos(theta))^2]/[(x2-x1)^2] R = a/2 S = (y2-y1) - (x2 - x1)*[sin(theta)/cos(theta)] v0 = QR/S

Can we get some sub-scripting for Cemetech? Also, before I check, are all the terms properly grouped for S?
_________________
StickFigure Graphic Productions || VSHI: Vermont Sustainable Heating Initiative

KermMartian

Joined: 14 Mar 2005
Posts: 55764
Location: Earth, Sol, Milky Way

 Posted: 22 Feb 2011 10:09:23 pm    Post subject: We have it, I just don't like using it for some reason. And yes, that multiplication is only for the latter term of S._________________
Pseudoprogrammer

Awesomesauce

Joined: 12 Dec 2006
Posts: 890

 Posted: 22 Feb 2011 11:03:04 pm    Post subject: I got, probably through a different method: x = x2 - x1 y = y1 - y2 V0 = sqrt(-(sqrt(((x/cos(t))^2)((sin(t)^2)+2gy))-xtan(t))/(2gy))) Visualized: C and P the whole link; Kerm's BBcode fails. http://www.wolframalpha.com/input/?i=sqrt(-(sqrt(((x/cos(t))^2)((sin(t)^2)%2B2ay))-xtan(t))/(2ay))Last edited by Pseudoprogrammer on 22 Feb 2011 11:10:35 pm; edited 2 times in total
elfprince13

OVER NINE THOUSAND!

Joined: 23 May 2005
Posts: 10234
Location: A galaxy far far away......

 Posted: 22 Feb 2011 11:09:45 pm    Post subject: Add it to the BBCode buttons list you silly thing! And I started to check it, but remembered I need to finish 2 papers tonight..._________________StickFigure Graphic Productions || VSHI: Vermont Sustainable Heating Initiative
KermMartian

Joined: 14 Mar 2005
Posts: 55764
Location: Earth, Sol, Milky Way

 Posted: 22 Feb 2011 11:19:45 pm    Post subject: Pseudo: don't forget that I'm working in z80 ASM. I have a sine and cosine lookup table of low-ish precision for theta=0 through theta=180, but square room, tangent, etc are expensive. Mine also has a sqrt, unfortunately, although I originally omitted it. I edited my post above accordingly. I'm not sure why you have so many square roots..._________________
Pseudoprogrammer

Awesomesauce

Joined: 12 Dec 2006
Posts: 890

 Posted: 22 Feb 2011 11:25:41 pm    Post subject: I used: 0 = -.5at^2 + VyT + (y2-y1) and quad formula'd it to find the amount of time T it would be in the air which is (V0sin(t) + sqrt((V0sin(t))^2 + 2a(y2-y1)))/a then I find the amount of time T it would need to be in the air to travel the X distance (which is V0cos(t) ) so: t=(x2-x1)/(V0cos(t)) set the two equations equal to each other and solve for V0.
KermMartian

Joined: 14 Mar 2005
Posts: 55764
Location: Earth, Sol, Milky Way

 Posted: 22 Feb 2011 11:28:06 pm    Post subject: That was my original approach as well, but I didn't like the square root that that required. Unfortunately, it then turned out I would need a square root anyway._________________
Pseudoprogrammer

Awesomesauce

Joined: 12 Dec 2006
Posts: 890

 Posted: 22 Feb 2011 11:30:30 pm    Post subject: How did you arrive at your solution?
KermMartian

Joined: 14 Mar 2005
Posts: 55764
Location: Earth, Sol, Milky Way

Posted: 23 Feb 2011 12:09:12 am    Post subject:

 Pseudoprogrammer wrote: How did you arrive at your solution?
I started with x2 = x1 + v0x*t = x1 + (v0*cos(theta))*t, used y2 = y1 + (v0*sin(theta))*t + 0.5*a*t^2, solved the first equation for t, and plugged it in as t in the second equation.
_________________

elfprince13

OVER NINE THOUSAND!

Joined: 23 May 2005
Posts: 10234
Location: A galaxy far far away......

 Posted: 23 Feb 2011 02:14:14 am    Post subject: Methinks we need "The (Other) Vector Thread" to stop diverting this one _________________StickFigure Graphic Productions || VSHI: Vermont Sustainable Heating Initiative
Pseudoprogrammer

Awesomesauce

Joined: 12 Dec 2006
Posts: 890

 Posted: 23 Feb 2011 10:20:57 am    Post subject: I solved the equations again using a different method and I got: sqrt((y1 + tan(t)(x2-x1) + .5a((x2-x1)^2))/(y2cos(t))) Not sure if they're equivalent.
KermMartian

Joined: 14 Mar 2005
Posts: 55764
Location: Earth, Sol, Milky Way

 Posted: 23 Feb 2011 11:46:10 am    Post subject: Doesn't seem to be equivalent. I don't think that that equation is correct; if y2 = 0, then you get division by zero, and not every equation with a final y-coordinate of zero is unsolvable..._________________
KermMartian

Joined: 14 Mar 2005
Posts: 55764
Location: Earth, Sol, Milky Way

 Posted: 24 Feb 2011 02:29:13 am    Post subject: Hmmm, here's the latest thing I came up with. Code: Gameplay_AITurn_Aim:    ; 1. Pick an alive tank    ; 1a. Set deltaX, deltaY    ; 2. Loop Theta 0 to 180, step 2*(6-Difficulty)    ; 2a. calculate Q = a/2 * deltaX    ; 2b. calculate R = deltaY * cos(theta)    ; 2c. calculate R = sin(theta)-R/deltaX    ; 2d. calculate R = Rcos(theta)    ; 2e. calculate v0 = sqrt(Q/R)    ; 2f. if 0 < v0 <= 100, fire! 1a. deltaX, deltaY are 16-bit words 2. theta is a 8-bit byte 2a. a/2 is a byte. deltaX is a 16-bit word, so Q is a 16-bit word (well, 24-bit, but it turns out a/2 = 2/2 = 1) 2b. cos(theta) is a nine-bit sign-prepended byte. deltaY is a 16-bit word. R is potentially a 25-bit (?!) word. 2c. R is, say, 24 bits (dearie me), deltaX is 16 bits, so it pains me to realize that the new R could also be 24 bits 2d. R is now 24 bits, cos(theta) is 9 bits, so the new R could be 33 FREAKING BITS 2e. Q is 16b, R is 33b, Q/R is OH GOD SAVE ME HEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEELP Edit: Split, by the way._________________
comicIDIOT

Guru

Joined: 01 May 2006
Posts: 5108
Location: SFBA, California

 Posted: 24 Feb 2011 03:49:48 am    Post subject: I can't understand the fine specifics here, but I wouldn't call this AI until each tank can assess a situation. Which tank poses a greater threat (closer tank first then most accurate tank targeting it as the game progresses)Tank knows how far off it was from an enemy tank and adjusts next turn accordinglyThis is likely for version two, if anything. From what I understood above the AI chooses a tank at random and random settings each turn. The tanks are on a master graph. Tank A at -30pxls away from the origin, Tank B at +10. Then, each Tank is at the origin of it's own graph. When Tank B fires short of Tank A the value would be, say, 13. If it overshot the value would be -6. If it was short, it'd either adjust the power up or the angle down. Even Power up*2 and angle up. Only problem is that you'd have to store values for each tank. So you'd have n-1 lists of n elements denoting accuracy on individual tanks. (-1 for a human player). But, each tank would only have access to it's own list to prevent each tank from targeting the one tank until it's dead then moving on to the next most accurate. I don't expect that last paragraph to make much sense to anyone else and it probably won't for me in a day. But, how exactly does the AI work in English?_________________ -Alex
KermMartian

Joined: 14 Mar 2005
Posts: 55764
Location: Earth, Sol, Milky Way

 Posted: 24 Feb 2011 12:30:50 pm    Post subject: You vastly overestimate how easy manipulation of all this math is in z80 assembly. I'm already suffering enough with a targetting AI; I don't feel like complicating it any more at this point. You've presented a good system, though, and one that would make sense if in the future I have more patience. At this point I'm mostly interested in getting a decent AI working, publishing a beta, and starting Direct USB gCn. And yes, it's a real AI because it adjusts the angle and power properly to hit an enemy tank. Edit: I remembered that my sin and cos are 100-scaled. Improved magnitude estimates. Code: Gameplay_AITurn_Aim:    ; 1. Pick an alive tank    ; 1a. Set deltaX, deltaY    ; 2. Loop Theta 0 to 180, step 2*(6-Difficulty)    ; 2a. calculate Q = a/2 * deltaX    ; 2b. calculate R = deltaY * cos(theta) / 100    ; 2c. calculate R = sin(theta)/100-R/deltaX    ; 2d. calculate R = Rcos(theta)/100    ; 2e. calculate v0 = sqrt(Q/R)    ; 2f. if 0 < v0 <= 100, fire! 1a. deltaX, deltaY are 16-bit words 2. theta is a 8-bit byte 2a. a/2 is a byte. deltaX is a 16-bit word, so Q is a 16-bit word (well, 24-bit, but it turns out a/2 = 2/2 = 1) 2b. cos(theta) is a nine-bit sign-prepended byte. deltaY is a 16-bit word. R is potentially a 24-bit word. R/100 is up to an 18-bit word. 2c. R is, say, 18 bits (dearie me), deltaX is 16 bits, so it pains me to realize that the new R could also be 18 bits (but probably less) 2d. R is now 18 bits, cos(theta) is 9 bits, divide by 100 first to get 12 bits for R, multiply by cos(theta) to get 21 bits or so. 2e. Q is 16b, R is 21b, Q/R is something. Q/R is half or so of that. 2a requires no code. 2b requires a 16*16 multiply and a 32/8 divide. 2c requires a 32/16 divide, a 16/8 divide, and a (?!) 32-bit addition 2d requires a 24*8 bit multiply and a 32/8 divide 2e requires a 16/24 divide and a 16-bit square root Here's the equation for reference, by the way: _________________
KermMartian

Joined: 14 Mar 2005
Posts: 55764
Location: Earth, Sol, Milky Way

 Posted: 25 Feb 2011 02:12:04 pm    Post subject: *bump* I can has partial success burger? I suspect they're just using the wrong delta-Y now. _________________
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
 » Goto page 1, 2, 3  Next Page 1 of 3 » All times are GMT - 5 Hours

 Jump to: Select a forum Announcements----------------Cemetech AnnouncementsCemetech LabsContests General Discussion----------------Technology & Calculator Open Topic-- Electronics/Hardware Development-- Calculator HardwareYour ProjectsGeneral Open Topic-- Politics & Rants-- Reviews-- Humour/Jokes Cemetech's Projects----------------Doors CSSourceCoderMember Features-- TI-Freak8x-- Merthsoft-- GrammerOther & Upcoming Projects-- The BASIC Elite-- mobileTunes-- CALCnet 2.2-- SuggestionsProgramming the TI-83 Plus/TI-84 PlusUsing the TI-83 Plus/TI-84 PlusWebsite Programming & Design----------------General Programmingz80 AssemblyTI-BASICCasio Prizm/FX Development & ProgrammingWebsite Markup & ScriptingGraphics1337 Programming Tips Building with Blocks----------------FreeBuild, LEGO, and Minecraft-- FreeBuild General-- Suggestions & Troubleshooting-- Content & Gallery-- Servers & Activities
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.041049 seconds.