Tuesday, April 12, 2011

That is a Pesky 'Lil Bugger!

When dissecting bug #4 for a decent plan of attack, I focused on making a clean solution that would insert an additional message for the condition where a player entered the correct AMOUNT but not the correct combination of (fewest) coins.  Once I found my culprit (where the comparison was being made) and the destination of the event messages I was well on my way.  My group and I discussed on Thursday our ideas as to what we thought was the best way to handle it and I went off—with my rusty Python skills—and started working with it.  It didn’t take long to get what we had perceived to be the problem fixed and working as we had discussed.  I did have to create a new method that calculated if the "amount only" was correct--otherwise I was injecting a different comparison in a defined method.  Once I was satisfied my code was working correctly I went ahead and committed my fix so that everyone in my team could have a shot at it before the weekend took everyone’s attention. 
Feeling satisfied I then went back and played the game with the express purpose of testing it (kind of hard because the game injects random events that play havoc with those profits—making me have to wait for it to give me the figures that I needed to test…so I just played and documented my input values at each turn.  After a while I came up upon some combinations that slipped through the cracks…for example, if you had a profit of $8.05 the code won’t allow you to use…Dollars: 8 and Pennies: 5 because it is looking for Dollars: 8 and Nickels: 1…..however, if you have something like $9.80…you can fool the game by typing in…Dollars: 9, Quarters: 3 and Pennies: 5 and it will accept the amount.  While this is the correct amount, to satisfy the fewest coins principle it should have been Nickels: 1 instead of Pennies: 5.  What I discovered is that if  you have an amount that uses 2 of the 3 top coins (dollars, quarters or dimes) then you can cheat and use 2 nickels OR 1 nickel and 5 pennies to make a dime or 10 pennies to make a dime, etc....but if you have something using like 50 cents or $1.10 it won't let you cheat

I’m not sure where to go from here…I have not been able to decipher how he is figuring out the calculation of “fewest coins possible” which is really slowing down my progress.  I am satisfied with the solution that I have to our bug, but it appears to me that we have uncovered a different bug in the process.  We’ll discuss it at out meeting time today…maybe we should contact Nathaniel to see if it is something he intended or not (to be able to exchange nickels or pennies in certain circumstances)…anyway it is something to think about anyway.  Overall I’m not too disappointed, but would rather have had every transaction as fewest coins possible or every transaction accept the correct amount…but that’s just me.

No comments:

Post a Comment