'=========================================================================== ' Subject: CREATE RANDOM FULL SCREEN MAZES Date: 02-27-99 (20:08) ' Author: Darryl R. Waltz Code: QB, QBasic, PDS ' Origin: drw@telusplanet.net Packet: GRAPHICS.ABC '=========================================================================== ' Program creates random full screen maps ' MAZE.bas SCREEN 1: 'DEFSNG A-Z DIM pk%(1000), rd(15), dr(10), ns(2, 2, 2, 2), ew(2, 2, 2, 2), p(11, 29, 4), rr(200), cc(200), q%(1000), pp%(26000), f(109, 109), qq%(100): 'RANDOMIZE TIMER 'DIM rr(100) CLS COLOR 1, 13 RANDOMIZE TIMER LINE (0, 0)-(7, 7), 7, BF: GET (0, 0)-(7, 7), q%: CLS COLOR 0: LINE (0, 0)-(7, 7), , BF: GET (0, 0)-(7, 7), qq%: CLS r = INT(RND * 5) + 1: r = r * 2: c = INT(RND * 5) + 1: c = c * 2: f(r, c) = 2: rrr = r: ccc = c c1: ERASE dr: ck = 0: x = x + 1: rr(x) = r: : cc(x) = c c: IF ck = 4 THEN x = x - 1: IF x = 0 THEN GOTO d ELSE r = rr(x): c = cc(x): ck = 0: ERASE dr 10 rd = INT(RND * 4) + 1: IF dr(rd) = -1 THEN 10 1 IF rd = 1 AND f(ABS(r - 2), c) = 0 AND r - 2 > 1 THEN r = r - 1: f(r, c) = 1: r = r - 1: f(r, c) = 1: GOTO c1 2 IF rd = 2 AND f(ABS(r + 2), c) = 0 AND r + 2 < 25 THEN r = r + 1: f(r, c) = 1: r = r + 1: f(r, c) = 1: GOTO c1 3 IF rd = 3 AND f(r, ABS(c - 2)) = 0 AND c - 2 > 1 THEN c = c - 1: f(r, c) = 1: c = c - 1: f(r, c) = 1: GOTO c1 4 IF rd = 4 AND f(r, ABS(c + 2)) = 0 AND c + 2 < 40 THEN c = c + 1: f(r, c) = 1: c = c + 1: f(r, c) = 1: GOTO c1 dr(rd) = -1: ck = ck + 1 GOTO c d: FOR r = 10 TO rrr FOR c = 10 TO ccc e = e + 1: IF e = 3 THEN e = 1 IF f(r, c) = 0 THEN GOTO 25 FOR t = 1 TO 4 ON t GOTO s1, s2, s3, s4 s1: p(r, c, t) = ns(f(r, c - 1), f(r - 1, c), f(r, c + 1), e): GOTO t5 s2: p(r, c, t) = ew(f(r - 1, c), f(r, c + 1), f(r + 1, c), e): GOTO t5 s3: p(r, c, t) = ns(f(r, c + 1), f(r + 1, c), f(r, c - 1), e): GOTO t5 s4: p(r, c, t) = ew(f(r + 1, c), f(r, c - 1), f(r - 1, c), e): GOTO t5 t5: NEXT t 25 : NEXT c NEXT r rr = r: cc = c FOR rr = 0 TO 24 FOR cc = 1 TO 39 r = rr + 1: c = cc - 0: gr = f(r, c): IF gr = 0 THEN rg = rg + 1: IF gr = 2 THEN STOP IF gr = 2 THEN PUT (cc * 8, rr * 8), qq% 'IF gr = 2 THEN PUT (cc * 8, rr * 8), q% IF gr = 0 THEN PUT (cc * 8, rr * 8), q% 'IF gr > 2 THEN PUT (cc * 8, rr * 8), q% NEXT cc NEXT rr