[Chicago] My mind is not seeing it

T Wilson wilson.tamarrie at gmail.com
Thu Jan 17 13:10:23 CET 2013


The bug is after a person scores higher than 10 points the ball goes right
thru the paddles.  Just played it to see what's up.  Did you copy the code
and forget a section after the tenth line?

On Thu, Jan 17, 2013 at 12:12 AM, Randy Baxley <randy7771026 at gmail.com>wrote:

> It sounds like you have put me on the right track but I will likely not
> have a chance to actually look at it until Friday.  Thank you.
>
>
> On Wed, Jan 16, 2013 at 12:47 PM, Adam Bain <bainada.iit at gmail.com> wrote:
>
>> Randy,
>>
>> I don't see the bug exactly as you describe it. What I see is the ball
>> speeds up only when hitting the paddles (not when hitting the gutter, I
>> tried letting the ball hit the gutter a lot and saw no velocity increase
>> until I hit it with a paddle).  This seems to be the intended behavior as
>> you increase the horizontal component of the velocity by 10% each time
>> theres a paddle hit.
>>
>> ball_vel[0] = ( -ball_vel[0] ) * 1.0
>>
>> This horizontal speed does not get reset in magnitude after a point is
>> scored but it does get reversed (this doesn;t really affect the bug, but I
>> can't really tell if this is intended) :
>>
>> else:
>>             ball_vel[0] = ( -ball_vel[0] )
>>
>> To get to the meat of the bug though, what is happening is that you are
>> multiplying up the magnitude of the horizontal by 1.1 each hit (e.g 4,.4.4,
>> 4.84, ~5.32, ~5.86, ~6.44, ~7.09). As you noted this does eventually go
>> above 7, but consider what the code does in that situation.
>>
>> if ( ball_pos[1] <= bottom1 ) and ( ball_pos[1] >= top1 ): # You hit left
>> paddle
>>     # increase abolute velocity 10 percent but to no more than 7
>>             print ' hit paddle '
>>             if abs( ball_vel[0] ) < 7:
>>                 ball_vel[0] = ( -ball_vel[0] ) * 1.1
>>
>> This means that when the paddle is lined up for a hit, it will pass the
>> first if, print the 'hit paddle' and then fail the second if condition,
>> which means the ball never gets reversed.
>>
>> To the second part of your question, I assume you are asking why this
>> eventually gets counted as a point.  This is simply because as the ball
>> goes through the paddle, it will eventually no longer satisfy the first if
>> condition of being between the two paddle boundaries (especially since ht
>> user wont be able to see the ball anymore) and will fall through to the
>> else, which will run the 'point scored' code,
>>
>> There are a couple of simple ways to close this bug (depending on how
>> strictly you want to enforce the 7 speed limit), but rather than spelling
>> them out for you hopefully, this helps you getting on the right track to
>> coming up with a solution. Post back if you're still having trouble.
>>
>>
>> Adam Bain
>>
>>
>> On Wed, Jan 16, 2013 at 11:41 AM, Randy Baxley <randy7771026 at gmail.com>wrote:
>>
>>>
>>> Would someone play this game and tell me why towards the end the ball
>>> speed increases when hitting the gutters and fails the test when hitting
>>> the paddles and then passes the test?
>>>
>>> http://www.codeskulptor.org/#user8-paYp6vO6lS-19.py
>>>
>>> TIA,
>>>
>>> Randy
>>>
>>> _______________________________________________
>>> Chicago mailing list
>>> Chicago at python.org
>>> http://mail.python.org/mailman/listinfo/chicago
>>>
>>>
>>
>> _______________________________________________
>> Chicago mailing list
>> Chicago at python.org
>> http://mail.python.org/mailman/listinfo/chicago
>>
>>
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20130117/0a626155/attachment.html>


More information about the Chicago mailing list