플러드 필
고정 메모리 방법(오른손 채우기 방법) > 의사코드

다음은 최적의 고정 메모리 플러드 필 알고리즘의 의사코드 수행이다:
변수:
cur, mark, 그리고 mark2는 각각 픽셀의 좌표나 널 값을 가진다
    참고: mark가 널 값으로 설정 된다면, 이전 좌표 값을 지우면 안 된다.
        이 좌표들은 필요할 때마다 불러올 수 있게 해야 한다.
cur-dir, mark-dir, 그리고 mark2-dir는 각각 방향을 가진다 (왼쪽, 오른쪽, 위, 또는 아래)
backtrack과 findloop은 각각 논릿값을 가진다
count는 정수이다
알고리즘:
(참고: 모든 방향(front, back, left, right)은 cur-dir에 대해서 상대적이다)
set cur to starting pixel
set cur-dir to default direction
clear mark and mark2 (set values to null)
set backtrack and findloop to false

while front-pixel is empty
    move forward
end while

jump to START

MAIN LOOP:
    move forward
    if right-pixel is empty
        if backtrack is true and findloop is false and either front-pixel or left-pixel is empty
            set findloop to true
        end if
        turn right
PAINT:
        move forward
    end if
START:
    set count to number of non-diagonally adjacent pixels filled (front/back/left/right ONLY)
    if count is not 4
        do
            turn right
        while front-pixel is empty
        do
            turn left
        while front-pixel is filled
    end if
    switch count
        case 1
            if backtrack is true
                set findloop to true
            else if findloop is true
                if mark is null
                    restore mark
                end if
            else if front-left-pixel and back-left-pixel are both empty
                clear mark
                fill cur
                jump to PAINT
            end if
        end case
        case 2
            if back-pixel is filled
                if front-left-pixel is not filled
                    clear mark
                    fill cur
                    jump to PAINT
                end if
            else if mark is not set
                set mark to cur
                set mark-dir to cur-dir
                clear mark2
                set findloop and backtrack to false
            else
                if mark2 is not set
                    if cur is at mark
                        if cur-dir is the same as mark-dir
                            clear mark
                            turn around
                            fill cur
                            jump to PAINT
                        else
                            set backtrack to true
                            set findloop to false
                            set cur-dir to mark-dir
                        end if
                    else if findloop is true
                        set mark2 to cur
                        set mark2-dir to cur-dir
                    end if
                else
                    if cur is at mark
                        set cur to mark2
                        set cur-dir to mark2-dir
                        clear mark and mark2
                        set backtrack to false
                        turn around
                        fill cur
                        jump to PAINT
                    else if cur at mark2
                        set mark to cur
                        set cur-dir and mark-dir to mark2-dir
                        clear mark2
                    end
                end if
            end if
        end case
        case 3
            clear mark
            fill cur
            jump to PAINT
        end case
        case 4
            fill cur
            done
        end case
    end switch
end MAIN LOOP