Ejemplo n.º 1
0
        //Constructor 1.

        //Constructpor 2.
        public DrawHourse(int CurrentAStarGredy, bool MovementsAStarGreedyHeuristicTFou, bool IgnoreSelfObject, bool UsePenaltyRegardMechnisa, bool BestMovment, bool PredictHurist, bool OnlySel, bool AStarGreedyHuris, bool Arrangments, float i, float j, int a, int[,] Tab, int Ord, bool TB, int Cur//,ref AllDraw. THIS
                          )
        {
            {
                CurrentAStarGredyMax = CurrentAStarGredy;
                MovementsAStarGreedyHeuristicFoundT = MovementsAStarGreedyHeuristicTFou;
                IgnoreSelfobjectsT         = IgnoreSelfObject;
                UsePenaltyRegardMechnisamT = UsePenaltyRegardMechnisa;
                BestMovmentsT         = BestMovment;
                PredictHeuristicT     = PredictHurist;
                OnlySelfT             = OnlySel;
                AStarGreedyHeuristicT = AStarGreedyHuris;
                ArrangmentsChanged    = Arrangments;
                //Initiate Global Variable By Local Paramenters.
                Table = new int[8, 8];
                for (var ii = 0; ii < 8; ii++)
                {
                    for (var jj = 0; jj < 8; jj++)
                    {
                        Table[ii, jj] = Tab[ii, jj];
                    }
                }
                for (var ii = 0; ii < AllDraw.HourseMovments; ii++)
                {
                    HourseThinking[ii] = new ThinkingRefrigtzChessPortable(ii, 3, CurrentAStarGredyMax, MovementsAStarGreedyHeuristicFoundT, IgnoreSelfobjectsT, UsePenaltyRegardMechnisamT, BestMovmentsT, PredictHeuristicT, OnlySelfT, AStarGreedyHeuristicT, ArrangmentsChanged, (int)i, (int)j, a, CloneATable(Tab), 8, Ord, TB, Cur, 4, 3);
                }

                Row     = i;
                Column  = j;
                color   = a;
                Order   = Ord;
                Current = Cur;
            }
        }
Ejemplo n.º 2
0
        //Constructor 1.

        //Constructor 2.
        public DrawSoldier(int CurrentAStarGredy, bool MovementsAStarGreedyHeuristicTFou, bool IgnoreSelfObject, bool UsePenaltyRegardMechnisa, bool BestMovment, bool PredictHurist, bool OnlySel, bool AStarGreedyHuris, bool Arrangments, float i, float j, Color a, int[,] Tab, int Ord, bool TB, int Cur//, ref AllDraw. THIS
                           ) :
            base(Arrangments, (int)i, (int)j, a, Tab, Ord, TB, Cur)
        {
            object balancelock = new object();

            lock (balancelock)
            {
                CurrentAStarGredyMax = CurrentAStarGredy;
                MovementsAStarGreedyHeuristicFoundT = MovementsAStarGreedyHeuristicTFou;
                IgnoreSelfObjectsT         = IgnoreSelfObject;
                UsePenaltyRegardMechnisamT = UsePenaltyRegardMechnisa;
                BestMovmentsT         = BestMovment;
                PredictHeuristicT     = PredictHurist;
                OnlySelfT             = OnlySel;
                AStarGreedyHeuristicT = AStarGreedyHuris;
                ArrangmentsChanged    = Arrangments;
                //Initiate Global Variables.
                Table = new int[8, 8];
                for (var ii = 0; ii < 8; ii++)
                {
                    for (var jj = 0; jj < 8; jj++)
                    {
                        Table[ii, jj] = Tab[ii, jj];
                    }
                }
                for (var ii = 0; ii < AllDraw.SodierMovments; ii++)
                {
                    SoldierThinking[ii] = new ThinkingRefrigtzChessPortable(ii, 1, CurrentAStarGredyMax, MovementsAStarGreedyHeuristicFoundT, IgnoreSelfObjectsT, UsePenaltyRegardMechnisamT, BestMovmentsT, PredictHeuristicT, OnlySelfT, AStarGreedyHeuristicT, ArrangmentsChanged, (int)i, (int)j, a, CloneATable(Tab), 4, Ord, TB, Cur, 16, 1);
                }
                Row     = i;
                Column  = j;
                color   = a;
                Order   = Ord;
                Current = Cur;
            }
        }
