Kirjautuminen

Haku

Tehtävät

Keskustelu: Koodit: QB64: Ristinolla

terrist [17.10.2016 16:29:34]

#

'
' Ristinolla 2016
'
' Päivitetty wanha Jätkänshakki-peli QB64-versioksi.
' Pelataan hiirellä, oikea nappi aloittaa uuden pelin.
' Tekoälyä korjailtu hieman mutta edelleen älytön ;)

DIM Grid%(32, 25) ' ruudukko 32 x 24
RANDOMIZE TIMER: SCREEN _NEWIMAGE(641, 481, 256)

Alku:

_TITLE "XO"

_MOUSEHIDE

LINE (0, 0)-(640, 480), 7, BF ' harmaa tausta
FOR x% = 0 TO 32: FOR y% = 1 TO 24 ' ruudukko
        LINE (x% * 20, y% * 20 - 20)-(x% * 20 + 20, y% * 20), 8, B
        Grid%(x%, y%) = -1
NEXT: NEXT
_MOUSESHOW
game% = -1
muuvix% = 0

DO
    DO WHILE _MOUSEINPUT
        cx% = _MOUSEX: dx% = _MOUSEY

        rx% = INT(cx% / 20) + 1: ry% = (INT(dx% / 20)) + 1

        IF _MOUSEBUTTON(2) THEN GOTO Alku ' uusi peli

        IF _MOUSEBUTTON(1) THEN

            IF Grid%(rx%, ry%) = -1 AND game% = -1 THEN

                _MOUSEHIDE

                GOSUB Ruksi
                GOSUB Tietokone
                IF game% = 0 THEN _TITLE "XO - YOU LOSE!"
                IF game% = 1 THEN _TITLE "XO - YOU WIN!"
                IF game% = 2 THEN game% = -1

                _MOUSESHOW

            END IF
        END IF
    LOOP
LOOP

Ruksi:
Grid%(rx%, ry%) = 1
FOR f% = 1 TO 2
    x% = rx% * 20 - 19
    IF f% = 1 THEN y% = ry% * 20 - 18 ELSE y% = ry% * 20 - 3
    FOR r% = 1 TO 16
        LINE (x% + 1, y%)-(x% + 3, y% + 1), 1, BF
        LINE (x%, y%)-(x% + 1, y% + 1), 9, BF
        _DELAY 0.01
        x% = x% + 1
        IF f% = 1 THEN y% = y% + 1 ELSE y% = y% - 1
    NEXT r%
NEXT f%
RETURN

Nolla:
Grid%(x% + lisx%, y% + lisy%) = 0: muuvix% = x% + lisx%: muuviy% = y% + lisy%
FOR kulma% = 360 TO 1 STEP -5
    DRAW "bm" + STR$((x% + lisx%) * 20 - 9) + "," + STR$((y% + lisy%) * 20 - 10) + " ta" + STR$(kulma%) + " c4bl8l1"
    DRAW "bm" + STR$((x% + lisx%) * 20 - 10) + "," + STR$((y% + lisy%) * 20 - 10) + " ta" + STR$(kulma%) + " c12bl8l1"
    _DELAY 0.01
NEXT
RETURN

Tietokone:
FOR y% = 1 TO 24: FOR x% = 1 TO 28
        ' Jos 5 ruksia vaakaan
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y%) = 1 AND Grid%(x% + 2, y%) = 1 AND Grid%(x% + 3, y%) = 1 AND Grid%(x% + 4, y%) = 1 THEN game% = 1: GOTO Hyppy
        ' Jos 4 nollaa vaakaan
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y%) = 0 AND Grid%(x% + 2, y%) = 0 AND Grid%(x% + 3, y%) = 0 AND Grid%(x% + 4, y%) = 0 THEN game% = 0: lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y%) = 0 AND Grid%(x% + 2, y%) = 0 AND Grid%(x% + 3, y%) = 0 AND Grid%(x% + 4, y%) = -1 THEN game% = 0: lisx% = 4: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        ' 00_00
        IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y%) = 0 AND Grid%(x% + 2, y%) = -1 AND Grid%(x% + 3, y%) = 0 AND Grid%(x% + 4, y%) = 0 THEN game% = 0: lisx% = 2: lisy% = 0: GOSUB Nolla: GOTO Hyppy
