Beispiel #1
0
        // Constructor for successor states
        public State(int leftCannibals, int leftMissionaries, int rightCannibals, int rightMissionaries, string boatWas)
        {
            id = idCount;
            idCount++;

            riverBankLeft  = new RiverBank(leftCannibals, leftMissionaries);
            riverBankRight = new RiverBank(rightCannibals, rightMissionaries);
            if (boatWas == LEFT)
            {
                boatIs = RIGHT;
            }
            else if (boatWas == RIGHT)
            {
                boatIs = LEFT;
            }

            this.HeuristicValue = CalculateHeuristicValue();
        }
Beispiel #2
0
        // Constructor for Initial and Goal State
        public State(string type)
        {
            if (type == "initial")
            {
                id = idCount;
                idCount++;

                riverBankLeft  = new RiverBank(3, 3);
                riverBankRight = new RiverBank(0, 0);
                boatIs         = LEFT;
            }
            else if (type == "goal")
            {
                riverBankLeft  = new RiverBank(0, 0);
                riverBankRight = new RiverBank(3, 3);
                boatIs         = RIGHT;
            }

            this.HeuristicValue = CalculateHeuristicValue();
        }