Ejemplo n.º 3
0
        //Table Foundation of Genetic Alogorithm Method.
        public int[,] GenerateTable(List <int[, ]> List, int Index, int Order)
        {
            //Initiate Local Variables.
Begine5:
            RowColumn.Clear();
            int Store = Index;

            int[,] Cromosom1 = null;
            int[,] Cromosom2 = null;
            try
            {
                Cromosom1 = List[List.Count - 2];
                Cromosom2 = List[List.Count + MinusOne];
            }
            catch (IndexOutOfRangeException t)
            {
                Log(t);

                return(null);
            }

            Index = Store;
            //Found of Gen.
            if (!FindGenToModified(Cromosom1, Cromosom2, List, Index, Order, false))
            {
                goto EndFindAThing;
            }



            //Initiate Global Variables.
BeginFind:
            int color = 1;

            if (Order == -1)
            {
                color = -1;
            }
            try
            {
                //If Cromosom Location is Not Founded.
                if (CromosomRow == -1 && CromosomColumn == -1)
                {
                    //Initiayte Local Variables.
                    List.RemoveAt(List.Count + MinusOne);
                    Index--;
                    goto Begine5;
                }
                //Found Kind Of Gen.
                Ki = List[List.Count + MinusOne][CromosomRow, CromosomColumn];
                //Initiate Local Variables.
                GeneticTable = new int[8, 8];
                //If Gen Kind Not Found Retrun Not Valididity.
                if (List[List.Count + MinusOne][CromosomRow, CromosomColumn] == 0)
                {
                    return(null);
                }
                else
                {
                    //Clone a Copy.
                    for (var ii = 0; ii < 8; ii++)
                    {
                        for (var jj = 0; jj < 8; jj++)
                        {
                            GeneticTable[ii, jj] = List[List.Count + MinusOne][ii, jj];
                        }
                    }
                }
                //Initiate Global and Local Variables.
                color = 1;
                if (Order == -1)
                {
                    color = -1;
                }
                //For All Gens.
                for (Gen1 = 0; Gen1 < 8; Gen1++)
                {
                    for (Gen2 = 0; Gen2 < 8; Gen2++)
                    {
                        //If Gen is Current Gen Location Continue Traversal Back.
                        if (Gen1 == CromosomRow && Gen2 == CromosomColumn)
                        {
                            continue;
                        }
                        //Rulement of Gen Movments.
                        if ((new ChessRules(0, MovementsAStarGreedyHeuristicFoundT, IgnoreSelfobjectsT, UsePenaltyRegardMechnisamT, BestMovmentsT, PredictHeuristicT, OnlySelfT, AStarGreedyHeuristicT, ArrangmentsChanged, GeneticTable[CromosomRow, CromosomColumn], CloneATable(GeneticTable), Order, CromosomRow, CromosomColumn)).Rules(CromosomRow, CromosomColumn, Gen1,
                                                                                                                                                                                                                                                                                                                                             Gen2, color, GeneticTable[CromosomRow, CromosomColumn]))
                        {
                            //Initiate Global Variables and Syntax.
                            int[] A = new int[2];
                            A[0] = CromosomRow;
                            A[1] = CromosomColumn;
                            RowColumn.Add(A);



                            GeneticTable[Gen1, Gen2] = GeneticTable[CromosomRow, CromosomColumn];
                            GeneticTable[CromosomRow, CromosomColumn] = 0;
                            //Table Repeatative Consideration.
                            if (ThinkingRefrigtzChessPortable.ExistTableInList(CloneATable(GeneticTable), List, 0))
                            {
                                GeneticTable[CromosomRow, CromosomColumn] = GeneticTable[Gen1, Gen2];
                                GeneticTable[Gen1, Gen2] = 0;
                                continue;
                            }
                            else
                            {
                                //Check Consideration.
                                if ((new ChessRules(0, MovementsAStarGreedyHeuristicFoundT, IgnoreSelfobjectsT, UsePenaltyRegardMechnisamT, BestMovmentsT, PredictHeuristicT, OnlySelfT, AStarGreedyHeuristicT, ArrangmentsChanged, GeneticTable[CromosomRow, CromosomRow], CloneATable(GeneticTable), Order, CromosomRow, CromosomColumn)).Check(CloneATable(GeneticTable), Order))
                                {
                                    GeneticTable[CromosomRow, CromosomColumn] = GeneticTable[Gen1, Gen2];
                                    GeneticTable[Gen1, Gen2] = 0;
                                    continue;
                                }

                                else
                                {
                                    //Return Genetic Table.
                                    return(GeneticTable);
                                }
                            }
                        }
                    }
                }
                //Initiate Try Catch.
                GeneticTable = null;
                int a = GeneticTable[0, 0];
            }

            catch (NullReferenceException t)
            { Log(t);
              //Try Catch Expetion Handling of Not Successful Foundation of Gen.

              if (Order == 1)
              {
                  Ki = (new Random()).Next(1, 7);
              }
              else
              {
                  Ki = (new Random()).Next(1, 7) * -1;
              }

              if (Order == 1)
              {
                  int Count = 0;
                  do
                  {
                      if (Ki < 6)
                      {
                          Ki++;
                      }
                      else
                      {
                          Ki = 1;
                      }
                      Count++;
                  } while (Count < 6 && !(new ChessRules(0, MovementsAStarGreedyHeuristicFoundT, IgnoreSelfobjectsT, UsePenaltyRegardMechnisamT, BestMovmentsT, PredictHeuristicT, OnlySelfT, AStarGreedyHeuristicT, ArrangmentsChanged, Ki, List[List.Count + MinusOne], Order, CromosomRow, CromosomColumn)).FindAThing(List[List.Count + MinusOne], ref CromosomRow, ref CromosomColumn, Ki, true, RowColumn));
                  if (Count >= 6)
                  {
                      NoGameFounf = true;
                      return(null);
                  }
              }
              else
              {
                  int Count = 0;
                  do
                  {
                      if (Ki > -6)
                      {
                          Ki--;
                      }
                      else
                      {
                          Ki = -1;
                      }
                      Count++;
                  } while (Count < 6 && !(new ChessRules(0, MovementsAStarGreedyHeuristicFoundT, IgnoreSelfobjectsT, UsePenaltyRegardMechnisamT, BestMovmentsT, PredictHeuristicT, OnlySelfT, AStarGreedyHeuristicT, ArrangmentsChanged, Ki, List[List.Count + MinusOne], Order, CromosomRow, CromosomColumn)).FindAThing(List[List.Count + MinusOne], ref CromosomRow, ref CromosomColumn, Ki, true, RowColumn));
                  if (Count >= 6)
                  {
                      NoGameFounf = true;
                      return(null);
                  }
              }

              goto BeginFind; }

EndFindAThing:
            //Foudn of Some Samness Gen.
            if (Order == 1)
            {
                Ki = (new Random()).Next(1, 7);
            }
            else
            {
                Ki = (new Random()).Next(1, 7) * -1;
            }
            if (Order == 1)
            {
                int Count = 0;
                do
                {
                    if (Ki < 6)
                    {
                        Ki++;
                    }
                    else
                    {
                        Ki = 1;
                    }
                    Count++;
                } while (Count < 6 && !(new ChessRules(0, MovementsAStarGreedyHeuristicFoundT, IgnoreSelfobjectsT, UsePenaltyRegardMechnisamT, BestMovmentsT, PredictHeuristicT, OnlySelfT, AStarGreedyHeuristicT, ArrangmentsChanged, Ki, List[List.Count + MinusOne], Order, CromosomRow, CromosomColumn)).FindAThing(List[List.Count + MinusOne], ref CromosomRow, ref CromosomColumn, Ki, true, RowColumn));
                if (Count >= 6)
                {
                    return(null);
                }
            }
            else
            {
                int Count = 0;
                do
                {
                    if (Ki > -6)
                    {
                        Ki--;
                    }
                    else
                    {
                        Ki = -1;
                    }
                    Count++;
                } while (Count < 6 && !(new ChessRules(0, MovementsAStarGreedyHeuristicFoundT, IgnoreSelfobjectsT, UsePenaltyRegardMechnisamT, BestMovmentsT, PredictHeuristicT, OnlySelfT, AStarGreedyHeuristicT, ArrangmentsChanged, Ki, List[List.Count + MinusOne], Order, CromosomRow, CromosomColumn)).FindAThing(List[List.Count + MinusOne], ref CromosomRow, ref CromosomColumn, Ki, true, RowColumn));
                if (Count >= 6)
                {
                    return(null);
                }
            }

            goto BeginFind;
        }