Author |
Message |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Mon Sep 12, 2005 9:32 pm Post subject: Warping multiple times in a specific radius |
 |
|
|
|
How would I specify a certain number of tiles to warp randomly in on a command?
Like...
Just tell me how to specify the radius in this case, please..
I want to try to code the rest myself..
TY in advance... |
|
Back to top |
|
 |
Muskrat Server Help Squatter

Age:38 Joined: Aug 24 2004 Posts: 829 Location: Swamp Offline
|
Posted: Mon Sep 12, 2005 9:39 pm Post subject: |
 |
|
|
|
I dont think you explained it very well, but if you want it to be warped somewhere randomly within that region, you need to come up with a way to check if a point is in it. For a square it would be much easier, just get a random x between x1 and x2, and likewise for y. Or, you could specify a center tile and add or subtract a random amount of tiles within 0 and the radius. |
|
Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Mon Sep 12, 2005 10:01 pm Post subject: |
 |
|
|
|
I mean.. like... I do want to make it square.. So you're saying to get a random number? and then how would I specify the coords around the random number?
What command in other words.. I can get a random number, but how could I tell the bot what coords are around the number i specified? Is that a good enough explaination? |
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:41 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Mon Sep 12, 2005 10:28 pm Post subject: |
 |
|
|
|
If you want to pick a random spot inside of a circle, you choose two random values. One value is anywhere between 0 and the radius of the circle. The next value is anything between 0 and 2*pi. Now, using trigonometry, convert those polar coordinates into rectangular. Then add those X and Y values to the center point of the circle.
To help you learn this, I'll leave out the math for converting polar to rectangular. Use google or a math book to work that one out. |
|
Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Mon Sep 12, 2005 10:47 pm Post subject: |
 |
|
|
|
k ty.. lol i never took this before except basic trig  |
|
Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Mon Sep 12, 2005 11:03 pm Post subject: |
 |
|
|
|
jeeeeeeeeeeeeeeeeeeeesus this math is crazy.... this must be like advanced trig.. wtf loll... i'll get through it |
|
Back to top |
|
 |
Muskrat Server Help Squatter

Age:38 Joined: Aug 24 2004 Posts: 829 Location: Swamp Offline
|
Posted: Mon Sep 12, 2005 11:49 pm Post subject: |
 |
|
|
|
I suggest going with a square for now which will be much easier until you learn the polar to rectangular coordinates...
Get two random numbers between your radius and the negative value of your radius, then just add one to the x-coord and one to the y-coord and you've got a random spot in the square. |
|
Back to top |
|
 |
SamHughes Server Help Squatter

Joined: Jun 30 2004 Posts: 251 Location: Greenwich Offline
|
Posted: Tue Sep 13, 2005 12:05 am Post subject: |
 |
|
|
|
Mine GO BOOM wrote: | If you want to pick a random spot inside of a circle, you choose two random values. One value is anywhere between 0 and the radius of the circle. The next value is anything between 0 and 2*pi. Now, using trigonometry, convert those polar coordinates into rectangular. Then add those X and Y values to the center point of the circle.
To help you learn this, I'll leave out the math for converting polar to rectangular. Use google or a math book to work that one out. |
This method isn't very evenly distributed. Provided your values in [0, r) and [0, 2*pi) are evenly distributed, a given area at distance x from the center will get twice as many 'darts' as an equally sized area at distance 2x from the center.
If an even distribution mattered (I actually like your distribution better, but I might as well mention...), I'd use rectangular coordinates where x ranges in [-r,r] and y ranges in [-r,r] and pick random coordinates until x*x + y*y < r*r.
MGB's distribution gives an average radius of r/2, with a denser distribution near the center point, while the even distribution gives an average radius of 2r/3. |
|
Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Tue Sep 13, 2005 7:32 am Post subject: |
 |
|
|
|
Smart.
Last edited by Quan Chi2 on Tue Sep 13, 2005 9:35 pm, edited 1 time in total |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Tue Sep 13, 2005 9:42 am Post subject: |
 |
|
|
|
no we're not. It's the pathagareon theorm (distance formula). r = sqrt(x^2 + y^2). All he did was sqaure both sides to speed up calculating it on the computer (r^2 = x^2 + y^2) |
|
Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Tue Sep 13, 2005 3:52 pm Post subject: |
 |
|
|
|
lol i learned that! :d last year i didnt think that i would ever have to use it again :/
pfft lol |
|
Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Tue Sep 13, 2005 3:55 pm Post subject: |
 |
|
|
|
k now what commands/functions am i using here? I have to get a radom number, that I know.. but what other commands am i using? I saw the antiwarp src on Distort's site.. and it said 'radius'.. will i have to use something like that? is radius a built in command? |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Tue Sep 13, 2005 3:57 pm Post subject: |
 |
|
|
|
no you'll have to use variables. Find a good c++ reference online or in book form. |
|
Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Tue Sep 13, 2005 8:59 pm Post subject: |
 |
|
|
|
k  |
|
Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Tue Sep 13, 2005 10:31 pm Post subject: |
 |
|
|
|
I'll have to include the math header file right? |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Tue Sep 13, 2005 11:26 pm Post subject: |
 |
|
|
|
for what? |
|
Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Wed Sep 14, 2005 12:15 am Post subject: |
 |
|
|
|
i dunno... im trying to figure out how to make exponents in the code lol.. im reading C++ for dummies  |
|
Back to top |
|
 |
SamHughes Server Help Squatter

Joined: Jun 30 2004 Posts: 251 Location: Greenwich Offline
|
Posted: Wed Sep 14, 2005 12:56 am Post subject: |
 |
|
|
|
You don't need exponents to square a number.
What would you need exponents for? Anyway, if they're double-precision approximations of numbers, you'd use the function pow; if they're integers, you could make your own function if you wanted. |
|
Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Wed Sep 14, 2005 7:30 am Post subject: |
 |
|
|
|
k ty |
|
Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Wed Sep 14, 2005 5:45 pm Post subject: |
 |
|
|
|
um...
int radius;
Sqrt (4*4) + (3 * 3);/*Pythagorean Theorem read from a website*/
i have a strong feeling that im doing this wrong :/
I don't mean to be annoying.. i've just never done this before :/ Im looking through references though.
I'll learn by trial and error I guess.. But am I doing it wrong? |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Wed Sep 14, 2005 5:46 pm Post subject: |
 |
|
|
|
In a word, yes. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Wed Sep 14, 2005 6:04 pm Post subject: |
 |
|
|
|
yesss wait.. noooo... Wait you mean its correct? or is it not? |
|
Back to top |
|
 |
Muskrat Server Help Squatter

Age:38 Joined: Aug 24 2004 Posts: 829 Location: Swamp Offline
|
Posted: Wed Sep 14, 2005 6:10 pm Post subject: |
 |
|
|
|
Not. |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Wed Sep 14, 2005 7:01 pm Post subject: |
 |
|
|
|
Quan Chi2 wrote: | yesss wait.. noooo... Wait you mean its correct? or is it not? |
You asked if you were doing it wrong. I said yes. Draw your own conclusion. |
|
Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:34 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Wed Sep 14, 2005 9:31 pm Post subject: |
 |
|
|
|
lol k |
|
Back to top |
|
 |
|