On Sat, Dec 08, 2001 at 06:25:38PM -0800, Trent Piepho wrote: >On Sat, 8 Dec 2001, Mark Mielke wrote:>> Unfortunately, the problem still remains: (Range is -1000..999)>> -1000, -800, -600, -400, -200, 0, 200, 400, 600, 800>> 5 4 3 2 1 0 1 2 3 4>> This time, however, after Trent's correction, the issue is somewhat>> reduced. Instead of the extra location being 1 of 4 positions, it is>> 1 of 10 positions. The client may draw the ship up to 5 pixels left>> or up from the actual location, but only 4 pixels down or right from>> the actual location.>You are still wrong here. Each of those 10 positions isn't equally likely.>If the random number is 0-199, you get 0 pixels off. If it's 200-399 you get>1 pixel right. The only way to get 5 pixels left, is if the random number is>exactly -1000. Four pixels to the left is 200 times more common than>5 pixels to the left. You are only going to get the 5 pixel case off>0.05% of the time.Rounding is down, not 'towards 0'. Their is 1/10 chance that the number will be -1000..-801. Correct? That entire range is -5 pixels. The next range is -800..-601, and is -4 pixels. -600..-401 is -3 pixels, -400..-201 is -2 pixels, -200..-1 is -1 pixel, 0..199 is 0, 200..399 is +1 pixel, 400..599 is +2 pixels, 600..799 is +3 pixels, 800..999 is +4 pixels. There is one more possibility out of 10 that the ship will show up far to the left on the X axis, and one more possibility out of 10 that the ship will show up far to the top on Y axis. (This, suggesting that there is a 1 in 100 chance that the ship could show up 7 pixels distance to the topleft, but only a 1 in 100 chance that the ship could show up 5.6 pixels distance to the bottomright) Out of 100 possible positions (10x10), that the ship could equally be displayed at, 1 position is accurate, 16 positions are in the bottom right sector, 10+10-2=18 positions are on an axis, 100-1-16-18=65 positions are in the other 3 sectors. 3x16=48. 48 is quite shy of 65. >You also aren't taking into account that the initial position of the ship>isn't going to be 0. You might have it be 1 or 199, in which case the>rounding comes out differently.This is the argument that invalidates my argument. If the position is +100, it is already 1/20 chance of being -5, and 1/20 of being +5. If the position is +199, ~1/10 chance of being +5 and ~0 chance of being -5, etc. Hmm... mark -- mark at mielke.cc/markm at ncf.ca/markm at nortelnetworks.com __________________________ . . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder |\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ ||| | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, CanadaOne ring to rule them all, one ring to find them, one ring to bring them all and in the darkness bind them... http://mark.mielke.cc/