One problem here is that you are comparing a number that is basically unbounded with a number generated as a percentage. If the difference between them is, say, 100, then perc will always be less than diff.
If you want to compare against a percentage, you need to find some way of normalizing the difference between their "dodge scores" to be comparable to the percentage roll. This isn't really a programming problem, it's a design problem. You have to make sure that you're coming up with a difference that makes sense to compare. Your differences are on an entirely different scale than your die roll.
You should work out a few cases by hand where you write out the speed and agility of each, then run those through your formula to get their "dodge scores", compute the difference, and then see what the numbers are like as you scale input variables. This will give you a feeling for how to normalize the difference against the percentage. You can do this by graphing the difference along the x axis, and the normalized number on the y axis. Make sure to always express things the same way, e.g., always trying to figure out if the attacker succeeds, or always trying to figure out if the defender succeeds. This will help you get your signs right.
Basically, you need to work this out by hand and see what the numbers actually are, and not try to write formulas until you understand how the numbers and signs interact.
.........................
David Haley
Head Coder, Legends of the Darkstone
BabbleMUD Project
http://david.the-haleys.org