system "Arteinvivo's Labby I v2"
{
*************************************
*        System by Arteinvivo       *
*       request by mwilding 1981    *
*         on the VIP Lounge         *
*************************************
          Rx-ed by St0rm0r
-------------------------------------
           00-c0mpatible
-------------------------------------
You start with a 1,1 and obviously bet 2. If you win you restart.
If you lose you add onto the end as with a normal labby.
You then always bet the last one and the first 2.
Now each labby starts a new session when it begins.
After every winning bet
1. eliminate the first 2 and the last element of the labby.
2. you check to see whether the first bet of the labby is >=6
if so, copy the labby to labby2
work away element by element of labby 2 by creating a new labby per element
value divided by 10.
-------------------------------------
}
method "main"
begin
// section 1: do this once
while starting new session
    begin
    call "init"
    end

// section 2: do the tracking

// section 3: act on a loss
if red did not hit each time
    begin
    subtract 100% record"pro R"data record"bank R"data
    if flag "first bet R" true
        begin
        set flag "first bet R" false
        set list [1,1,2]record"labby R"data
        end
        else
        begin
        //add loss to the end of the labby
        put 1 record"labby R"data index
        loop until record"labby R"data index > record"labby R"data count
            begin
            add 1 record"labby R"data index
            end
        put 100% record"pro R"data record"labby R"data
        end
    end
if black did not hit each time
    begin
    subtract 100% record"pro B"data record"bank B"data
    if flag "first bet B" true
        begin
        set flag "first bet B" false
        set list [1,1,2]record"labby B"data
        end
        else
        begin
        //add loss to the end of the labby
        put 1 record"labby B"data index
        loop until record"labby B"data index > record"labby B"data count
            begin
            add 1 record"labby B"data index
            end
        put 100% record"pro B"data record"labby B"data
        end
    end

// section 4:act on a win
if red did hit each time
    begin
    add 100% record"pro R"data record"bank R"data
    if flag "first bet R" true
        begin
        call "reset R"
        end
        else
        begin
        //eliminate first two and last one
        if record"labby R"data count > 2
            begin
            clear record"temp"data
            put 3 record"labby R"data index
            loop until record"labby R"data index = record"labby R"data count
                begin
                put 100% record"labby R"data record"temp"data
                add 1 record"temp"data index
                add 1 record"labby R"data index
                end
            duplicate record"temp" record"labby R"
            end
            else
            begin
            clear record"labby R"data
            //call "reset R"
            end
        if record"labby R"data count = 0
            begin
            if record"bank R"data >=record"new high R"data
                begin
                call "reset R"
                end
                else
                begin
                if record"2nd labby R"data count > 0
                    begin
                    clear record"temp"data
                    put 1 record"2nd labby R"data index
                    put 100% record"2nd labby R"data record"to distribute"data
                    if record"2nd labby R"data index < record"2nd labby R"data count
                        begin
                        add 1 record"2nd labby R"data index
                        loop until record"2nd labby R"data index > record"2nd labby R"data count
                            begin
                            put 100% record"2nd labby R"data record"temp"data
                            add 1 record"temp"data index
                            add 1 record"2nd labby R"data index
                            end
                        duplicate record"temp" record"2nd labby R"
                        end
                    //make new 10 element max labby from the first element from 2nd labby
                    clear record"labby R"data
                    put 10% record"to distribute"data record"unit"data
                    put 100% record"unit"data number 0
                    put 100% number 0 record"unit"data
                    put 0 number 0
                    put 1 record"labby R"data index
                    loop until record"to distribute"data <= 0
                        begin
                        put 100% record"unit"data  record"labby R"data
                        add 1 record"labby R"data index
                        subtract 100% record"unit"data record"to distribute"data
                        end
                    end
                end
            end

        put 1 record"labby R"data index
        if record"labby R"data >= 6
            begin
            //goto end of 2nd labby
            put 1 record"2nd labby R"data index
            loop until record"2nd labby R"data index > record"2nd labby R"data count
                begin
                add 1 record"2nd labby R"data index
                end
            //transfer labby data to 2nd labby
            put 1 record"labby R"data index //take first element aside
            put 100% record"labby R"data record"to distribute"data
            add 1 record"labby R"data index
            loop until record"labby R"data index > record"labby R"data count //transfer the rest
                begin
                put 100% record"labby R"data record"2nd labby R"data
                add 1 record"2nd labby R"data index
                add 1 record"labby R"data index
                end
            //make new mawimum 10 element labby from the first element taken aside
            clear record"labby R"data
            put 10% record"to distribute"data record"unit"data
            put 100% record"unit"data number 0
            put 100% number 0 record"unit"data
            put 0 number 0
            put 1 record"labby R"data index
            loop until record"to distribute"data <= 0
                begin
                put 100% record"unit"data record"labby R"data
                add 1 record"labby R"data index
                subtract 100% record"unit"data record"to distribute"data
                end
            end
            else
            begin
            //continue labby betting
            end
        end
    end

