コード例 #1
0
 public Day11Move(Day11Piece piece, int fromFloor, int toFloor)
 {
     pieces = new List <Day11Piece>();
     pieces.Add(piece);
     FromFloor = fromFloor;
     ToFloor   = toFloor;
 }
コード例 #2
0
 public bool Equals(Day11Piece other)
 {
     return(TypeName.Equals(other.TypeName) && Generator == other.Generator);
 }
コード例 #3
0
 public bool ConflictingPair(Day11Piece other) => (other.Generator != Generator) && other.TypeName != TypeName;
コード例 #4
0
 public bool MatchedPair(Day11Piece other) => (other.Generator != Generator) && other.TypeName == TypeName;
コード例 #5
0
 private void AddSingleMovesToAdjacentFloor(List <Day11Move> moves, int floor, Day11Piece pieceToMove)
 {
     if (floor > 0 && Math.Abs(floor - ElevatorFloor) == 1)
     {
         int  conflicts = 0;
         bool addedMove = false;
         foreach (var pieceDown in FloorPieces[floor])
         {
             if (pieceDown.MatchedPair(pieceToMove))
             {
                 addedMove = true;
                 moves.Add(new Day11Move(pieceToMove, ElevatorFloor, floor));
             }
             else if (pieceDown.Generator ^ pieceToMove.Generator)
             {
                 conflicts++;
             }
         }
         if (conflicts == 0 && addedMove == false)
         {
             moves.Add(new Day11Move(pieceToMove, ElevatorFloor, floor));
         }
     }
 }