| Author |
Message |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Thu Sep 15, 2005 12:35 am Post subject: |
 |
|
|
|
| don't rely on a website to do math for you. You can learn it off a website and then apply it to your problem. That's how it's meant to be done anyways |
|
| Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:35 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Thu Sep 15, 2005 4:15 pm Post subject: |
 |
|
|
|
| Yes, Im trying to do that. I know the math, but I'm having trouble putting it in the code... I have almost no idea how to do this besides making an equation.. I'm just trying to. |
|
| Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:42 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
|
| Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:35 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Thu Sep 15, 2005 11:03 pm Post subject: |
 |
|
|
|
| is that a built in function? |
|
| Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:35 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Thu Sep 15, 2005 11:04 pm Post subject: |
 |
|
|
|
ty for the help  |
|
| Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:35 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Fri Sep 16, 2005 3:07 pm Post subject: |
 |
|
|
|
hey lol id you make that up yourself? looks cool lol seriously im looking up some things in that code to learn how it works hehe |
|
| Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Fri Sep 16, 2005 3:42 pm Post subject: |
 |
|
|
|
(shakes head)
stop triple posting. And only post relevant things, not "cool" |
|
| Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:35 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Fri Sep 16, 2005 3:49 pm Post subject: |
 |
|
|
|
lol sorry
(oops i did it again :/ ) |
|
| Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:35 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Fri Sep 16, 2005 5:28 pm Post subject: |
 |
|
|
|
| um.. im supposed to fill in the coords and stuff right? |
|
| Back to top |
|
 |
Muskrat Server Help Squatter

Age:38 Joined: Aug 24 2004 Posts: 829 Location: Swamp Offline
|
Posted: Fri Sep 16, 2005 5:47 pm Post subject: |
 |
|
|
|
| That would have been a perfect opportunity to use the edit button. |
|
| Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:42 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Fri Sep 16, 2005 11:10 pm Post subject: |
 |
|
|
|
| Quan Chi2 wrote: | | hey lol id you make that up yourself? looks cool lol seriously :P im looking up some things in that code to learn how it works hehe |
Yes. A simple google search on polar to rectangular returned the exact math you needed. The original idea is what I posted back in my first message in this thread.
| Quan Chi2 wrote: | | um.. im supposed to fill in the coords and stuff right? |
You'll need fill in three values, CircleX, CircleY, and Radius. These should be known values of the circle you want to warp into, as that is what you mentioned in the very first post. The XCoord and YCoord doesn't need to be set to anything, as the function sets the return values there.
Example usage:
int x,y;
PickRandomSpotInCircle(512, 512, 10, x, y);
sendMessage(playerID, "*warpto %d %d", x, y);
The sendMessage is different for each bot core. I don't use MERV at all, thus I don't know if it supports formatting or you guys just use the string class everywhere. |
|
| Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:35 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Fri Sep 16, 2005 11:25 pm Post subject: |
 |
|
|
|
ok.. i see what you're saying. in the first post i just didnt understand. i had done a google search on polar to rectangular but i didnt understand the math.. not quite at that level yet Thank you very much for the help |
|
| Back to top |
|
 |
Underlord Novice
Gender: Joined: Feb 17 2004 Posts: 55 Offline
|
|
| Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
| Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:42 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Sun Sep 18, 2005 10:48 pm Post subject: |
 |
|
|
|
rand() is not a truly random number. The high-order bits are requested to be more random than the lower bits by the official standard. For the most part, most system's rand() is good enough that you can just mod the number you want, but to get a more random number, you should use the high-order bits, which involves using the methods Underlord and I both posted.
Doing a quick test on the standard deviation of rand() on different amounts with different sample sets shows that both methods on Windows 2000's stdlib work almost identical. On other system's implementation of rand, it maybe different.
And in the case of speed, the bot is usually not trying to be real-time, and spends most of its time idling. So in this case, its better to error on the side of more accurate than speed. And in the case where you are using the string class, the speed between these methods is the least of your worries. |
|
| Back to top |
|
 |
Underlord Novice
Gender: Joined: Feb 17 2004 Posts: 55 Offline
|
Posted: Wed Sep 21, 2005 4:48 am Post subject: |
 |
|
|
|
| Quote: | Do NOT use
y = rand() % M;
as this focuses on the lower bits of rand(). For linear congruential random number generators, which rand() often is, the lower bytes are much less random than the higher bytes. In fact the lowest bit cycles between 0 and 1. Thus rand() may cycle between even and odd (try it out). Note rand() does not have to be a linear congruential random number generator. It's perfectly permissible for it to be something better which does not have this problem. |
|
|
| Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Wed Sep 21, 2005 11:47 pm Post subject: |
 |
|
|
|
learn something new every day...
This actually came up a day after reading MGB's responce. I made a c program for a microcontroller and it was supposed to chose a random color for a bi-color LED, red or green. However, it chose red 95% of the time. Thinking about what mgb said, I changed
to
and it finally started picking green a lot more. Funny how this doesn't come up in years of programming until the day after someone tells it to you. Another option I was considering was to load an array with like 5 red and 5 green values, then doing a random shuffle on the data, so for any 10 tries you'd get 5 reds and 5 greens, but the order would be random. |
|
| Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Sep 22, 2005 10:39 am Post subject: |
 |
|
|
|
On all of the uCs I've programmed there hasn't been a rand() so I've always had to write my own psudeo-random number generator. Usually just a shift and xor does the trick. _________________ 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:35 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Sat Sep 24, 2005 12:43 am Post subject: |
 |
|
|
|
| why did Underlord include time.h? |
|
| Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Sat Sep 24, 2005 12:51 am Post subject: |
 |
|
|
|
| Probably because he used a function in time.h. Just a guess... |
|
| Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:35 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
Posted: Sat Sep 24, 2005 1:17 am Post subject: |
 |
|
|
|
| lol.. funny |
|
| Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
| Back to top |
|
 |
Maverick

Age:41 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
|
| Back to top |
|
 |
Quan Chi2 Member of "Sexy Teenagers that Code" Group

Age:35 Gender: Joined: Mar 25 2005 Posts: 860 Location: NYC Offline
|
|
| Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Sun Oct 23, 2005 8:41 pm Post subject: |
 |
|
|
|
| Yes, your bot will say exactly (no replacement) "*warpto X Y" The server doesn't know how to warp a player there. |
|
| Back to top |
|
 |
|