The formula doesn't work in java.

Asked 3 months ago, Updated 3 months ago, 6 views

I am a beginner in java.
I deleted what I posted before and rewritten the code, but I can't make my first self-made application well.
The concept is a game action technique, and which combination will cause the most damage.

I'm still in the process of creating it, but the code is

class Act{
    public static void main(String args[]){
            ActDmgTotalReject act=newActDmgTotalReject();
            act.ActDmgTotal();
    }
}
classActDmgSrc{

    static double routine [] = {2.50, 2.50, 80, 53, 0};
            // ActionSkill {cast, recast, dmg, cost dmg_time};
    static double baio[] = {0, 2.50, 40, 110, 18};

}
classActDmgTotalReject extensionsActDmgSrc{
    voidActDmgTotal(){
        double count = 240; // function that counts the number of operations and ends the loop after 240
        double total = 0; // Total damage
        doubleruin_count = 0; //ruin number
        double baio_count = 0; // baio number
        double dmg_ruin = 0;//ruin damage
        double dmg_baio=0;//baio damage
        if(count<=240){
            for(;ruin_count<=240;ruin_count++){
                baio_count=(count-ruin_count*ActDmgSrc.ruin[1])
                        / ActDmgSrc.baio[1]);
                if(baio_count>=0){
                    System.out.println("ruin_count="+ruin_count);
                    System.out.println("baio_count="+baio_count);
                    dmg_ruin=ActDmgSrc.ruin[2]*ruin_count;//ruin damage calculation
                    dmg_baio=ActDmgSrc.baio[2]*baio_count
                            + ActDmgSrc.baio[2]* (ActDmgSrc.baio[4]/3); //baio Damage Calculation
                    total=dmg_ruin+dmg_baio;
                    System.out.println("total="+total);
                }
            }
        }

    }
}

Yes.
We decided to find the combination that would cause the most damage in 4 minutes, so we set the count to 240 and ended the calculation when the count reaches 240.
Then, I divided the number of times and cases of the technique with ruin_count and baio_count.
I would like to ask for the total damage to the combination by applying the number of times of use and damage.
Baio automatically caused 40 damage for 18 seconds, and during that time, I didn't code well that I could hit other techniques.Also, the combination of ruin_count and baio_count is good, but the damage value is strange.

