# dvogel

Member

38

1. ## QT tutorials?

Look into QGraphicsScene.
2. ## So, I want to send a struct...

If you know that the server and client are always on the same machine, you could store the structs in shared memory.
3. ## Where should/shouldn't polymorphism be used?

The amount of code that the vtable eliminates makes up for any speed penalty you will incur. In other words, you will likely have to perform the performance equivalent of a vtable lookup elsewhere in your code to accomplish the task at hand (e.g. by adding a conditional to check object type, etc).
4. ## Dynamically Weighted Probabilities?

I understand your point about the slopes of each line segment. I've been trying to decide whether it would be better to just use constant slopes of 0.5 and -0.5 and use the weapon proficiency (which would then be a range of -0.5 to +0.5) to adjust the damage value after selecting the damage value. e.g. for a range of 4-11 and a weapon proficiency of -0.25, I would select a random number between 0-7 (e.g. 6), then adjust by (11-4)*-0.25=1.75, giving me a damage value of 4.25. The math behind this is much simpler, more straight-forward, and I believe if would be faster but it has the unwanted effect of eliminating the highest or lowest damage value for any weapon profiency other than 0. My plan is to implement the system I explained in my original post and, if it performed poorly, I would implement the system that I explained in this post. I'm interested in hearing your opinion on the trade-offs. Which system would you rather play with?
5. ## Dynamically Weighted Probabilities?

I am making a classic rpg. I believe that I may be overcomplicating my approach to the damage dealt by weapons. I want to ask you two things: 1) Is there a simpler way to accomplish this type of weighting probabilities? 2) I currently use a procedural approach of summing the weights for each value in the damage range to reverse map the number returned by my random number generator. Is there a mathematical formula do accomplish this? Each weapon has a damage range (e.g. 4-11) and a weapon class (e.g. slicing, piercing). Each character has a profiency rating for each weapon class, ranging from 0 to 1. I want to "randomly" select the values in this range based on the character's profiency with the weapon that he has equiped. My approach is to generate two line segments to form a peak at the (max-min)*profiency area of the damage range, then weighting the probability of selecting each number in the damage range based on where the vertical line at that damage value intersects the line segment on that side of the peak. For example, with a range of 4-11 and a weapon proficiency of 0.65, the two line segments will form a peak at X=8.55 (which is calculated as ((11-4)*.65]+4). The Y coordinate of the peak will be equal to (max-min)/2, or, in this case, (11-4)/2) = 3.5. So our line segments are (4, 1)-(8.55, 3.5) and (8.55, 3.5)-(11, 1) -- the 1 ensuring that all values have at least some chance of being selected. Calculating the line segment intersections for each damage value, you get the following weights: 4=>1.0, 5=>1.55, 6=>2.1, 7=2.65, 8=>3.2, 9=>3.0, 10=>2.0, 11=>1.0. I then generate a random number between 0 and the sum of the values (in this case the range would be 0 to 16.5) e.g. If the random number generator returns the value 5, I would use the damage value of 7 because 5<=1.0+1.55+2.1+2.65. Note: When I implement it, I will scale the range up by a factor of 100 in order to use the integers returned by the random number generator.