NEXT x%: NEXT y%
FOR x% = 1 TO 32: FOR y% = 1 TO 20
        ' Jos 5 ruksia pystyyn
        IF Grid%(x%, y%) = 1 AND Grid%(x%, y% + 1) = 1 AND Grid%(x%, y% + 2) = 1 AND Grid%(x%, y% + 3) = 1 AND Grid%(x%, y% + 4) = 1 THEN game% = 1: GOTO Hyppy
        ' Jos 4 nollaa pystyyn
        IF Grid%(x%, y%) = -1 AND Grid%(x%, y% + 1) = 0 AND Grid%(x%, y% + 2) = 0 AND Grid%(x%, y% + 3) = 0 AND Grid%(x%, y% + 4) = 0 THEN game% = 0: lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 0 AND Grid%(x%, y% + 1) = 0 AND Grid%(x%, y% + 2) = 0 AND Grid%(x%, y% + 3) = 0 AND Grid%(x%, y% + 4) = -1 THEN game% = 0: lisx% = 0: lisy% = 4: GOSUB Nolla: GOTO Hyppy
        ' Jos OO_OO
        IF Grid%(x%, y%) = 0 AND Grid%(x%, y% + 1) = 0 AND Grid%(x%, y% + 2) = -1 AND Grid%(x%, y% + 3) = 0 AND Grid%(x%, y% + 4) = 0 THEN game% = 0: lisx% = 0: lisy% = 2: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
FOR x% = 1 TO 28: FOR y% = 1 TO 20
        ' Jos 5 ruksia alaviistoon
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% + 1) = 1 AND Grid%(x% + 2, y% + 2) = 1 AND Grid%(x% + 3, y% + 3) = 1 AND Grid%(x% + 4, y% + 4) = 1 THEN game% = 1: GOTO Hyppy
        ' Jos 4 nollaa alaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% + 1) = 0 AND Grid%(x% + 2, y% + 2) = 0 AND Grid%(x% + 3, y% + 3) = 0 AND Grid%(x% + 4, y% + 4) = 0 THEN game% = 0: lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y% + 1) = 0 AND Grid%(x% + 2, y% + 2) = 0 AND Grid%(x% + 3, y% + 3) = 0 AND Grid%(x% + 4, y% + 4) = -1 THEN game% = 0: lisx% = 4: lisy% = 4: GOSUB Nolla: GOTO Hyppy
        ' Jos OO_OO
        IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y% + 1) = 0 AND Grid%(x% + 2, y% + 2) = -1 AND Grid%(x% + 3, y% + 3) = 0 AND Grid%(x% + 4, y% + 4) = 0 THEN game% = 0: lisx% = 2: lisy% = 2: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
FOR x% = 1 TO 28: FOR y% = 5 TO 24
        ' Jos 5 ruksia ylaviistoon
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% - 1) = 1 AND Grid%(x% + 2, y% - 2) = 1 AND Grid%(x% + 3, y% - 3) = 1 AND Grid%(x% + 4, y% - 4) = 1 THEN game% = 1: GOTO Hyppy
        ' Jos 4 nollaa ylaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% - 1) = 0 AND Grid%(x% + 2, y% - 2) = 0 AND Grid%(x% + 3, y% - 3) = 0 AND Grid%(x% + 4, y% - 4) = 0 THEN game% = 0: lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y% - 1) = 0 AND Grid%(x% + 2, y% - 2) = 0 AND Grid%(x% + 3, y% - 3) = 0 AND Grid%(x% + 4, y% - 4) = -1 THEN game% = 0: lisx% = 4: lisy% = -4: GOSUB Nolla: GOTO Hyppy
        ' Jos OO_OO
        IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y% - 1) = 0 AND Grid%(x% + 2, y% - 2) = -1 AND Grid%(x% + 3, y% - 3) = 0 AND Grid%(x% + 4, y% - 4) = 0 THEN game% = 0: lisx% = 2: lisy% = -2: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
