예제 #1
0
        public static void Find_Combinations()
        {
            //Find out if enemy will release some molecules for you
            int[] willbe_available_M = new int[5] {
                0, 0, 0, 0, 0
            };
            int[] availableM = new int[5] {
                bank.A, bank.B, bank.C, bank.D, bank.E
            };

            if (enemy.target == "LABORATORY")
            {
                //Find out what molecules WILL be available
                foreach (Sample a in enemy.carried_sample.Values)
                {
                    int[] dM = new int[5] {
                        a.costA - enemy.expertiseA, a.costB - enemy.expertiseB, a.costC - enemy.expertiseC, a.costD - enemy.expertiseD, a.costE - enemy.expertiseE
                    };
                    if (enemy.storageA - dM[0] >= 0 && enemy.storageB - dM[1] >= 0 && enemy.storageC - dM[2] >= 0 && enemy.storageD - dM[3] >= 0 && enemy.storageE - dM[4] >= 0)
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            //Enemy will use this sample
                            willbe_available_M[i] += dM[i];
                        }
                    }
                }
            }
            //Fill Combination
            List <int> ID_list = new List <int>();

            foreach (Sample a in ally.carried_sample.Values)
            {
                ID_list.Add(a.sampleId);
            }
            foreach (Sample a in ally.carried_sample.Values)
            {
                Combination      Combo      = new Combination();
                combination_info Combo_info = new combination_info();
                Combo_info.storageTot = ally.storageTot;

                for (int i = 0; i < 5; i++)
                {
                    //Initialize avail
                    availM[i] = 0;
                    //Then set availM
                    availM[i] = willbe_available_M[i] + availableM[i];
                }
                //Set values in convo info
                Combo_info.availableA_inAlly = ally.storageA;
                Combo_info.availableB_inAlly = ally.storageB;
                Combo_info.availableC_inAlly = ally.storageC;
                Combo_info.availableD_inAlly = ally.storageD;
                Combo_info.availableE_inAlly = ally.storageE;
                Console.Error.WriteLine("First sample" + a.sampleId);
                //Find the IDs of the other samples
                List <int> other_samples = new List <int>();
                foreach (int b in ID_list)
                {
                    if (b != a.sampleId)
                    {
                        other_samples.Add(b);
                        Console.Error.WriteLine("OTHER SAMPLES" + b);
                    }
                }
                //Check sample validity(S1)
                Check_Sample(a, Combo, Combo_info);
                //Check next 2
                foreach (int b in other_samples)
                {
                    Combination      Combo2      = new Combination();
                    combination_info Combo_info2 = new combination_info();
                    Combo2.S1 = Combo.S1;
                    Console.Error.WriteLine("SECOND SAMPLE: " + b + " Combo2.S1=" + Combo2.S1);
                    Combo_info2.set_comb_info(Combo2, Combo_info.Health_GainTot, Combo_info.expertiseA, Combo_info.expertiseB, Combo_info.expertiseC, Combo_info.expertiseD, Combo_info.expertiseE, Combo_info.S_count, Combo_info.storageTot, Combo_info.availableA_inAlly, Combo_info.availableB_inAlly, Combo_info.availableC_inAlly, Combo_info.availableD_inAlly, Combo_info.availableE_inAlly);
                    //Find 3rd sample
                    int sample3_ID = -1;
                    foreach (int c in other_samples)
                    {
                        if (c != b)
                        {
                            sample3_ID = c;
                        }
                    }

                    //Try second sample
                    Check_Sample(ally.carried_sample[b], Combo2, Combo_info2);
                    Console.Error.WriteLine("Thrid SAMPLE: " + sample3_ID + " Combo2.S1=" + Combo2.S1 + "Combo.S2=" + Combo2.S2);
                    //Then 3rd
                    Check_Sample(ally.carried_sample[sample3_ID], Combo2, Combo_info2);
                }
            }
        }
