Esempio n. 1
0
            public List <Move> GetValidMoves()
            {
                var validMoves = new List <Move>();
                var floor      = Floors.First(f => f.FloorNum == Elevator.FloorNum);

                var possibleElevatorItems = GetFloorElevatorItems(floor);

                if (floor.FloorNum < Floors.Count)
                {
                    var destFloor = Floors.First(f => f.FloorNum == (floor.FloorNum + 1));
                    foreach (var elevatorItems in possibleElevatorItems)
                    {
                        var move = new Move()
                        {
                            StartFloorNum = floor.FloorNum,
                            EndFloorNum   = destFloor.FloorNum,
                            Items         = elevatorItems
                        };

                        if (MoveResultIsValid(move))
                        {
                            validMoves.Add(move);
                        }
                    }
                }

                if (floor.FloorNum > 1)
                {
                    var destFloor = Floors.First(f => f.FloorNum == (floor.FloorNum - 1));
                    //foreach (var elevatorItems in possibleElevatorItems.Where(e=>e.Count()==1 && e.Any(i=>i.ItemType==ItemType.microchip)))
                    foreach (var elevatorItems in possibleElevatorItems)
                    {
                        var move = new Move()
                        {
                            StartFloorNum = floor.FloorNum,
                            EndFloorNum   = destFloor.FloorNum,
                            Items         = elevatorItems
                        };

                        if (MoveResultIsValid(move))
                        {
                            validMoves.Add(move);
                        }
                        //if (MoveResultIsValid(move))
                        //{
                        //    validMoves.Add(move);
                        //    Facility.Previous.Add();
                        //}
                    }
                }

                return(validMoves);
            }
Esempio n. 2
0
 private Floor CloneFloor(int floorNum)
 {
     return(Floors.First(f => f.FloorNum == floorNum).Clone());
 }