Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Plt-D v.0.9.5
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Plts { public int iD; public string name; public int xCord; public float numberBlts; public int reproductionBlts; public string color; } public class Program { bool WBlue = false; int count = 0; public int count12 = 0; public float percK = 1.1f; public static void Main(string[] args) { string blue = "blue"; string red = "red"; string green = "green"; string gray = "gray"; float blueKD = 0.1f; float allColorKAtkFromOnePlt = 0.1f; float bluePrcForAtkFronOneplt = 0.1f; float blueKAtkFromOnePlt = 1.2f; float blueMinDefOstatokOnPlt = 5f; float bluePrcDefAfterAtk = 1.2f; int periodIteracii = 200; Program classProg = new Program(); List<Plts> listPlts = new List<Plts>(); listPlts.Add(new Plts { iD = 1, name = "HRed", xCord = 4, numberBlts = 20f, reproductionBlts = 2, color = red }); listPlts.Add(new Plts { iD = 2, name = "HBlue", xCord = 12, numberBlts = 20f, reproductionBlts = 2, color = blue }); listPlts.Add(new Plts { iD = 3, name = "net1", xCord = 11, numberBlts = 20f, reproductionBlts = 1, color = gray }); listPlts.Add(new Plts { iD = 4, name = "net2", xCord = 5, numberBlts = 20f, reproductionBlts = 1, color = gray }); listPlts.Add(new Plts { iD = 5, name = "net3", xCord = 8, numberBlts = 20f, reproductionBlts = 1, color = gray }); Console.WriteLine("Основа start: "); foreach (Plts llistPlst in listPlts) { Console.Write(" | " + llistPlst.name + " и " + llistPlst.numberBlts + " и " + llistPlst.color); } Console.Write(" \n"); var tempColor = listPlts.First().color; while (classProg.WBlue != true) { classProg.BPlrs(blue ,listPlts, blueKD, bluePrcForAtkFronOneplt, blueKAtkFromOnePlt, periodIteracii, blueMinDefOstatokOnPlt, bluePrcDefAfterAtk); classProg.BPlrs(red ,listPlts, blueKD, bluePrcForAtkFronOneplt, blueKAtkFromOnePlt, periodIteracii, blueMinDefOstatokOnPlt, bluePrcDefAfterAtk); //classProg.NetPlrs(listPlts); classProg.Count1(); } ; Console.WriteLine("\nОснова2:"); foreach (Plts llistPlst in listPlts) Console.Write(" | " + llistPlst.name + " и " + llistPlst.numberBlts + " и " + llistPlst.color); Console.WriteLine(" \ncount = " + classProg.count + " count12 = " + classProg.count12); } public void Count1() { count12++; } public void BPlrs(string stringColorPlr, List<Plts> lb, float KD, float locBlueColorKAtkFromOnePlt, float locBlueKAtkFromOnePlt, int locPeriodIteracii, float locBlueMinDefOstatokOnPlt, float locBluePrcDefAfterAtk) { string str = "blue"; var lBluePlts = SelfColor(stringColorPlr, lb); var lBlueAtk = SelfAtak(stringColorPlr, lb); // TODO: Blue Plts CalcBlts(str, lBluePlts); foreach (Plts lBP in lBluePlts) { Console.Write(" -|- " + lBP.name + " и " + lBP.numberBlts + " " + lBP.color ); } ChsTrgt(lBluePlts,lBlueAtk, locBlueColorKAtkFromOnePlt, locBlueKAtkFromOnePlt, locBlueMinDefOstatokOnPlt, locBluePrcDefAfterAtk); ChkDBY(lBlueAtk); Console.WriteLine("\n count++ = " + count++ ); } public void CalcBlts( string locColorString, IEnumerable<Plts> lb) { foreach (Plts l in lb) { l.numberBlts += l.reproductionBlts; } } public void ChsTrgt(IEnumerable<Plts> lb, IEnumerable<Plts> eLb, float locBlueColorKAtkFromOnePlt, float locBlueKAtkFromOnePlt, float locBlueMinDefOstatokOnPlt, float locBluePrcDefAfterAtk) { float totalSummBlts = 0; float totalSummBltsMinusMinDef = 0; float totalSummEBlts = 0; float percForDf = 0; float targetToAt = 100000000; //eLb.Max(x => x.numberBlts); //max from EnumberBlts foreach (Plts eL in eLb) { totalSummEBlts += eL.numberBlts; if (eL.numberBlts < targetToAt) { targetToAt = eL.numberBlts; } } // Console.Write(" || targetToAt = " + targetToAt); foreach (Plts l in lb) { totalSummBlts += l.numberBlts; totalSummBltsMinusMinDef += l.numberBlts - locBlueMinDefOstatokOnPlt; } // Console.WriteLine(totalSummBlts + " --==-- " + totalSummBltsMinusMinDef); foreach (Plts l in lb) { foreach (Plts eL in eLb) { if (eL.numberBlts < l.numberBlts * locBlueColorKAtkFromOnePlt) { // Console.Write(" || l.numberBlts * locBlueColorKAtkFromOnePlt = " + (l.numberBlts * locBlueColorKAtkFromOnePlt) + " eL.numberBlts = " + eL.numberBlts); if ((Math.Ceiling (eL.numberBlts * locBlueKAtkFromOnePlt)) <= l.numberBlts && l.numberBlts - (Math.Ceiling (eL.numberBlts * locBlueKAtkFromOnePlt)) > 0) { Console.Write(" +|+ "+ l.numberBlts); Console.Write(" \neL.numberBlts * locBlueKAtkFromOnePlt = " + Math.Ceiling (eL.numberBlts * locBlueKAtkFromOnePlt) + " l.numberBlts - (Math.Floor(eL.numberBlts * locBlueKAtkFromOnePlt)) = " + (l.numberBlts - (Math.Ceiling(eL.numberBlts * locBlueKAtkFromOnePlt))) + " eL.Name = " + eL.name); float tempVar = (float) Math.Ceiling (eL.numberBlts * locBlueKAtkFromOnePlt); l.numberBlts -= tempVar; eL.numberBlts *= -1f; eL.numberBlts += tempVar; eL.color = l.color; Console.Write(" -|- " + l.name + " и " + l.numberBlts); } } else { if (totalSummBltsMinusMinDef > Math.Ceiling(eL.numberBlts * locBluePrcDefAfterAtk)) { var tempNumberBltsToAtk = Math.Ceiling(eL.numberBlts * locBluePrcDefAfterAtk); //indispensably Blts for A, and prc for def var tempPrcMinusBltsToAtk = tempNumberBltsToAtk / totalSummBltsMinusMinDef; // Prc ot vseh Plts for A Console.WriteLine(" tempNumberBltsToAtk = " + tempNumberBltsToAtk + " tempPrcMinusBltsToAtk = " + tempPrcMinusBltsToAtk + " totalSummBltsMinusMinDef = " + totalSummBltsMinusMinDef + " ID = " + eL.iD); foreach (Plts lA in lb) { lA.numberBlts -= (int)Math.Ceiling(lA.numberBlts * tempPrcMinusBltsToAtk); } eL.numberBlts *= - 1; eL.numberBlts += (int) tempNumberBltsToAtk; eL.color = l.color; } //totalSummBlts totalSummBltsMinusMinDef /* targetToAt totalSummBlts*/ } // if (l.numberBlts > Math.Floor(eL.numberBlts * percK)) // Console.Write("\n" + l.numberBlts + " > " + eL.numberBlts + " ("+ Math.Round((eL.numberBlts * percK)) + ")" + " " + eL.name ); // Console.Write("\n {0} {1}", Math.Floor(eL.numberBlts * percK), (eL.numberBlts * percK)); } } } public void FtStep(Plts iDSelfPlts, Plts IdEplTs) { } public void ChkDBY( IEnumerable<Plts> lb) { if (lb.Count() == 0) WBlue = true; } public void NetPlrs(List<Plts> lnet) { string str = "gray"; var netPlts = from list in lnet where list.color == "gray" select list; Console.WriteLine("Gray"); foreach (Plts lNetList in netPlts) { System.Threading.Thread.Sleep(10); Console.Write(" |Net " + lNetList.name); } Console.WriteLine(" "); } public IEnumerable<Plts> SelfColor(string lStr, List<Plts> l) { var l1 = from list in l where list.color == lStr select list; return l1; } public IEnumerable<Plts> SelfAtak(string lStr, List<Plts> l) { var l1 = from list in l where list.color != lStr select list; return l1; } } }
run
|
edit
|
history
|
help
0
Fibonacci Series
RRE
iLoveLizzy
Detaylar
Generic class and method example in C#
Beadando Simon Szabolcs
QuickSort
abcd
datetime
Create RFReader HardwareConfig