'----------------------------------------JOS XX_XX NIIN...
FOR y% = 1 TO 24: FOR x% = 1 TO 28
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y%) = 1 AND Grid%(x% + 2, y%) = -1 AND Grid%(x% + 3, y%) = 1 AND Grid%(x% + 4, y%) = 1 THEN lisx% = 2: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y%) = 1 AND Grid%(x% + 2, y%) = 1 AND Grid%(x% + 3, y%) = -1 AND Grid%(x% + 4, y%) = 1 THEN lisx% = 3: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y%) = -1 AND Grid%(x% + 2, y%) = 1 AND Grid%(x% + 3, y%) = 1 AND Grid%(x% + 4, y%) = 1 THEN lisx% = 1: lisy% = 0: GOSUB Nolla: GOTO Hyppy
NEXT x%: NEXT y%
FOR x% = 1 TO 32: FOR y% = 1 TO 20
        IF Grid%(x%, y%) = 1 AND Grid%(x%, y% + 1) = 1 AND Grid%(x%, y% + 2) = -1 AND Grid%(x%, y% + 3) = 1 AND Grid%(x%, y% + 4) = 1 THEN lisx% = 0: lisy% = 2: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x%, y% + 1) = 1 AND Grid%(x%, y% + 2) = 1 AND Grid%(x%, y% + 3) = -1 AND Grid%(x%, y% + 4) = 1 THEN lisx% = 0: lisy% = 3: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x%, y% + 1) = -1 AND Grid%(x%, y% + 2) = 1 AND Grid%(x%, y% + 3) = 1 AND Grid%(x%, y% + 4) = 1 THEN lisx% = 0: lisy% = 1: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
FOR x% = 1 TO 28: FOR y% = 1 TO 20
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% + 1) = 1 AND Grid%(x% + 2, y% + 2) = -1 AND Grid%(x% + 3, y% + 3) = 1 AND Grid%(x% + 4, y% + 4) = 1 THEN lisx% = 2: lisy% = 2: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% + 1) = 1 AND Grid%(x% + 2, y% + 2) = 1 AND Grid%(x% + 3, y% + 3) = -1 AND Grid%(x% + 4, y% + 4) = 1 THEN lisx% = 3: lisy% = 3: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% + 1) = -1 AND Grid%(x% + 2, y% + 2) = 1 AND Grid%(x% + 3, y% + 3) = 1 AND Grid%(x% + 4, y% + 4) = 1 THEN lisx% = 1: lisy% = 1: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
FOR x% = 1 TO 28: FOR y% = 5 TO 24
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% - 1) = 1 AND Grid%(x% + 2, y% - 2) = -1 AND Grid%(x% + 3, y% - 3) = 1 AND Grid%(x% + 4, y% - 4) = 1 THEN lisx% = 2: lisy% = -2: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% - 1) = 1 AND Grid%(x% + 2, y% - 2) = 1 AND Grid%(x% + 3, y% - 3) = -1 AND Grid%(x% + 4, y% - 4) = 1 THEN lisx% = 3: lisy% = -3: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% - 1) = -1 AND Grid%(x% + 2, y% - 2) = 1 AND Grid%(x% + 3, y% - 3) = 1 AND Grid%(x% + 4, y% - 4) = 1 THEN lisx% = 1: lisy% = -1: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
'----------------------------JOS 4 RUKSIA NIIN...
FOR y% = 1 TO 24: FOR x% = 1 TO 28
        ' Jos 4 ruksia vaakaan
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y%) = 1 AND Grid%(x% + 2, y%) = 1 AND Grid%(x% + 3, y%) = 1 AND Grid%(x% + 4, y%) = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y%) = 1 AND Grid%(x% + 2, y%) = 1 AND Grid%(x% + 3, y%) = 1 AND Grid%(x% + 4, y%) = -1 THEN lisx% = 4: lisy% = 0: GOSUB Nolla: GOTO Hyppy
NEXT x%: NEXT y%
FOR x% = 1 TO 32: FOR y% = 1 TO 20
        ' Jos 4 ruksia pystyyn
        IF Grid%(x%, y%) = -1 AND Grid%(x%, y% + 1) = 1 AND Grid%(x%, y% + 2) = 1 AND Grid%(x%, y% + 3) = 1 AND Grid%(x%, y% + 4) = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x%, y% + 1) = 1 AND Grid%(x%, y% + 2) = 1 AND Grid%(x%, y% + 3) = 1 AND Grid%(x%, y% + 4) = -1 THEN lisx% = 0: lisy% = 4: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
