def findClosestRoom (room, roomList):
    """
        Finds the closest room to 'room' in the roomList.
        Distance is calculated by rectangle centers.
    """
    currentClosest = None
    closestDistance = None
    roomCenter = (room[0] + (room[0] + room[2]) // 2,
                  room[1] + (room[1] + room[3]) // 2)
    for compareRoom in roomList:
        compareCenter = (compareRoom[0] + (compareRoom[0] + compareRoom[2]) // 2,
                         compareRoom[1] + (compareRoom[1] + compareRoom[3]) // 2)
        dist = ((compareCenter[0] - roomCenter[0]) ** 2 + (compareCenter[1] - roomCenter[1]) ** 2) ** 0.5
        if currentClosest != None and dist < closestDistance:
            currentClosest = compareRoom
            closestDistance = dist
        elif currentClosest == None:
            currentClosest = compareRoom
            closestDistance = dist
    return currentClosest