public static void Main( string[] args ) { int mineral, gas, supply; Data data = new Data(); if( args.Length != 3 ) { System.Console.WriteLine( "Usage: ResourceAllocation #mineral #gas #supply" ); //return; mineral = 20000; gas = 14000; supply = 380; } else { mineral = Convert.ToInt32( args[ 0 ] ); gas = Convert.ToInt32( args[ 1 ] ); supply = Convert.ToInt32( args[ 2 ] ); } int maxSize = Math.Max( mineral / 25, Math.Max( gas / 25, supply ) ); var domain = new ghost.Domain( maxSize, 0 ); var listUnits = MakeTerranUnits( domain ); var setUnits = new SetVariables( listUnits ); var constraints = new List< Constraint > { new MineralConstraint( setUnits, mineral ), new GasConstraint( setUnits, gas ), new SupplyConstraint( setUnits, supply ) }; var objective = new MaxDPS( "max DPS", mineral, gas, supply ); var solver = new ghost.Solver< Variable, SetVariables, Constraint >( setUnits, constraints, objective ); Console.WriteLine( "Start solving trivial test" ); solver.solve( 100, 2000 ); int mineralUsed = 0; int gasUsed = 0; double supplyUsed = 0.0; double DPS = 0.0; for( int i = 0 ; i < setUnits.GetNumberVariables() ; ++i ) { mineralUsed += setUnits.GetValue( i ) * data.Dataset[ setUnits.Name( i ) ].CostMineral; gasUsed += setUnits.GetValue( i ) * data.Dataset[ setUnits.Name( i ) ].CostGas; supplyUsed += setUnits.GetValue( i ) * data.Dataset[ setUnits.Name( i ) ].CostSupply; if( data.Dataset[ setUnits.Name( i ) ].GroundAttack > 0 ) DPS += setUnits.GetValue( i ) * ( (double)data.Dataset[ setUnits.Name( i ) ].GroundAttack / data.Dataset[ setUnits.Name( i ) ].GroundCooldown ); } DPS *= 24; Console.WriteLine( "DPS = " + DPS ); Console.WriteLine( "Mineral left: " + (mineral - mineralUsed) + ", gas left: " + (gas - gasUsed) + ", supply left: " + (supply - supplyUsed) ); }
public override string ToolTip() { //string minDPS = ((int)(AttackSpeed * (MaxDamage*DmgVariance))).ToString (); //string maxDPS = ((int)(AttackSpeed * MaxDamage)).ToString (); string numBuffs = ""; if (this.NumberOfBuffs() > 0) { numBuffs = "\n" + GetBuffsString(); } else { numBuffs = ""; } //Format wording of proc correctly string procDesc = ""; switch (Proc) { case ProcType.GainLifeOnHit: procDesc = "\n" + string.Format("Gain {0} health per physical attack", ProcModifier); break; case ProcType.GainManaOnHit: procDesc = "\n" + string.Format("Gain {0} mana per physical attack", ProcModifier); break; case ProcType.Knockback: procDesc = "\n" + string.Format("Has a {0}% chance to cause knockback", (ProcModifier * 100).ToString("F2")); break; case ProcType.None: break; case ProcType.Poison: procDesc = "\n" + string.Format("Has a {0}% chance to cause poison", (ProcModifier * 100).ToString("F2")); break; case ProcType.Slow: procDesc = "\n" + string.Format("Has a {0}% chance to slow targets attack speed", (ProcModifier * 100).ToString("F2")); break; case ProcType.ConvertToLife: procDesc = "\n" + string.Format("Converts {0}% of damage dealth to health", (ProcModifier * 100).ToString("F2")); break; case ProcType.ConvertToMana: procDesc = "\n" + string.Format("Converts {0}% of damage dealth to mana.", (ProcModifier * 100).ToString("F2")); break; case ProcType.Stun: procDesc = "\n" + string.Format("Has a {0}% chance to stun your target", (ProcModifier * 100).ToString("F2")); break; case ProcType.GainEnergyOnHit: procDesc = "\n" + string.Format("Gain {0} energy per physical attack", ProcModifier.ToString("0.00")); break; case ProcType.ConvertToEnergy: procDesc = "\n" + string.Format("Converts {0}% of damage dealth to energy", (ProcModifier * 100).ToString("F2")); break; } string moreStats = ""; if (this.Proc != ProcType.None || this.CritChance != 0 || this.CritDamage > 0.0f) { if (this.CritChance != 0) { moreStats += "\n" + "+ " + (CritChance * 100).ToString("0") + "% Critical Hit Chance"; } if (this.CritDamage > 0.0f) { moreStats += "\n" + "Critical hits deal " + ((2.0 + CritDamage) * 100).ToString("0") + "% damage"; } if (this.Proc != ProcType.None) { moreStats += procDesc; } } string elementalDmg = ""; if (this.DmgValue != 0) { elementalDmg += "+ " + DmgValue + " " + DmgType.ToString() + " damage" + "\n"; } string socketBuffs = ""; if (EquippedSockets.Count > 0) { socketBuffs += "\n \n" + "(" + UsedSockets.ToString() + ") Sockets: \n"; } foreach (SocketItem socket in EquippedSockets) { socketBuffs += socket.GetBuffsString(); } socketBuffs += "\n"; //Set correct tooltype to corresponding type return("Damage: " + (int)(MaxDamage * DmgVariance) + " - " + MaxDamage + "\n" + elementalDmg + "(DPS: " + MinDPS.ToString() + "-" + MaxDPS.ToString() + ")" + "\n" + "Attacks Per Second: " + AttackSpeed.ToString("0.00") + numBuffs + socketBuffs + moreStats); }