FOR x% = 1 TO 28: FOR y% = 1 TO 20
        ' Jos 4 ruksia alaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% + 1) = 1 AND Grid%(x% + 2, y% + 2) = 1 AND Grid%(x% + 3, y% + 3) = 1 AND Grid%(x% + 4, y% + 4) = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% + 1) = 1 AND Grid%(x% + 2, y% + 2) = 1 AND Grid%(x% + 3, y% + 3) = 1 AND Grid%(x% + 4, y% + 4) = -1 THEN lisx% = 4: lisy% = 4: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
FOR x% = 1 TO 28: FOR y% = 5 TO 24
        ' Jos 4 ruksia ylaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% - 1) = 1 AND Grid%(x% + 2, y% - 2) = 1 AND Grid%(x% + 3, y% - 3) = 1 AND Grid%(x% + 4, y% - 4) = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% - 1) = 1 AND Grid%(x% + 2, y% - 2) = 1 AND Grid%(x% + 3, y% - 3) = 1 AND Grid%(x% + 4, y% - 4) = -1 THEN lisx% = 4: lisy% = -4: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
'--------------------------------JOS KOLME SAMAA NIIN...
arv% = INT(RND * 2) + 1
FOR y% = 1 TO 24: FOR x% = 1 TO 28
        ' Jos 3 samaa vaakaan
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y%) = 1 AND Grid%(x% + 2, y%) = 1 AND Grid%(x% + 3, y%) = 1 AND Grid%(x% + 4, y%) = -1 THEN
            IF arv% = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
            IF arv% = 2 THEN lisx% = 4: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        END IF
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y%) = 0 AND Grid%(x% + 2, y%) = 0 AND Grid%(x% + 3, y%) = 0 AND Grid%(x% + 4, y%) = -1 THEN
            IF arv% = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
            IF arv% = 2 THEN lisx% = 4: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        END IF
NEXT x%: NEXT y%
FOR x% = 1 TO 32: FOR y% = 1 TO 20
        ' Jos 3 samaa pystyyn
        IF Grid%(x%, y%) = -1 AND Grid%(x%, y% + 1) = 1 AND Grid%(x%, y% + 2) = 1 AND Grid%(x%, y% + 3) = 1 AND Grid%(x%, y% + 4) = -1 THEN
            IF arv% = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
            IF arv% = 2 THEN lisx% = 0: lisy% = 4: GOSUB Nolla: GOTO Hyppy
        END IF
        IF Grid%(x%, y%) = -1 AND Grid%(x%, y% + 1) = 0 AND Grid%(x%, y% + 2) = 0 AND Grid%(x%, y% + 3) = 0 AND Grid%(x%, y% + 4) = -1 THEN
            IF arv% = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
            IF arv% = 2 THEN lisx% = 0: lisy% = 4: GOSUB Nolla: GOTO Hyppy
        END IF
