Exemplo n.º 1
0
        private static void Day11()
        {
            var currentState = new BuildingState(new List <char> {
                'P', 'T', 'Z', 'R', 'C', 'E', 'D'
            });

            currentState.ElevatorLocation = 0;
            currentState.SetChipLocation('P', 1);
            currentState.SetGeneratorLocation('P', 0);
            currentState.SetChipLocation('T', 0);
            currentState.SetGeneratorLocation('T', 0);
            currentState.SetChipLocation('Z', 1);
            currentState.SetGeneratorLocation('Z', 0);
            currentState.SetChipLocation('R', 0);
            currentState.SetGeneratorLocation('R', 0);
            currentState.SetChipLocation('C', 0);
            currentState.SetGeneratorLocation('C', 0);
            currentState.SetChipLocation('E', 0);
            currentState.SetGeneratorLocation('E', 0);
            currentState.SetChipLocation('D', 0);
            currentState.SetGeneratorLocation('D', 0);

            var stateTraverser = new StateTraverser();

            var goalState = BuildingState.CreateGoalState(currentState);

            var stepsToGoalState = stateTraverser.GetStepsToGoalState(currentState, goalState);

            Console.WriteLine("Steps: " + stepsToGoalState);
        }
Exemplo n.º 2
0
        public static BuildingState BuildingState(int numberOfElements)
        {
            var elementNames  = ElementNames(numberOfElements);
            var buildingState = new BuildingState(elementNames);

            for (var i = 0; i < numberOfElements; i++)
            {
                var elementName = elementNames[i];
                buildingState.SetChipLocation(elementName, Floor());
                buildingState.SetGeneratorLocation(elementName, Floor());
            }

            buildingState.ElevatorLocation = Floor();

            return(buildingState);
        }