主题:求救:怎样做迷宫
muhuailei
[专家分:0] 发布于 2006-07-31 17:54:00
求救:怎样做迷宫,用搜索再在12模式下line画出来?
高手帮帮啊!!!!!!!!!!
谢。。。。。
回复列表 (共21个回复)
沙发
def [专家分:3380] 发布于 2006-08-02 10:12:00
用RANDOMIZE TIMER语句和
RND函数
板凳
我长大会更帅 [专家分:0] 发布于 2006-08-07 02:01:00
首先解决出路的唯一性和存在性啊
再想办法搞叉路啊
我也菜鸟
这样可不可以啊?
3 楼
moz [专家分:37620] 发布于 2006-08-07 11:04:00
可以
4 楼
小小tqw [专家分:40] 发布于 2006-08-07 13:09:00
20 SCREEN 12: CLS : COLOR 11
30 PRINT : PRINT : PRINT TAB(30); "Welcome to zhmg"
40 PRINT TAB(15); "First the computer wants know your want to in what class,1 best easy--20 best not easy"
50 PRINT TAB(25); "Then the computer draw the maze": PRINT
55 PRINT TAB(20); "use IJKL four keys move a littel bit small until come out the maze": PRINT
60 PRINT TAB(30); "I--turn up": PRINT TAB(30); "K--turn down"
70 PRINT TAB(30); "L--turn right": PRINT TAB(30); "J--turn left": PRINT : PRINT
80 LINE (0, 0)-(639, 479), 10, B
90 LINE (2, 2)-(637, 477), 12, B
100 LINE (4, 4)-(635, 475), 14, B
110 RANDOMIZE (VAL(MID$(TIME$, 4, 2) + RIGHT$(TIME$, 2)))
120 RANDOMIZE (32000 - 64000 * RND): COLOR 2
130 INPUT "Input your class(1~20):"; D: CLS
135 IF D > 20 THEN 130
140 W = D * 2 + 8: H = D * 2 + 6
145 WO = 640 / (W + 1): HO = 480 / (H + 1)
150 CLS : LINE (0, 0)-(WO * W, HO * H), 3, B
160 I1 = W * H * 2
170 FOR I = 0 TO I1
180 IF I > W * H THEN X = INT(I / H): Y = I MOD H: GOTO 240
190 IF I > 15 THEN X = INT(RND * W + 1): Y = INT(RND * H + 1): GOTO 240
200 IF (I MOD 4) = 3 THEN X = INT(RND * (W - 3) + 1): Y = 1: GOTO 240
210 IF (I MOD 4) = 2 THEN X = INT(RND * (W - 3) + 1): Y = H - 1: GOTO 240
220 IF (I MOD 4) = 1 THEN X = 1: Y = INT(RND * (H - 6) + 3): GOTO 240
230 IF (I MOD 4) = 0 THEN X = W - 1: Y = INT(RND * (H - 6) + 3)
240 X = X * WO: Y = Y * HO
250 IF POINT(X, Y) THEN 460
260 D = INT(4 * RND + 1): D2 = D
265 D = D MOD 4 + 1
270 X1 = ((D = 1) - (D = 3)) * WO + X
280 Y1 = ((D = 2) - (D = 4)) * HO + Y
290 IF POINT(X1, Y1) = 0 THEN 420
300 IF ((X1 = WO) AND (Y1 = INT(H / 2) * HO)) OR ((X1 = W * WO - WO) AND (Y1 = INT(H / 2) * HO)) THEN 420
310 LINE (X, Y)-(X1, Y1), 3
320 D = INT(RND * 4 + 1)
330 FOR K = 1 TO 4
340 D = D MOD 4 + 1
350 X1 = ((D = 1) - (D = 3)) * WO + X
360 Y1 = ((D = 2) - (D = 4)) * HO + Y
370 IF POINT(X1, Y1) THEN 450
380 IF W < 20 AND D = D1 THEN 450
390 IF ((X1 = WO) AND (Y1 = INT(H / 2) * HO)) OR ((X1 = W * WO - WO) AND (Y = INT(H / 2) * WO)) THEN 450
400 LINE (X, Y)-(X1, Y1), 3
410 X = X1: Y = Y1: D1 = D: GOTO 320
420 IF D = D2 THEN 440
430 X = X1: Y = Y1
440 GOTO 265
450 NEXT K
460 NEXT I
470 Y = (H / 2) * HO
480 LINE (0, Y)-(0, Y + HO), 0
490 LINE (W * WO, Y)-(W * WO, Y + HO), 0
500 C = 3: X = 0: W2 = WO / 2
510 H2 = HO / 2: Y = Y + H2: YT = Y
520 PSET (X, Y), C
530 WHILE X < W * WO
540 K$ = INKEY$: IF K$ = "" THEN 540
550 IF K$ = "Z" OR K$ = "z" THEN 780
570 IF K$ = "Q" OR K$ = "q" THEN A = 1: GOTO 675
580 IF K$ < CHR$(73) OR K$ > CHR$(76) THEN 540
590 ON ASC(K$) - 72 GOTO 610, 620, 600, 630
600 POT = POINT(X, Y + H2): X1 = X: Y1 = Y: Y = Y + H2: GOTO 640
610 POT = POINT(X, Y - H2): X1 = X: Y1 = Y: Y = Y - H2: GOTO 640
620 POT = POINT(X - W2, Y): X1 = X: Y1 = Y: X = X - W2: GOTO 640
630 POT = POINT(X + W2, Y): X1 = X: Y1 = Y: X = X + W2
640 IF POT = 1 THEN X = X1: Y = Y1: GOTO 540
650 IF POT = 2 THEN C = 0: GOTO 675
660 IF POT = 0 THEN C = 2: GOTO 675
670 X = X1: Y = Y1: GOTO 540
675 LINE -(X, Y), C
680 IF A = 0 THEN 770
690 PSET (X, Y), 0
700 LINE -(X, Y), 0
710 IF X <= 0 THEN A = 0: GOTO 520
720 IF POINT(X, Y + 1) <> 0 AND POINT(X, Y + H2) <> 0 THEN Y = Y + H2: GOTO 700
730 IF POINT(X, Y - 1) <> 0 AND POINT(X, Y - H2) <> 0 THEN Y = Y - H2: GOTO 700
740 IF POINT(X + 1, Y) <> 0 AND POINT(X + W2, Y) <> 0 THEN X = X + W2: GOTO 700
750 IF POINT(X - 1, Y) <> 0 AND POINT(X - W2, Y) <> 0 THEN X = X - W2: GOTO 700
760 A = 0: GOTO 520
770 WEND
780 END
5 楼
moz [专家分:37620] 发布于 2006-08-08 01:50:00
[url=http://www.programfan.com/club/showbbs.asp?id=92235&page=last#last]这是一张旧贴,是我改人家的,参考一下吧.[/url]
6 楼
老大徒伤悲 [专家分:29120] 发布于 2006-08-08 17:09:00
2楼的思路是正确的
7 楼
phile [专家分:2310] 发布于 2009-07-22 11:38:00
如此
REM L10_15
SCREEN 1
CLS
DATA 1,1,1,1,1,1,1,1,1
DATA 0,0,0,0,0,0,1,0,1
DATA 1,1,0,1,0,1,1,0,1
DATA 1,0,0,1,0,0,0,0,1
DATA 1,1,0,1,0,0,1,0,1
DATA 1,0,0,0,0,1,1,1,1
DATA 1,0,1,1,0,0,0,0,1
DATA 1,0,0,1,1,1,1,0,1
DATA 1,0,0,0,0,0,1,0,0
DATA 1,1,1,1,1,1,1,1,1
x = 10: Y = 9
a$ = STRING$(3, 219)
b$ = STRING$(3, 176)
DIM S(100), x(100), Y(100), a(x, Y): xe = 9: ye = 9
FOR i = 1 TO x: FOR j = 1 TO Y
READ a(i, j)
IF a(i, j) = 1 THEN LOCATE i, j * 3: PRINT a$
NEXT j, i
FOR i = 1 TO 4: FOR j = 1 TO 2
READ v(i, j)
NEXT j, i: DATA 0,1,-1,0,0,-1,1,0
LOCATE 12: PRINT "Press any key to run": d$ = INPUT$(1)
x = 2: Y = 0: p = 0: x(p) = x: Y(p) = Y: i = 0
DO
i = i + 1
IF i <= 4 THEN
x = x(p) + v(i, 1): Y = Y(p) + v(i, 2)
IF a(x, Y) = 0 THEN
p = p + 1: S(p) = i: x(p) = x: Y(p) = Y
a(x, Y) = 2
i = 0
GOSUB 10
END IF
ELSE
GOSUB 10
IF p <> 2 THEN i = S(p)
p = p - 1
END IF
LOOP UNTIL p = 0 OR x = xe AND Y = ye
IF p = 0 THEN
PRINT "NO"
ELSE
LOCATE 14: PRINT "LX:RK"; "2,0"; "--->";
FOR i = 1 TO p
PRINT x(i); ","; Y(i); "--->";
NEXT i: PRINT "CK"
END IF
END
10 LOCATE x(p), Y(p) * 3:
FOR k = 1 TO 300000: NEXT k
IF i <= 4 THEN PRINT USING "##"; p ELSE PRINT b$
RETURN
8 楼
Saitor@love.com [专家分:30] 发布于 2009-08-07 13:27:00
[quote]如此
REM L10_15
SCREEN 1
CLS
DATA 1,1,1,1,1,1,1,1,1
DATA 0,0,0,0,0,0,1,0,1
DATA 1,1,0,1,0,1,1,0,1
DATA 1,0,0,1,0,0,0,0,1
DATA 1,1,0,1,0,0,1,0,1
DATA 1,0,0,0,0,1,1,1,1
DATA 1,0,1,1,0,0,0,0,1
DATA 1,0,0,1,1,1,1,0,1
DATA 1,0,0,0,0,0,1,0,0
DATA 1,1,1,1,1,1,1,1,1
x = 10: Y = 9
a$ = STRING$(3, 219)
b$ = STRING$(3, 176)
DIM S(100), x(100), Y(100), a(x, Y): xe = 9: ye = 9
FOR i = 1 TO x: FOR j = 1 TO Y
READ a(i, j)
IF a(i, j) = 1 THEN LOCATE i, j * 3: PRINT a$
NEXT j, i
FOR i = 1 TO 4: FOR j = 1 TO 2
READ v(i, j)
NEXT j, i: DATA 0,1,-1,0,0,-1,1,0
LOCATE 12: PRINT "Press any key to run": d$ = INPUT$(1)
x = 2: Y = 0: p = 0: x(p) = x: Y(p) = Y: i = 0
DO
i = i + 1
IF i <= 4 THEN
x = x(p) + v(i, 1): Y = Y(p) + v(i, 2)
IF a(x, Y) = 0 THEN
p = p + 1: S(p) = i: x(p) = x: Y(p) = Y
a(x, Y) = 2
i = 0
GOSUB 10
END IF
ELSE
GOSUB 10
IF p <> 2 THEN i = S(p)
p = p - 1
END IF
LOOP UNTIL p = 0 OR x = xe AND Y = ye
IF p = 0 THEN
PRINT "NO"
ELSE
LOCATE 14: PRINT "LX:RK"; "2,0"; "--->";
FOR i = 1 TO p
PRINT x(i); ","; Y(i); "--->";
NEXT i: PRINT "CK"
END IF
END
10 LOCATE x(p), Y(p) * 3:
FOR k = 1 TO 300000: NEXT k
IF i <= 4 THEN PRINT USING "##"; p ELSE PRINT b$
RETURN
我们老师这样教的。
9 楼
梦幻小樱 [专家分:140] 发布于 2009-08-07 13:39:00
REM L10_15
SCREEN 1
CLS
DATA 1,1,1,1,1,1,1,1,1
DATA 0,0,0,0,0,0,1,0,1
DATA 1,1,0,1,0,1,1,0,1
DATA 1,0,0,1,0,0,0,0,1
DATA 1,1,0,1,0,0,1,0,1
DATA 1,0,0,0,0,1,1,1,1
DATA 1,0,1,1,0,0,0,0,1
DATA 1,0,0,1,1,1,1,0,1
DATA 1,0,0,0,0,0,1,0,0
DATA 1,1,1,1,1,1,1,1,1
x = 10: Y = 9
a$ = STRING$(3, 219)
b$ = STRING$(3, 176)
DIM S(100), x(100), Y(100), a(x, Y): xe = 9: ye = 9
FOR i = 1 TO x: FOR j = 1 TO Y
READ a(i, j)
IF a(i, j) = 1 THEN LOCATE i, j * 3: PRINT a$
NEXT j, i
FOR i = 1 TO 4: FOR j = 1 TO 2
READ v(i, j)
NEXT j, i: DATA 0,1,-1,0,0,-1,1,0
LOCATE 12: PRINT "Press any key to run": d$ = INPUT$(1)
x = 2: Y = 0: p = 0: x(p) = x: Y(p) = Y: i = 0
DO
i = i + 1
IF i <= 4 THEN
x = x(p) + v(i, 1): Y = Y(p) + v(i, 2)
IF a(x, Y) = 0 THEN
p = p + 1: S(p) = i: x(p) = x: Y(p) = Y
a(x, Y) = 2
i = 0
GOSUB 10
END IF
ELSE
GOSUB 10
IF p <> 2 THEN i = S(p)
p = p - 1
END IF
LOOP UNTIL p = 0 OR x = xe AND Y = ye
IF p = 0 THEN
PRINT "NO"
ELSE
LOCATE 14: PRINT "LX:RK"; "2,0"; "--->";
FOR i = 1 TO p
PRINT x(i); ","; Y(i); "--->";
NEXT i: PRINT "CK"
END IF
END
10 LOCATE x(p), Y(p) * 3:
FOR k = 1 TO 300000: NEXT k
IF i <= 4 THEN PRINT USING "##"; p ELSE PRINT b$
RETURN
10 楼
phile [专家分:2310] 发布于 2009-08-07 17:53:00
梦幻小樱你怎么老抄袭!
我来回复