NEXT y%: NEXT x%
FOR x% = 1 TO 28: FOR y% = 1 TO 20
        ' Jos 3 samaa alaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% + 1) = 1 AND Grid%(x% + 2, y% + 2) = 1 AND Grid%(x% + 3, y% + 3) = 1 AND Grid%(x% + 4, y% + 4) = -1 THEN
            IF arv% = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
            IF arv% = 2 THEN lisx% = 4: lisy% = 4: GOSUB Nolla: GOTO Hyppy
        END IF
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% + 1) = 0 AND Grid%(x% + 2, y% + 2) = 0 AND Grid%(x% + 3, y% + 3) = 0 AND Grid%(x% + 4, y% + 4) = -1 THEN
            IF arv% = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
            IF arv% = 2 THEN lisx% = 4: lisy% = 4: GOSUB Nolla: GOTO Hyppy
        END IF
NEXT y%: NEXT x%
FOR x% = 1 TO 28: FOR y% = 5 TO 24
        ' Jos 3 samaa ylaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% - 1) = 1 AND Grid%(x% + 2, y% - 2) = 1 AND Grid%(x% + 3, y% - 3) = 1 AND Grid%(x% + 4, y% - 4) = -1 THEN
            IF arv% = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
            IF arv% = 2 THEN lisx% = 4: lisy% = -4: GOSUB Nolla: GOTO Hyppy
        END IF
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% - 1) = 0 AND Grid%(x% + 2, y% - 2) = 0 AND Grid%(x% + 3, y% - 3) = 0 AND Grid%(x% + 4, y% - 4) = -1 THEN
            IF arv% = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
            IF arv% = 2 THEN lisx% = 4: lisy% = -4: GOSUB Nolla: GOTO Hyppy
        END IF
NEXT y%: NEXT x%
'--------------------------------JOS XX-X tai OO-O
FOR y% = 1 TO 24: FOR x% = 1 TO 28
        ' Jos XX-X tai OO-O vaakaan
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y%) = 1 AND Grid%(x% + 2, y%) = 1 AND Grid%(x% + 3, y%) = -1 AND Grid%(x% + 4, y%) = 1 THEN lisx% = 3: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y%) = 0 AND Grid%(x% + 2, y%) = 0 AND Grid%(x% + 3, y%) = -1 AND Grid%(x% + 4, y%) = 0 THEN lisx% = 3: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        ' Jos X-XX tai O-OO vaakaan
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y%) = 1 AND Grid%(x% + 2, y%) = -1 AND Grid%(x% + 3, y%) = 1 AND Grid%(x% + 4, y%) = 1 THEN lisx% = 2: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y%) = 0 AND Grid%(x% + 2, y%) = -1 AND Grid%(x% + 3, y%) = 0 AND Grid%(x% + 4, y%) = 0 THEN lisx% = 2: lisy% = 0: GOSUB Nolla: GOTO Hyppy
NEXT x%: NEXT y%
FOR x% = 1 TO 32: FOR y% = 1 TO 20
        ' Jos XX-X tai OO-O pystyyn
        IF Grid%(x%, y%) = -1 AND Grid%(x%, y% + 1) = 1 AND Grid%(x%, y% + 2) = 1 AND Grid%(x%, y% + 3) = -1 AND Grid%(x%, y% + 4) = 1 THEN lisx% = 0: lisy% = 3: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x%, y% + 1) = 0 AND Grid%(x%, y% + 2) = 0 AND Grid%(x%, y% + 3) = -1 AND Grid%(x%, y% + 4) = 0 THEN lisx% = 0: lisy% = 3: GOSUB Nolla: GOTO Hyppy
        ' Jos X-XX tai O-OO pystyyn
        IF Grid%(x%, y%) = -1 AND Grid%(x%, y% + 1) = 1 AND Grid%(x%, y% + 2) = -1 AND Grid%(x%, y% + 3) = 1 AND Grid%(x%, y% + 4) = 1 THEN lisx% = 0: lisy% = 2: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x%, y% + 1) = 0 AND Grid%(x%, y% + 2) = -1 AND Grid%(x%, y% + 3) = 0 AND Grid%(x%, y% + 4) = 0 THEN lisx% = 0: lisy% = 2: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