ruin_count=0.0
baio_count = 96.0
total = 4080.0
ruin_count = 1.0
baio_count = 95.0
total=4120.0
ruin_count = 2.0
baio_count = 94.0
total = 4160.0
ruin_count = 3.0
baio_count = 93.0
total = 4200.0
ruin_count = 4.0
baio_count = 92.0
total = 4240.0
ruin_count = 5.0
baio_count = 91.0
total = 4280.0
ruin_count = 6.0
baio_count = 90.0
total=4320.0
ruin_count = 7.0
baio_count = 89.0
total = 4360.0
ruin_count = 8.0
baio_count = 88.0
total = 4400.0
ruin_count = 9.0
baio_count = 87.0
total = 4440.0
ruin_count = 10.0
baio_count = 86.0
total = 4480.0
ruin_count = 11.0
baio_count = 85.0
total = 4520.0
ruin_count = 12.0
baio_count = 84.0
total = 4560.0
ruin_count = 13.0
baio_count = 83.0
total = 4600.0
ruin_count = 14.0
baio_count = 82.0
total = 4640.0
ruin_count = 15.0
baio_count = 81.0
total = 4680.0
ruin_count = 16.0
baio_count = 80.0
total = 4720.0
ruin_count = 17.0
baio_count = 79.0
total = 4760.0
ruin_count = 18.0
baio_count = 78.0
total = 4800.0
ruin_count = 19.0
baio_count = 77.0
total = 4840.0
ruin_count = 20.0
baio_count = 76.0
total = 4880.0
ruin_count = 21.0
baio_count = 75.0
total = 4920.0
ruin_count = 22.0
baio_count = 74.0
total = 4960.0
ruin_count = 23.0
baio_count = 73.0
total = 500.0
ruin_count = 24.0
baio_count = 72.0
total = 5040.0
ruin_count = 25.0
baio_count = 71.0
total = 5080.0
ruin_count = 26.0
baio_count = 70.0
total = 5120.0
ruin_count = 27.0
baio_count=69.0
total = 5160.0
ruin_count = 28.0
baio_count = 68.0
total = 5200.0
ruin_count = 29.0
baio_count = 67.0
total = 5240.0
ruin_count = 30.0
baio_count = 66.0
total = 5280.0
routine_count = 31.0
baio_count = 65.0
total = 5320.0
routine_count = 32.0
baio_count = 64.0
total = 5360.0
ruin_count = 33.0
baio_count = 63.0
total = 5400.0
routine_count = 34.0
baio_count = 62.0
total = 5440.0
ruin_count = 35.0
baio_count = 61.0
total = 5480.0
routine_count = 36.0
baio_count = 60.0
total = 5520.0
routine_count = 37.0
baio_count = 59.0
total = 5560.0
ruin_count = 38.0
baio_count = 58.0
total = 5600.0
ruin_count = 39.0
baio_count = 57.0
total = 5640.0
ruin_count = 40.0
baio_count = 56.0
total = 5680.0
ruin_count = 41.0
baio_count = 55.0
total = 5720.0
ruin_count = 42.0
baio_count = 54.0
total = 5760.0
ruin_count = 43.0
baio_count = 53.0
total = 5800.0
ruin_count = 44.0
baio_count = 52.0
total = 5840.0
ruin_count = 45.0
baio_count = 51.0
total = 5880.0
ruin_count = 46.0
baio_count = 50.0
total = 5920.0
ruin_count = 47.0
baio_count = 49.0
total = 5960.0
ruin_count = 48.0
baio_count = 48.0
total = 6000.0
ruin_count = 49.0
baio_count = 47.0
total = 6040.0
ruin_count = 50.0
baio_count = 46.0
total = 6080.0
ruin_count = 51.0
baio_count = 45.0
total = 6120.0
ruin_count = 52.0
baio_count = 44.0
total = 6160.0
ruin_count = 53.0
baio_count = 43.0
total = 6200.0
ruin_count = 54.0
baio_count = 42.0
total = 6240.0
ruin_count = 55.0
baio_count = 41.0
total = 6280.0
ruin_count = 56.0
baio_count = 40.0
total = 6320.0
ruin_count = 57.0
baio_count = 39.0
total = 6360.0
ruin_count = 58.0
baio_count = 38.0
total = 6400.0
ruin_count = 59.0
baio_count = 37.0
total = 6440.0
ruin_count = 60.0
baio_count = 36.0
total = 6480.0
ruin_count = 61.0
baio_count = 35.0
total = 6520.0
ruin_count = 62.0
baio_count = 34.0
total = 6560.0
ruin_count = 63.0
baio_count = 33.0
total = 6600.0
ruin_count = 64.0
baio_count = 32.0
total = 6640.0
ruin_count = 65.0
baio_count = 31.0
total = 6680.0
ruin_count = 66.0
baio_count = 30.0
total = 6720.0
ruin_count = 67.0
baio_count = 29.0
total = 6760.0
ruin_count = 68.0
baio_count = 28.0
total = 6800.0
ruin_count =69.0
baio_count = 27.0
total = 6840.0
ruin_count = 70.0
baio_count = 26.0
total = 6880.0
ruin_count = 71.0
baio_count = 25.0
total = 6920.0
routine_count = 72.0
baio_count = 24.0
total = 6960.0
ruin_count = 73.0
baio_count = 23.0
total = 7000.0
ruin_count = 74.0
baio_count = 22.0
total = 7040.0
ruin_count = 75.0
baio_count = 21.0
total = 7080.0
routine_count = 76.0
baio_count = 20.0
total = 7120.0
ruin_count = 77.0
baio_count = 19.0
total = 7160.0
ruin_count = 78.0
baio_count = 18.0
total = 7200.0
ruin_count = 79.0
baio_count = 17.0
total = 7240.0
ruin_count = 80.0
baio_count = 16.0
total = 7280.0
ruin_count = 81.0
baio_count = 15.0
total = 7320.0
ruin_count = 82.0
baio_count = 14.0
total = 7360.0
ruin_count = 83.0
baio_count = 13.0
total = 7400.0
routine_count = 84.0
baio_count = 12.0
total = 7440.0
ruin_count = 85.0
baio_count = 11.0
total = 7480.0
routine_count = 86.0
baio_count = 10.0
total = 7520.0
ruin_count = 87.0
baio_count = 9.0
total = 7560.0
ruin_count = 88.0
baio_count = 8.0
total = 7600.0
ruin_count = 89.0
baio_count = 7.0
total = 7640.0
ruin_count = 90.0
baio_count = 6.0
total = 7680.0
routine_count = 91.0
baio_count = 5.0
total = 7720.0
ruin_count = 92.0
baio_count = 4.0
total = 7760.0
routine_count = 93.0
baio_count = 3.0
total = 7800.0
ruin_count = 94.0
baio_count = 2.0
total = 7840.0
ruin_count = 95.0
baio_count = 1.0
total = 7880.0
ruin_count = 96.0
baio_count = 0.0
total = 7920.0

It looks like this, and the result is that the most damage is caused when the baio has never been used.
I don't know if it's correct even if I complete it by myself, but I don't know how to make it because it's my first attempt.
Considering that we will eventually increase our offensive skills, I think it will be difficult to write this code.
Please tell me how to calculate the combination of actions and damage.

java

2022-09-30 14:29

1 Answers

As you write yourself, there is no concept of cost at all, so it is only natural that the maximum value will be achieved if you use a technique that simply causes a lot of damage? repeatedly.
Once the cost is determined to be related to time, there are two inequalities, which can be solved as a problem called linear planning.


2022-09-30 14:29

If you have any answers or tips


© 2023 OneMinuteCode. All rights reserved.