예제 #2
0
        public static void Check_Sample(Sample a, Combination Combo, combination_info Combo_info)
        {
            int A_needed = ally.carried_sample[a.sampleId].costA - Combo_info.availableA_inAlly - Combo_info.expertiseA;
            int B_needed = ally.carried_sample[a.sampleId].costB - Combo_info.availableB_inAlly - Combo_info.expertiseB;
            int C_needed = ally.carried_sample[a.sampleId].costC - Combo_info.availableC_inAlly - Combo_info.expertiseC;
            int D_needed = ally.carried_sample[a.sampleId].costD - Combo_info.availableD_inAlly - Combo_info.expertiseD;
            int E_needed = ally.carried_sample[a.sampleId].costE - Combo_info.availableE_inAlly - Combo_info.expertiseE;

            if (A_needed < 0)
            {
                A_needed = 0;
            }
            if (B_needed < 0)
            {
                B_needed = 0;
            }
            if (C_needed < 0)
            {
                C_needed = 0;
            }
            if (D_needed < 0)
            {
                D_needed = 0;
            }
            if (E_needed < 0)
            {
                E_needed = 0;
            }

            int needed_Tot = A_needed + B_needed + C_needed + D_needed + E_needed;

            if (A_needed <= availM[0] && B_needed <= availM[1] && C_needed <= availM[2] && D_needed <= availM[3] && E_needed <= availM[4] && needed_Tot <= 10 - Combo_info.storageTot)
            {
                //Molecules has enough materials or you alrdy have it
                //update info
                Combo_info.S_count++;
                Combo_info.storageTot += needed_Tot;
                availM[0]             -= A_needed;
                availM[1]             -= B_needed;
                availM[2]             -= C_needed;
                availM[3]             -= D_needed;
                availM[4]             -= E_needed;

                Combo_info.availableA_inAlly = Get_Updated_Ally_Storage(A_needed, Combo_info.availableA_inAlly);
                Combo_info.availableB_inAlly = Get_Updated_Ally_Storage(B_needed, Combo_info.availableB_inAlly);
                Combo_info.availableC_inAlly = Get_Updated_Ally_Storage(C_needed, Combo_info.availableC_inAlly);
                Combo_info.availableD_inAlly = Get_Updated_Ally_Storage(D_needed, Combo_info.availableD_inAlly);
                Combo_info.availableE_inAlly = Get_Updated_Ally_Storage(E_needed, Combo_info.availableE_inAlly);
                Combo_info.Health_GainTot   += ally.carried_sample[a.sampleId].health;
                if (a.gain == "A")
                {
                    Combo_info.expertiseA++;
                }
                else if (a.gain == "B")
                {
                    Combo_info.expertiseB++;
                }
                else if (a.gain == "C")
                {
                    Combo_info.expertiseC++;
                }
                else if (a.gain == "D")
                {
                    Combo_info.expertiseD++;
                }
                else if (a.gain == "E")
                {
                    Combo_info.expertiseE++;
                }
                //Set Combo
                if (Combo.S1 == -1)
                {
                    Combo.S1 = a.sampleId;
                }
                else if (Combo.S2 == -1)
                {
                    Combo.S2 = a.sampleId;
                }
                else if (Combo.S3 == -1)
                {
                    Combo.S3 = a.sampleId;
                }
                //Add to combinations
                //make new combination to get unique hashcode
                Combination combAdd = new Combination();
                combAdd.S1 = Combo.S1;
                combAdd.S2 = Combo.S2;
                combAdd.S3 = Combo.S3;
                //Print Combination added
                Combo.Print_sampleIDs();
                if (!Combinations.ContainsKey(combAdd))
                {
                    Combinations.Add(combAdd, Combo_info);
                }
            }
        }
예제 #3
0
 public static void AT_Diagnosis()
 {
     //First of all diagnose any unidentified samples
     if (ally.undiagnosed_count > 0)
     {
         err_output = ("HAVE UNDIAGNOSED SAMPLE/S, DIAGNOSE THEM");
         output     = "CONNECT " + ally.undiagnosed_ids[0];
     }
     //all samples diagnosed
     else
     {
         //Calculate possible combinations
         Find_Combinations();
         combinations_sorted = Combinations.Values.OrderByDescending(s => s.Health_GainTot).ThenBy(s => s.S_count).ThenBy(s => s.storageTot).ToList();
         foreach (combination_info a in combinations_sorted)
         {
             if (a != null)
             {
                 Console.Error.WriteLine("COMBINATION: " + a.Combo.S1 + " " + a.Combo.S2 + " " + a.Combo.S3 + " Can_Sample_Count: " + a.S_count + "  Health_GainTot: " + a.Health_GainTot + " expertiseA: " + a.expertiseA + " expertiseB: " + a.expertiseB + " expertiseC: " + a.expertiseC + " expertiseD: " + a.expertiseD + " expertiseE: " + a.expertiseE);
             }
         }
         if (ally.carried_sample.Count == 3)
         {
             if (combinations_sorted[0].S_count == 3)
             {
                 //Great, Get on to Molecules
                 output = "GOTO MOLECULES";
             }
             else if (combinations_sorted[0].S_count == 2)
             {
                 int         RemoveID = -1;
                 Combination bo       = combinations_sorted[0].Combo;
                 //Check the sample not included in the combination
                 foreach (Sample a in ally.carried_sample.Values)
                 {
                     if (bo.S1 != a.sampleId && bo.S2 != a.sampleId && bo.S3 != a.sampleId)
                     {
                         RemoveID = a.sampleId;
                     }
                 }
                 if (ally.carried_sample[RemoveID].valid)
                 {
                     output = "GOTO MOLECULES";
                 }
                 else
                 {
                     //remove it
                     output = "CONNECT " + RemoveID;
                 }
             }
         }
         else if (ally.carried_sample.Count == 2)
         {
             //check out cloud
             if (samples.Count != 0)
             {
                 //check out samples in it
                 if (samples[samples_sorted[0]].valid)
                 {
                     //ASK for it
                     output = "CONNECT " + samples_sorted[0];
                 }
                 else
                 {
                     output = "GOTO MOLECULES";
                 }
             }
         }
     }
 }