FOR x% = 1 TO 28: FOR y% = 1 TO 20
        ' alaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% + 1) = 1 AND Grid%(x% + 2, y% + 2) = 1 AND Grid%(x% + 3, y% + 3) = -1 AND Grid%(x% + 4, y% + 4) = 1 THEN lisx% = 3: lisy% = 3: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% + 1) = 0 AND Grid%(x% + 2, y% + 2) = 0 AND Grid%(x% + 3, y% + 3) = -1 AND Grid%(x% + 4, y% + 4) = 0 THEN lisx% = 3: lisy% = 3: GOSUB Nolla: GOTO Hyppy
        ' alaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% + 1) = 1 AND Grid%(x% + 2, y% + 2) = -1 AND Grid%(x% + 3, y% + 3) = 1 AND Grid%(x% + 4, y% + 4) = 1 THEN lisx% = 2: lisy% = 2: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% + 1) = 0 AND Grid%(x% + 2, y% + 2) = -1 AND Grid%(x% + 3, y% + 3) = 0 AND Grid%(x% + 4, y% + 4) = 0 THEN lisx% = 2: lisy% = 2: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
FOR x% = 1 TO 28: FOR y% = 5 TO 24
        ' ylaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% - 1) = 1 AND Grid%(x% + 2, y% - 2) = 1 AND Grid%(x% + 3, y% - 3) = -1 AND Grid%(x% + 4, y% - 4) = 1 THEN lisx% = 3: lisy% = -3: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% - 1) = 0 AND Grid%(x% + 2, y% - 2) = 0 AND Grid%(x% + 3, y% - 3) = -1 AND Grid%(x% + 4, y% - 4) = 0 THEN lisx% = 3: lisy% = -3: GOSUB Nolla: GOTO Hyppy
        ' ylaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% + 1) = 1 AND Grid%(x% + 2, y% - 2) = -1 AND Grid%(x% + 3, y% - 3) = 1 AND Grid%(x% + 4, y% - 4) = 1 THEN lisx% = 2: lisy% = -2: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% - 1) = 0 AND Grid%(x% + 2, y% - 2) = -1 AND Grid%(x% + 3, y% - 3) = 0 AND Grid%(x% + 4, y% - 4) = 0 THEN lisx% = 2: lisy% = -2: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
'--------------------------------JOS KOLME SAMAA NIIN...
FOR y% = 1 TO 24: FOR x% = 1 TO 29
        ' Jos 3 samaa vaakaan
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y%) = 1 AND Grid%(x% + 2, y%) = 1 AND Grid%(x% + 3, y%) = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y%) = 1 AND Grid%(x% + 2, y%) = 1 AND Grid%(x% + 3, y%) = -1 THEN lisx% = 3: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y%) = 0 AND Grid%(x% + 2, y%) = 0 AND Grid%(x% + 3, y%) = 0 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y%) = 0 AND Grid%(x% + 2, y%) = 0 AND Grid%(x% + 3, y%) = -1 THEN lisx% = 3: lisy% = 0: GOSUB Nolla: GOTO Hyppy
NEXT x%: NEXT y%
FOR x% = 1 TO 32: FOR y% = 1 TO 21
        ' Jos 3 samaa pystyyn
        IF Grid%(x%, y%) = -1 AND Grid%(x%, y% + 1) = 1 AND Grid%(x%, y% + 2) = 1 AND Grid%(x%, y% + 3) = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x%, y% + 1) = 1 AND Grid%(x%, y% + 2) = 1 AND Grid%(x%, y% + 3) = -1 THEN lisx% = 0: lisy% = 3: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x%, y% + 1) = 0 AND Grid%(x%, y% + 2) = 0 AND Grid%(x%, y% + 3) = 0 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 0 AND Grid%(x%, y% + 1) = 0 AND Grid%(x%, y% + 2) = 0 AND Grid%(x%, y% + 3) = -1 THEN lisx% = 0: lisy% = 3: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
