public static State CreateNewStateFromChipsList(ChipsList lst_chips)
        {
            State new_state = new State(lst_chips);

            new_state.StateEvaluation();
            new_state.ReachGoal();
            return(new_state);
        }
Beispiel #2
0
        public static List <State> ReadStatesFromFile(string filename)
        {
            List <State>          states      = new List <State>();
            List <List <string> > arrs_string = ReadStringArraysFromFile(filename);

            foreach (List <string> arr_str in arrs_string)
            {
                ChipsList cplst = new ChipsList();
                foreach (string str in arr_str)
                {
                    Color color = dict_string_color[str];
                    cplst.Add(new Chip(color));
                }
                State new_init_state = State.CreateNewStateFromChipsList(cplst);
                states.Add(new_init_state);
            }
            return(states);
        }
        public static bool operator ==(State a, State b)
        {
            ChipsList ChipsListA = a.mChipsList;
            ChipsList ChipsListB = b.mChipsList;

            if (ChipsListA.Count == ChipsListB.Count)
            {
                for (int i = 0; i < ChipsListA.Count; i++)
                {
                    if (ChipsListA[i] != ChipsListB[i])
                    {
                        return(false);
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private State(ChipsList lst_chips)
        {
            this.mChipsList = lst_chips;
            int how_many_empty_space = 0;

            for (int i = 0; i < this.mChipsList.Count; i++)
            {
                if (this.mChipsList[i].mChipColor == Color.Transparent)
                {
                    how_many_empty_space++;
                    this.mCurrentEmptySpaceIndex = i;
                }
                if (how_many_empty_space > 1)
                {
                    throw new Exception("There are more than one empty space in the configuration!!");
                }
            }
            if (how_many_empty_space == 0)
            {
                throw new Exception("There is no empty space in the configuration!!");
            }
        }