The code for the updateThreshold method currently includes the following lines:
` switch(decisionStrat) {
case PRICE:
ProbAdjuster prob;
if (priceDiff < 0)
if(rarityDiff < 0) prob = new ProbAdjuster(q4); //fourth quadrant
else prob = new ProbAdjuster(q1); //first quadrant
else
if(rarityDiff < 0) prob = new ProbAdjuster(q3); //third quadrant
else prob = new ProbAdjuster(q2); //second quadrant
deltaProbb = prob.getAdjustmentwBoost(rarityDiff, priceDiff, (double)newLoot.getRarity());
break;
`
The q4, q1, q3, and q2 variables are static instances that are declared and initialized when the class is loaded. You have added a constructor to the ProbAdjuster class that takes another instance of ProbAdjuster and (essentially) copies it. However, all of this adds overhead to the code. Instead of using the q4, q1, q3, and q2 variables as templates that get copied every time, you can just use those instances:
`
Because constructing and destroying objects is expensive, this should improve performance. As long as these objects are the same for all players, and as long as they do not change during the simulation, you can reuse the instances instead of creating new ones for every player, every tick. (Note that there is some Java magic going on: the variable 'prob' is basically a pointer here, and it can be set to point to the existing object. Java doesn't really allow pointers, but it acts like it does sometimes.)
The code for the updateThreshold method currently includes the following lines:
` switch(decisionStrat) { case PRICE:
`
The q4, q1, q3, and q2 variables are static instances that are declared and initialized when the class is loaded. You have added a constructor to the ProbAdjuster class that takes another instance of ProbAdjuster and (essentially) copies it. However, all of this adds overhead to the code. Instead of using the q4, q1, q3, and q2 variables as templates that get copied every time, you can just use those instances:
` switch(decisionStrat) { case PRICE:
` Because constructing and destroying objects is expensive, this should improve performance. As long as these objects are the same for all players, and as long as they do not change during the simulation, you can reuse the instances instead of creating new ones for every player, every tick. (Note that there is some Java magic going on: the variable 'prob' is basically a pointer here, and it can be set to point to the existing object. Java doesn't really allow pointers, but it acts like it does sometimes.)