FOR x% = 1 TO 29: FOR y% = 1 TO 21
        ' Jos 3 samaa alaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% + 1) = 1 AND Grid%(x% + 2, y% + 2) = 1 AND Grid%(x% + 3, y% + 3) = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% + 1) = 1 AND Grid%(x% + 2, y% + 2) = 1 AND Grid%(x% + 3, y% + 3) = -1 THEN lisx% = 3: lisy% = 3: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% + 1) = 0 AND Grid%(x% + 2, y% + 2) = 0 AND Grid%(x% + 3, y% + 3) = 0 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y% + 1) = 0 AND Grid%(x% + 2, y% + 2) = 0 AND Grid%(x% + 3, y% + 3) = -1 THEN lisx% = 3: lisy% = 3: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
FOR x% = 1 TO 29: FOR y% = 4 TO 24
        ' Jos 3 samaa ylaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% - 1) = 1 AND Grid%(x% + 2, y% - 2) = 1 AND Grid%(x% + 3, y% - 3) = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% - 1) = 1 AND Grid%(x% + 2, y% - 2) = 1 AND Grid%(x% + 3, y% - 3) = -1 THEN lisx% = 3: lisy% = -3: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% - 1) = 0 AND Grid%(x% + 2, y% - 2) = 0 AND Grid%(x% + 3, y% - 3) = 0 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y% - 1) = 0 AND Grid%(x% + 2, y% - 2) = 0 AND Grid%(x% + 3, y% - 3) = -1 THEN lisx% = 3: lisy% = -3: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
'---------------ARVOTAAN PELILIIKE----------------------------
arv% = INT(RND * 2) + 1
IF arv% = 1 THEN
    '------------------------------------JOS X_X TAI O_O NIIN...
    FOR y% = 1 TO 24: FOR x% = 1 TO 30
            ' vaakaan
            IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y%) = -1 AND Grid%(x% + 2, y%) = 1 THEN lisx% = 1: lisy% = 0: GOSUB Nolla: GOTO Hyppy
            IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y%) = -1 AND Grid%(x% + 2, y%) = 0 THEN lisx% = 1: lisy% = 0: GOSUB Nolla: GOTO Hyppy
    NEXT x%: NEXT y%
    FOR y% = 1 TO 22: FOR x% = 1 TO 32
            ' pystyyn
            IF Grid%(x%, y%) = 1 AND Grid%(x%, y% + 1) = -1 AND Grid%(x%, y% + 2) = 1 THEN lisx% = 0: lisy% = 1: GOSUB Nolla: GOTO Hyppy
            IF Grid%(x%, y%) = 0 AND Grid%(x%, y% + 1) = -1 AND Grid%(x%, y% + 2) = 0 THEN lisx% = 0: lisy% = 1: GOSUB Nolla: GOTO Hyppy
    NEXT x%: NEXT y%
    FOR y% = 1 TO 22: FOR x% = 1 TO 30
            ' alaviistoon
            IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% + 1) = -1 AND Grid%(x% + 2, y% + 2) = 1 THEN lisx% = 1: lisy% = 1: GOSUB Nolla: GOTO Hyppy
            IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y% + 1) = -1 AND Grid%(x% + 2, y% + 2) = 0 THEN lisx% = 1: lisy% = 1: GOSUB Nolla: GOTO Hyppy
    NEXT x%: NEXT y%
    FOR y% = 3 TO 24: FOR x% = 1 TO 30
            ' alaviistoon
            IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% - 1) = -1 AND Grid%(x% + 2, y% - 2) = 1 THEN lisx% = 1: lisy% = -1: GOSUB Nolla: GOTO Hyppy
            IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y% - 1) = -1 AND Grid%(x% + 2, y% - 2) = 0 THEN lisx% = 1: lisy% = -1: GOSUB Nolla: GOTO Hyppy
    NEXT x%: NEXT y%