if black did hit each time
    begin
    add 100% record"pro B"data record"bank B"data
    if flag "first bet B" true
        begin
        call "reset B"
        end
        else
        begin
        //eliminate first two and last one
        if record"labby B"data count > 2
            begin
            clear record"temp"data
            put 3 record"labby B"data index
            loop until record"labby B"data index = record"labby B"data count
                begin
                put 100% record"labby B"data record"temp"data
                add 1 record"temp"data index
                add 1 record"labby B"data index
                end
            duplicate record"temp" record"labby B"
            end
            else
            begin
            clear record"labby B"data
            //call "reset B"
            end
        if record"labby B"data count = 0
            begin
            if record"bank B"data >=record"new high B"data
                begin
                call "reset B"
                end
                else
                begin
                if record"2nd labby B"data count > 0
                    begin
                    clear record"temp"data
                    put 1 record"2nd labby B"data index
                    put 100% record"2nd labby B"data record"to distribute"data
                    if record"2nd labby B"data index < record"2nd labby B"data count
                        begin
                        add 1 record"2nd labby B"data index
                        loop until record"2nd labby B"data index > record"2nd labby B"data count
                            begin
                            put 100% record"2nd labby B"data record"temp"data
                            add 1 record"temp"data index
                            add 1 record"2nd labby B"data index
                            end
                        duplicate record"temp" record"2nd labby B"
                        end
                    //make new 10 element max labby from the first element from 2nd labby
                    clear record"labby B"data
                    put 10% record"to distribute"data record"unit"data
                    put 100% record"unit"data number 0
                    put 100% number 0 record"unit"data
                    put 0 number 0
                    put 1 record"labby B"data index
                    loop until record"to distribute"data <= 0
                        begin
                        put 100% record"unit"data  record"labby B"data
                        add 1 record"labby B"data index
                        subtract 100% record"unit"data record"to distribute"data
                        end
                    end
                end
            end

        put 1 record"labby B"data index
        if record"labby B"data >= 6
            begin
            //goto end of 2nd labby
            put 1 record"2nd labby B"data index
            loop until record"2nd labby B"data index > record"2nd labby B"data count
                begin
                add 1 record"2nd labby B"data index
                end
            //transfer labby data to 2nd labby
            put 1 record"labby B"data index //take first element aside
            put 100% record"labby B"data record"to distribute"data
            add 1 record"labby B"data index
            loop until record"labby B"data index > record"labby B"data count //transfer the rest
                begin
                put 100% record"labby B"data record"2nd labby B"data
                add 1 record"2nd labby B"data index
                add 1 record"labby B"data index
                end
            //make new mawimum 10 element labby from the first element taken aside
            clear record"labby B"data
            put 10% record"to distribute"data record"unit"data
            put 100% record"unit"data number 0
            put 100% number 0 record"unit"data
            put 0 number 0
            put 1 record"labby B"data index
            loop until record"to distribute"data <= 0
                begin
                put 100% record"unit"data record"labby B"data
                add 1 record"labby B"data index
                subtract 100% record"unit"data record"to distribute"data
                end
            end
            else
            begin
            //continue labby betting
            end
        end
    end

if flag "first bet R" false
    begin
    //calculate next bet
    put 0 record"pro R"data
    put 1 record"labby R"data index
    add 100% record"labby R"data record"pro R"data
    if record"labby R"data index < record"labby R"data count
        begin
        add 1 record"labby R"data index
        add 100% record"labby R"data record"pro R"data
        end
    if record"labby R"data index < record"labby R"data count
        begin
        loop until record"labby R"data index >= record"labby R"data count
            begin
            add 1 record"labby R"data index
            end
        add 100% record"labby R"data record"pro R"data
        end
    end
if flag "first bet B" false
    begin
    //calculate next bet
    put 0 record"pro B"data
    put 1 record"labby B"data index
    add 100% record"labby B"data record"pro B"data
    if record"labby B"data index < record"labby B"data count
        begin
        add 1 record"labby B"data index
        add 100% record"labby B"data record"pro B"data
        end
    if record"labby B"data index < record"labby B"data count
        begin
        loop until record"labby B"data index >= record"labby B"data count
            begin
            add 1 record"labby B"data index
            end
        add 100% record"labby B"data record"pro B"data
        end
    end

//bet
if flag "first bet R" true
    begin
    put 2 record"pro R"data
    end
if flag "first bet B" true
    begin
    put 2 record"pro B"data
    end

if record"P"data = 1 or record"P"data = 3
    begin
    put 100% record"pro R"data red
    end
if record"P"data = 2 or record"P"data = 3
    begin
    put 100% record"pro B"data black
    end
if record"P"data = 4
    begin
    if record"pro R"data > record"pro B"data
        begin
        put 100% record"pro R"data red
        subtract 100% record"pro B"data red
        end
    if record"pro B"data > record"pro R"data
        begin
        put 100% record"pro B"data black
        subtract 100% record"pro R"data black
        end
    end

end

// subroutines
method "init"
begin
group
    begin
    display "Arteinvivo's Labby I v2"
    display "------------------------------------------"
    input dropdown "Play
    1:= red only
    2:= black only
    3:= red and black full
    4:= red or black differential" record"P"data
    end
put 0 record"bank R"data
put 0 record"bank B"data
call "reset R"
call "reset B"
end

method "reset R"
begin
set flag "first bet R" true
clear record"labby R"data
clear record"2nd labby R"data
put 100% record"bank R"data record"new high R"data
end

method "reset B"
begin
set flag "first bet B" true
clear record"labby B"data
clear record"2nd labby B"data
put 100% record"bank B"data record"new high B"data
end
