• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Br@inf*ck UNO Card Checker MetHorn   Nov 23rd, 2019 170 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. This program is a modified solution to the
2. Habitica Programming Challenge Guild
3. November '19 challenge
4.
5. It checks if one UNO hand card could be
6. dropped onto the top card on the pile
7.
8. Written by MetHorn
9.
10. Tested with online BF interpreter at
11. https://copy(dot)sh/brainfuck/
12.
13. Input Registers:
14. Register R0 and R1 = card value (0 to 9)
15. Register R2 and R3 = color (g = green | r = red
16. | n = blue | y = yellow)
17.
18. Return values:
19. 0 = Card can't be played
20. 1 = Card can be played
21.
22.
23. Lets start:
24.    Init Flag in R4 to 1 = Card can be played
25.    >>>>+<<<<
26.
27.    Read hand card value to R0 and
28.    increment pointer
29.    ,>
30.
31.    Read pile card value to R1 and inc p
32.    ,>
33.
34.    Read hand card color to R2 and inc p
35.    ,>
36.
37.    Read pile card color to R3
38.    ,
39.
40.    Pointer back to R1
41.    <<
42.
43.    Now lets compare the card values
44.    [<->-] Decrement R0 and R1 until R1 is 0
45.    < Back to R0
46.
47.    [ This block is only executed if R0 != 0
48.        Since the values are different check
49.        the colors now
50.        [-] R0 = 0
51.        >>> Pointer to R3
52.        [<->-] Decrement R2 and R3 until R3 is 0
53.        < Back to R2
54.
55.        [ This block is only executed if R2 != 0
56.            The values and colors are both different
57.            so the card in hand can't be played
58.            We have to return ASCII '0' which is 48
59.            Lets put 7*7-1 in R1
60.            << Pointer to R0
61.            [-] R0 =0
62.            +++++++ R0 = 7
63.            [>+++++++<-] R1 = R0 multiplied by 7
64.            >- Subb 1 from R1
65.            . Print R1
66.            >>>-<< Reset Flag at R4 and
67.            Pointer back to R2
68.            [-] R2 = 0
69.        ]
70.        << Pointer to R0
71.    ]
72.
73.    >>>> Pointer to R4 (Flag Card can be played)
74.    [ This block is only executed if R4 = 1
75.        If cards have same value and/or same
76.        color return 1
77.        So we have to return ASCII '1' which is 49
78.        Lets put 7*7 in R1
79.        <<<< Pointer to R0
80.        [-] R0 = 0
81.        +++++++ R0 = 7
82.        [>+++++++<-] R1 = R0 multiplied by 7
83.        >. Print R1
84.        < Pointer to R0
85.    ]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top