END IF
'------------------------------------JOS KAKSI SAMAA NIIN...
FOR y% = 1 TO 24: FOR x% = 1 TO 30
        ' Jos 2 samaa vaakaan
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y%) = 0 AND Grid%(x% + 2, y%) = 0 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y%) = 0 AND Grid%(x% + 2, y%) = -1 THEN lisx% = 2: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y%) = 1 AND Grid%(x% + 2, y%) = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y%) = 1 AND Grid%(x% + 2, y%) = -1 THEN lisx% = 2: lisy% = 0: GOSUB Nolla: GOTO Hyppy
NEXT x%: NEXT y%
FOR x% = 1 TO 32: FOR y% = 1 TO 22
        ' Jos 2 samaa pystyyn
        IF Grid%(x%, y%) = -1 AND Grid%(x%, y% + 1) = 0 AND Grid%(x%, y% + 2) = 0 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 0 AND Grid%(x%, y% + 1) = 0 AND Grid%(x%, y% + 2) = -1 THEN lisx% = 0: lisy% = 2: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x%, y% + 1) = 1 AND Grid%(x%, y% + 2) = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x%, y% + 1) = 1 AND Grid%(x%, y% + 2) = -1 THEN lisx% = 0: lisy% = 2: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
FOR x% = 1 TO 30: FOR y% = 1 TO 22
        ' Jos 2 samaa alaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% + 1) = 0 AND Grid%(x% + 2, y% + 2) = 0 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y% + 1) = 0 AND Grid%(x% + 2, y% + 2) = -1 THEN lisx% = 2: lisy% = 2: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% + 1) = 1 AND Grid%(x% + 2, y% + 2) = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% + 1) = 1 AND Grid%(x% + 2, y% + 2) = -1 THEN lisx% = 2: lisy% = 2: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
FOR x% = 1 TO 30: FOR y% = 3 TO 24
        ' Jos 2 samaa ylaviistoon
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% - 1) = 0 AND Grid%(x% + 2, y% - 2) = 0 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 0 AND Grid%(x% + 1, y% - 1) = 0 AND Grid%(x% + 2, y% - 2) = -1 THEN lisx% = 2: lisy% = -2: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = -1 AND Grid%(x% + 1, y% - 1) = 1 AND Grid%(x% + 2, y% - 2) = 1 THEN lisx% = 0: lisy% = 0: GOSUB Nolla: GOTO Hyppy
        IF Grid%(x%, y%) = 1 AND Grid%(x% + 1, y% - 1) = 1 AND Grid%(x% + 2, y% - 2) = -1 THEN lisx% = 2: lisy% = -2: GOSUB Nolla: GOTO Hyppy
NEXT y%: NEXT x%
'---------------ARVOTAAN SEURAAVA PELILIIKE----------------------------
DO
    arv% = INT(RND * 2) + 1: xx% = INT(RND * 3): yy% = INT(RND * 3)
    IF xx% = 2 THEN xx% = -1
    IF yy% = 2 THEN yy% = -1
    IF arv% = 2 AND muuvix% <> 0 THEN rx% = muuvix%: ry% = muuviy%
    IF rx% + xx% > 0 AND rx% + xx% < 33 AND ry% + yy% > 0 AND ry% + yy% < 25 THEN
        IF Grid%(rx% + xx%, ry% + yy%) = -1 THEN
            x% = rx%: y% = ry%: lisx% = xx%: lisy% = yy%: GOSUB Nolla
            EXIT DO
        END IF
    END IF
LOOP
Hyppy:
RETURN

Vastaus

Aihe on jo aika vanha, joten et voi enää vastata siihen.

Tietoa sivustosta