Mindstorms - want to perform various tasks, but never two of the same in a row (and other restrictions)
This looks like a state machine.

Save the "state" of your program in a variable. The state will be which program to run, so 1, 2 or 3.

You will also need some more variables to track the previous state and how many times a program has run.

Code flow will be something like this:

next_state = 1
prev_state = 0
run_count = 0
begin loop
    compute_next_state
    switch next_state
        case 1: run program_1
        case 2: run program_2
        case 3: run program_3
    end switch
    if next_state == prev_state
        run_count = run_count + 1
    else
       run_count = 0
    end if
    prev_state = next_state
end loop


I left out the implementation of compute_next_state since you have that spelled out quite well in your diagram.