if (behaviorInState == 0) {
	behaviorOutTrafficSignal = Green( );
	behaviorOutPedestrianSignal = Stop( );
	behaviorOutIndicatorSignal = Off( );
	behaviorOutTime = -1;
	behaviorOutState = 1;
	return;
}

if (behaviorInState == 1) {
	if (behaviorInRequest == Present( ) && behaviorInTime == -1) {
		behaviorOutTrafficSignal = Green( );
		behaviorOutPedestrianSignal = Stop( );
		behaviorOutIndicatorSignal = On( );
		behaviorOutTime = tGreen( );
		behaviorOutState = 1;
		return;
	}
	if (behaviorInTime > 0) {
		behaviorOutTime = behaviorInTime - 1;
		behaviorOutState = 1;
		return;
	}
	if (behaviorInTime == 0) {
		behaviorOutTrafficSignal = Yellow( );
		behaviorOutPedestrianSignal = Stop( );
		behaviorOutIndicatorSignal = On( );
		behaviorOutTime = tYellow( );
		behaviorOutState = 2;
		return;
	}
}

if (behaviorInState == 2) {
	if (behaviorInTime > 0) {
		behaviorOutTime = behaviorInTime - 1;
		behaviorOutState = 2;
		return;
	}
	if (behaviorInTime == 0) {
		behaviorOutTrafficSignal = Red( );
		behaviorOutPedestrianSignal = Walk( );
		behaviorOutIndicatorSignal = Off( );
		behaviorOutTime = tRed( );
		behaviorOutState = 3;
		return;
	}
}

if (behaviorInState == 3) {
	if (behaviorInTime > 0) {
		behaviorOutTime = behaviorInTime - 1;
		behaviorOutState = 3;
		return;
	}
	if (behaviorInTime == 0) {
		behaviorOutTrafficSignal = RedYellow( );
		behaviorOutPedestrianSignal = Stop( );
		behaviorOutIndicatorSignal = Off( );
		behaviorOutTime = tYellow( );
		behaviorOutState = 4;
		return;
	}
}

if (behaviorInState == 4) {
	if (behaviorInTime > 0) {
		behaviorOutTime = behaviorInTime - 1;
		behaviorOutState = 4;
		return;
	}
	if (behaviorInTime == 0) {
		behaviorOutTrafficSignal = Green( );
		behaviorOutPedestrianSignal = Stop( );
		behaviorOutIndicatorSignal = Off( );
		behaviorOutTime = -1;
		behaviorOutState = 1;
		return;
	}
}

behaviorOutTrafficSignal = NoVal;
behaviorOutPedestrianSignal = NoVal;
behaviorOutIndicatorSignal = NoVal;
behaviorOutState = behaviorInState;
behaviorOutTime = behaviorInTime;
