public AtomCollisionResult ProduceCombine(Atom a, Atom b, int aAmo, int bAmo) { AtomCollision info = EstimateCombine(a, b, aAmo, bAmo); AtomCollisionResult result = new AtomCollisionResult(); result.atomsProduced = new List <AtomAmo>(); result.atomsUsed = new List <AtomAmo>(); AtomData aData = Game.Instance.gameData.FindAtomData(a.GetAtomicNumber()); AtomData bData = Game.Instance.gameData.FindAtomData(b.GetAtomicNumber()); int usedAmo = Mathf.Min(Mathf.Min(aAmo, aData.GetCurrAmo()), Mathf.Min(bAmo, bData.GetCurrAmo())); Atom target = info.targetAtom; int maxAmo = info.amo; float successChance = info.success; float stabilityChance = 1.0f; stabilityChance = info.stability; int produced = (int)(maxAmo * successChance); int stabilized = (int)(produced * stabilityChance); AtomAmo atomAmo = new AtomAmo(); atomAmo.amo = stabilized; atomAmo.atom = target; result.atomsProduced.Add(atomAmo); Game.Instance.Absorb(target, stabilized); AtomAmo atomAUsed = new AtomAmo(); atomAUsed.atom = a; atomAUsed.amo = usedAmo; result.atomsUsed.Add(atomAUsed); AtomAmo atomBUsed = new AtomAmo(); atomBUsed.atom = b; atomBUsed.amo = usedAmo; result.atomsUsed.Add(atomBUsed); Game.Instance.Use(a, usedAmo); Game.Instance.Use(b, usedAmo); if (OnAtomCombine != null) { OnAtomCombine(target, stabilized); } return(result); }
public AtomCollisionResult ProduceSplit(Atom a, int aAmo) { AtomCollision info = EstimateSplit(a, aAmo); AtomData aData = Game.Instance.gameData.FindAtomData(a.GetAtomicNumber()); aAmo = Mathf.Min(aAmo, aData.GetCurrAmo()); AtomCollisionResult result = new AtomCollisionResult(); result.atomsProduced = new List <AtomAmo>(); result.atomsUsed = new List <AtomAmo>(); Atom target = info.targetAtom; // Split int produced = (int)(info.amo * info.success); // Random Loss // Stabilize int stabilized = (int)(produced * info.stability); // Result AtomAmo atomAmo = new AtomAmo(); atomAmo.amo = stabilized; atomAmo.atom = target; result.atomsProduced.Add(atomAmo); Game.Instance.Absorb(target, stabilized); // Used AtomAmo atomAUsed = new AtomAmo(); atomAUsed.atom = a; atomAUsed.amo = aAmo; result.atomsUsed.Add(atomAUsed); Game.Instance.Use(a, aAmo); if (OnAtomSplit != null) { OnAtomSplit(target, stabilized); } return(result); }
public AtomCollision EstimateSplit(Atom a, int aAmo) { AtomCollision info = new AtomCollision(); if (a.GetAtomicNumber() == 1) // Hydrogen, Can Not Split... { return(info); } AtomInfo aInfo = Game.Instance.gameData.FindAtomInfo(a.GetAtomicNumber()); //aAmo = Mathf.Min(aAmo, int.MaxValue / aInfo.GetNeutrons()); int halfProtons = aInfo.GetProtons() / 2; long totalNeutrons = aInfo.GetNeutrons() * 1L * aAmo; // Target info.targetAtom = Game.Instance.gameData.FindAtom(halfProtons); // Should Correlate to Atomic number AtomInfo targetInfo = Game.Instance.gameData.FindAtomInfo(halfProtons); // Max Amount to Be Made if (info.targetAtom.GetAtomicNumber() == 1) // Hydrogen { long protons = aInfo.GetProtons() * aAmo; info.amo = (int)(protons / targetInfo.GetProtons()); // Proton Based } else { long amo = totalNeutrons / targetInfo.GetNeutrons(); info.amo = amo > int.MaxValue ? int.MaxValue : (int)amo; // Neutron Based } // Success float estimatedSpeed = aInfo.GetProtons() / 10f; info.success = Mathf.Clamp01(1 - estimatedSpeed / accelerationUpgrade.GetValue()); // Stability if (targetInfo.GetHalfLife() == 0f) { info.stability = 1.0f; } else { //float halfLife = targetInfo.GetHalfLife() + timeUpgrade.GetValue(); //float multiple = 1 / Mathf.Sqrt(1 - (stabilityUpgrade.GetValue() * stabilityUpgrade.GetValue()) / (100 * 100)); //info.stability = AtomInfo.GetStability(halfLife * multiple * multiple); float halflife = targetInfo.GetHalfLife() + timeUpgrade.GetValue(); if (halflife < 0) { info.stability = 0f; } else { float yearPercentage = 5256000; // 10 years ish float t = .001f; float stableValue = stabilityUpgrade.GetValue(); float lerp = Mathf.Lerp(halflife, yearPercentage, t); float power = Mathf.Sqrt(stableValue / 30); float stability = Mathf.Pow(lerp, power); info.stability = Mathf.Clamp01(stability / yearPercentage); } } return(info); }
public AtomCollision EstimateCombine(Atom a, Atom b, int aAmo, int bAmo) { AtomCollision info = new AtomCollision(); AtomInfo aInfo = Game.Instance.gameData.FindAtomInfo(a.GetAtomicNumber()); AtomInfo bInfo = Game.Instance.gameData.FindAtomInfo(b.GetAtomicNumber()); AtomData aData = Game.Instance.gameData.FindAtomData(a.GetAtomicNumber()); AtomData bData = Game.Instance.gameData.FindAtomData(b.GetAtomicNumber()); aAmo = Mathf.Min(aAmo, aData.GetCurrAmo()); bAmo = Mathf.Min(bAmo, bData.GetCurrAmo()); //aAmo = Mathf.Min(aAmo, int.MaxValue / aInfo.GetNeutrons()); //bAmo = Mathf.Min(bAmo, int.MaxValue / bInfo.GetNeutrons()); int maxProtons = aInfo.GetProtons() + bInfo.GetProtons(); long totalANeutrons = aAmo * aInfo.GetNeutrons(); long totalBNeutrons = bAmo * bInfo.GetNeutrons(); if (Game.Instance.gameData.GetAtomAmount() >= maxProtons) { info.targetAtom = Game.Instance.gameData.FindAtom(maxProtons); // Should Correlate to Atomic number } else { info.targetAtom = null; return(info); } AtomInfo targetInfo = Game.Instance.gameData.FindAtomInfo(maxProtons); long minProtons = Mathf.Min(aAmo, bAmo); // Min of Atoms long minNeutrons = (totalANeutrons + totalBNeutrons) / targetInfo.GetNeutrons(); long amo = minProtons > minNeutrons ? minNeutrons : minProtons; info.amo = amo > int.MaxValue ? int.MaxValue : (int)amo; // 119 / 10 -> 11.9% Speed // 1 - (11.9 / 12) -> .008333 About 1 / 12 // // At 10% speed of light, Titanium -> Berkelium produces an estimated 1 / 1 billion atoms of Element 119 float estimatedSpeed = maxProtons / 10f; info.success = Mathf.Clamp01(1 - estimatedSpeed / accelerationUpgrade.GetValue()); // Apparently the half life of atoms can be changed by Time Dialation, Gravity, and External Radiation // There is no known way to accurately predict the half-life of atoms. There are two many variables // How about this, we place radioactive atoms near a black hole. Depending on the strength and randomness, the atom's half-life may be extended and stored indefinetly. // Our goal is to get that between 525600 1 year and 525600000 1000 years // However if we have a value of 0.00085 // That requires a multiple of 618,352,941 Just for the min //100*sqrt(1-((x*x)/(100*100))); Percentage of Speed -> Time Ratio //1 / sqrt(1-((x*x)/(100*100))); Percentage of Speed -> Time Multiple if (targetInfo.GetHalfLife() == 0f) { info.stability = 1.0f; } else { //float halfLife = targetInfo.GetHalfLife() + timeUpgrade.GetValue(); //float multiple = 1 / Mathf.Sqrt(1 - (stabilityUpgrade.GetValue() * stabilityUpgrade.GetValue()) / (100 * 100)); //info.stability = AtomInfo.GetStability(halfLife * multiple * multiple); //\frac{\left(\left(t\cdot\left(a-v\right)+v\right)^{\sqrt{\frac{x}{30}}}\right)}{525600} float halflife = targetInfo.GetHalfLife() + timeUpgrade.GetValue(); if (halflife < 0) { info.stability = 0f; } else { float yearPercentage = 5256000; // 10 years ish float t = .001f; float stableValue = stabilityUpgrade.GetValue(); float lerp = Mathf.Lerp(halflife, yearPercentage, t); float power = Mathf.Sqrt(stableValue / 30); float stability = Mathf.Pow(lerp, power); info.stability = Mathf.Clamp01(stability / yearPercentage); } } return(info); }