public Day11Move(Day11Piece piece, int fromFloor, int toFloor) { pieces = new List <Day11Piece>(); pieces.Add(piece); FromFloor = fromFloor; ToFloor = toFloor; }
public bool Equals(Day11Piece other) { return(TypeName.Equals(other.TypeName) && Generator == other.Generator); }
public bool ConflictingPair(Day11Piece other) => (other.Generator != Generator) && other.TypeName != TypeName;
public bool MatchedPair(Day11Piece other) => (other.Generator != Generator) && other.TypeName == TypeName;
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)); } } }