From: Svjatoslav Agejenko Date: Wed, 16 Oct 2024 20:00:02 +0000 (+0300) Subject: Using AI to improve code readability X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=0a73cea066fbd35a39faf81e603fc7c189fd8569;p=qbasicapps.git Using AI to improve code readability --- diff --git a/Graphics/Presentations/AI/AI demo.bas b/Graphics/Presentations/AI/AI demo.bas index 6a54940..c6922e9 100644 --- a/Graphics/Presentations/AI/AI demo.bas +++ b/Graphics/Presentations/AI/AI demo.bas @@ -1,36 +1,14 @@ -DECLARE SUB sc10 () -DECLARE SUB sc9 () -DECLARE SUB sc8 () -DECLARE SUB sc7 () -DECLARE SUB sc6 () -DECLARE SUB inpur () -DECLARE SUB sc5 () -DECLARE SUB box (x1!, y1!, x2!, y2!) -DECLARE SUB pri (x!, y!, s!, c!, a$) -DECLARE SUB getfnt () -DECLARE SUB sc4 () -DECLARE SUB mkback () -DECLARE SUB sc3 () -DECLARE SUB calc (tx1!, ty1!, tz1!, tx2!, ty2!, tz2!, tx3!, ty3!, tz3!, c!) -DECLARE SUB getan (x1!, y1!, x2!, y2!, N!) -DECLARE SUB rot (zx!, zy!, x1!, y1!, N!) -DECLARE SUB fp (x1!, y1!, x2!, y2!, x3!, y3!, c!) -DECLARE SUB sc2 () -DECLARE SUB pal (r!, g!, b!, c!) -DECLARE SUB sc1 () -DECLARE SUB start () - - ' AI presentation ' made by Svjatoslav Agejenko ' in 2002 ' homepage: svjatoslav.eu ' email: svjatoslav@svjatoslav.eu - + DIM SHARED pii DIM SHARED pi DIM SHARED angl1, angl2 DIM SHARED font(0 TO 7, 0 TO 7, 32 TO 150) + start 'GOTO 6 sc1 @@ -45,90 +23,75 @@ sc8 sc10 sc9 -SYSTEM - SUB box (x1, y1, x2, y2) -'FOR a = 0 TO 30 -'IF a <= 5 THEN buf1(a) = 120 + (SQR((20 - a) * a)) -'IF (a > 5) AND (a < 25) THEN buf1(a) = 120 + 10 -'IF a >= 25 THEN buf1(a) = 120 + (SQR((30 - a) * (a - 10))) -'NEXT a - FOR y = y1 TO y2 -s = 10 -IF y - y1 <= 10 THEN -s = (SQR((20 - (y - y1)) * (y - y1))) -END IF - -IF y2 - y <= 10 THEN -s = (SQR((20 - (y2 - y)) * (y2 - y))) -END IF - -FOR x = x1 - s TO x2 + s -c = POINT(x, y) -IF c <= 127 THEN -c = c + 127 -IF c > 245 THEN c = 245 -PSET (x, y), c -END IF -NEXT x + s = 10 + IF y - y1 <= 10 THEN + s = (SQR((20 - (y - y1)) * (y - y1))) + END IF + + IF y2 - y <= 10 THEN + s = (SQR((20 - (y2 - y)) * (y2 - y))) + END IF + + FOR x = x1 - s TO x2 + s + c = POINT(x, y) + IF c <= 127 THEN + c = c + 127 + IF c > 245 THEN c = 245 + PSET (x, y), c + END IF + NEXT x NEXT y END SUB SUB calc (tx1, ty1, tz1, tx2, ty2, tz2, tx3, ty3, tz3, c) -x1 = tx1 -y1 = ty1 -z1 = tz1 - -x2 = tx2 -y2 = ty2 -z2 = tz2 - -x3 = tx3 -y3 = ty3 -z3 = tz3 - - -'LINE (x1, y1)-(x2, y2), 3 -'LINE (x3, y3)-(x2, y2), 3 -'LINE (x1, y1)-(x3, y3), 3 - - -getan x1, y1, x2, y2, n1 -rot x1, y1, x2, y2, -n1 -rot x1, y1, x3, y3, -n1 - -getan y1, z1, y2, z2, n2 -n2 = n2 + pi / 2 -rot y1, z1, y2, z2, -n2 -rot y1, z1, y3, z3, -n2 - -getan x1, z1, x3, z3, n3 -n3 = n3 + pi / 2 -rot x1, z1, x2, z2, -n3 -rot x1, z1, x3, z3, -n3 - -x4 = x1 -y4 = y1 -z4 = z1 + 30 - -rot x1, z1, x4, z4, n3 -rot y1, z1, y4, z4, n2 -rot x1, y1, x4, y4, n1 - -'LINE (tx1, ty1)-(x4, y4), 255 -x1 = tx1 + 20 -y1 = ty1 + 10 -a = SQR((x1 - x4) ^ 2 + (y1 - y4) ^ 2) -c = 49 - a -IF c < 0 THEN c = 0 + x1 = tx1 + y1 = ty1 + z1 = tz1 + + x2 = tx2 + y2 = ty2 + z2 = tz2 + + x3 = tx3 + y3 = ty3 + z3 = tz3 + + getan x1, y1, x2, y2, n1 + rot x1, y1, x2, y2, -n1 + rot x1, y1, x3, y3, -n1 + + getan y1, z1, y2, z2, n2 + n2 = n2 + pi / 2 + rot y1, z1, y2, z2, -n2 + rot y1, z1, y3, z3, -n2 + + getan x1, z1, x3, z3, n3 + n3 = n3 + pi / 2 + rot x1, z1, x2, z2, -n3 + rot x1, z1, x3, z3, -n3 + + x4 = x1 + y4 = y1 + z4 = z1 + 30 + + rot x1, z1, x4, z4, n3 + rot y1, z1, y4, z4, n2 + rot x1, y1, x4, y4, n1 + + 'LINE (tx1, ty1)-(x4, y4), 255 + x1 = tx1 + 20 + y1 = ty1 + 10 + a = SQR((x1 - x4) ^ 2 + (y1 - y4) ^ 2) + c = 49 - a + IF c < 0 THEN c = 0 END SUB SUB fp (x1, y1, x2, y2, x3, y3, c) - DIM yb(-100 TO 300) mx1 = x1 @@ -151,16 +114,16 @@ GOTO 1 mkl: IF my2 < my1 THEN SWAP my1, my2: SWAP mx1, mx2 FOR y = my1 TO my2 - 1 -x = mx1 + (mx2 - mx1) * ((y - my1) / (my2 - my1)) -IF yb(y) = 0 THEN -yb(y) = x -ELSE -LINE (x, y)-(yb(y), y), c -END IF + x = mx1 + (mx2 - mx1) * ((y - my1) / (my2 - my1)) + IF yb(y) = 0 THEN + yb(y) = x + ELSE + LINE (x, y)-(yb(y), y), c + END IF NEXT y RETURN -1 +1 'LINE (x1, y1)-(x2, y2), 0 'LINE (x3, y3)-(x2, y2), 0 @@ -169,26 +132,27 @@ RETURN END SUB SUB getan (x1, y1, x2, y2, N) -IF y1 = y2 THEN -IF x2 > x1 THEN N = pi / 2 ELSE N = pi * 1.5 -GOTO 2 -END IF + IF y1 = y2 THEN + IF x2 > x1 THEN N = pi / 2 ELSE N = pi * 1.5 + GOTO 2 + END IF + + IF y2 > y1 THEN + IF x2 = x1 THEN N = pi: GOTO 2 + IF x2 > x1 THEN + N = (pi * 1) - ATN((x2 - x1) / (y2 - y1)) + ELSE + N = pi + ATN((x1 - x2) / (y2 - y1)) + END IF + ELSE + IF x2 = x1 THEN N = 0: GOTO 2 + IF x2 > x1 THEN + N = ATN((x2 - x1) / (y1 - y2)) + ELSE + N = pi * 2 - ATN((x1 - x2) / (y1 - y2)) + END IF + END IF -IF y2 > y1 THEN -IF x2 = x1 THEN N = pi: GOTO 2 -IF x2 > x1 THEN -N = (pi * 1) - ATN((x2 - x1) / (y2 - y1)) -ELSE -N = pi + ATN((x1 - x2) / (y2 - y1)) -END IF -ELSE -IF x2 = x1 THEN N = 0: GOTO 2 -IF x2 > x1 THEN -N = ATN((x2 - x1) / (y1 - y2)) -ELSE -N = pi * 2 - ATN((x1 - x2) / (y1 - y2)) -END IF -END IF 2 END SUB @@ -198,13 +162,13 @@ SUB getfnt pal 0, 0, 0, 70 COLOR 70 FOR a = 32 TO 150 -LOCATE 1, 1 -PRINT CHR$(a) -FOR y = 0 TO 7 -FOR x = 0 TO 7 -font(x, y, a) = POINT(x, y) -NEXT x -NEXT y + LOCATE 1, 1 + PRINT CHR$(a) + FOR y = 0 TO 7 + FOR x = 0 TO 7 + font(x, y, a) = POINT(x, y) + NEXT x + NEXT y NEXT a END SUB @@ -212,7 +176,6 @@ END SUB SUB inpur a$ = INPUT$(1) - END SUB DEFINT A-Z @@ -226,24 +189,23 @@ pal 0, 5, 5, 254 pal 0, 5, 5, 255 FOR a = 0 TO 127 -OUT &H3C8, a -OUT &H3C9, SIN(a / 22) * 30 + 30 -OUT &H3C9, SIN(a / 18) * 5 + 5 -OUT &H3C9, COS(a / 12) * 10 + 10 + OUT &H3C8, a + OUT &H3C9, SIN(a / 22) * 30 + 30 + OUT &H3C9, SIN(a / 18) * 5 + 5 + OUT &H3C9, COS(a / 12) * 10 + 10 NEXT a FOR a = 128 TO 245 -OUT &H3C8, a -b = a - 128 -OUT &H3C9, SIN(b / 22) * 4 + 10 -OUT &H3C9, SIN(b / 18) * 4 + 10 -OUT &H3C9, COS(b / 12) * 4 + 10 + OUT &H3C8, a + b = a - 128 + OUT &H3C9, SIN(b / 22) * 4 + 10 + OUT &H3C9, SIN(b / 18) * 4 + 10 + OUT &H3C9, COS(b / 12) * 4 + 10 NEXT a DIM lm lm = 127 - s = 2 ^ 8 5 s = s \ 2 @@ -251,88 +213,82 @@ x2 = (319 \ s) - 1 y2 = (199 \ s) - 1 FOR y = 0 TO y2 -FOR x = 0 TO x2 -x1 = x * s -y1 = y * s -c1 = POINT(x1, y1) -c2 = POINT(x1 + s, y1) -c3 = POINT(x1, y1 + s) -c4 = POINT(x1 + s, y1 + s) - -sp = s \ 2 + FOR x = 0 TO x2 + x1 = x * s + y1 = y * s + c1 = POINT(x1, y1) + c2 = POINT(x1 + s, y1) + c3 = POINT(x1, y1 + s) + c4 = POINT(x1 + s, y1 + s) -cc2 = ((c1 + c2) / 2) + (RND * 6) - 3 -IF cc2 > lm THEN cc2 = lm + sp = s \ 2 -cc3 = ((c1 + c3) / 2) + (RND * 6) - 3 -IF cc3 > lm THEN cc3 = lm + cc2 = ((c1 + c2) / 2) + (RND * 6) - 3 + IF cc2 > lm THEN cc2 = lm -cc4 = ((c2 + c4) / 2) + (RND * 6) - 3 -IF cc4 > lm THEN cc4 = lm + cc3 = ((c1 + c3) / 2) + (RND * 6) - 3 + IF cc3 > lm THEN cc3 = lm -cc5 = ((c3 + c4) / 2) + (RND * 6) - 3 -IF cc5 > lm THEN cc5 = lm + cc4 = ((c2 + c4) / 2) + (RND * 6) - 3 + IF cc4 > lm THEN cc4 = lm -cc1 = ((cc2 + cc3 + cc4 + cc5) / 4) + (RND * 6) - 3 -IF cc1 > lm THEN cc1 = lm + cc5 = ((c3 + c4) / 2) + (RND * 6) - 3 + IF cc5 > lm THEN cc5 = lm + cc1 = ((cc2 + cc3 + cc4 + cc5) / 4) + (RND * 6) - 3 + IF cc1 > lm THEN cc1 = lm - -PSET (x1 + sp, y1 + sp), cc1 -PSET (x1 + sp, y1), cc2 -PSET (x1, y1 + sp), cc3 -PSET (x1 + s, y1 + sp), cc4 -PSET (x1 + sp, y1 + s), cc5 - - -NEXT x + PSET (x1 + sp, y1 + sp), cc1 + PSET (x1 + sp, y1), cc2 + PSET (x1, y1 + sp), cc3 + PSET (x1 + s, y1 + sp), cc4 + PSET (x1 + sp, y1 + s), cc5 + NEXT x NEXT y IF s > 2 THEN GOTO 5 - - END SUB DEFSNG A-Z SUB pal (r, g, b, c) -IF r < 0 THEN r = 0 -IF g < 0 THEN g = 0 -IF b < 0 THEN b = 0 -IF r > 63 THEN r = 63 -IF g > 63 THEN g = 63 -IF b > 63 THEN b = 63 - -OUT &H3C8, c -OUT &H3C9, r -OUT &H3C9, g -OUT &H3C9, b + IF r < 0 THEN r = 0 + IF g < 0 THEN g = 0 + IF b < 0 THEN b = 0 + IF r > 63 THEN r = 63 + IF g > 63 THEN g = 63 + IF b > 63 THEN b = 63 + + OUT &H3C8, c + OUT &H3C9, r + OUT &H3C9, g + OUT &H3C9, b END SUB SUB pri (x, y, s, c, a$) -IF s = 1 THEN -x2 = x -FOR a = 1 TO LEN(a$) -b = ASC(RIGHT$(LEFT$(a$, a), 1)) -IF b > 150 OR b < 32 THEN GOTO 7 -FOR y1 = 0 TO 7 -FOR x1 = 0 TO 7 -c1 = font(x1, y1, b) -IF c1 > 0 THEN PSET (x1 + x2, y1 + y), c -NEXT x1 -NEXT y1 -7 -x2 = x2 + 8 -NEXT a -END IF + IF s = 1 THEN + x2 = x + FOR a = 1 TO LEN(a$) + b = ASC(RIGHT$(LEFT$(a$, a), 1)) + IF b > 150 OR b < 32 THEN GOTO 7 + FOR y1 = 0 TO 7 + FOR x1 = 0 TO 7 + c1 = font(x1, y1, b) + IF c1 > 0 THEN PSET (x1 + x2, y1 + y), c + NEXT x1 + NEXT y1 + 7 + x2 = x2 + 8 + NEXT a + END IF END SUB SUB rot (zx, zy, x1, y1, N) -x2 = x1 - zx -y2 = y1 - zy -c1 = SIN(N) -s1 = COS(N) -x1 = x2 * s1 - y2 * c1 + zx -y1 = x2 * c1 + y2 * s1 + zy + x2 = x1 - zx + y2 = y1 - zy + c1 = SIN(N) + s1 = COS(N) + x1 = x2 * s1 - y2 * c1 + zx + y1 = x2 * c1 + y2 * s1 + zy END SUB SUB sc1 @@ -360,7 +316,6 @@ DIM ehi tim = 0 ehi = 1 - an1 = 0 an2 = 0 @@ -381,31 +336,32 @@ INPUT #1, inco INPUT #1, inpo FOR a = 1 TO inco -INPUT #1, x, y, z -np = np + 1 -px(np) = x - 100 -py(np) = y -pz(np) = z + INPUT #1, x, y, z + np = np + 1 + px(np) = x - 100 + py(np) = y + pz(np) = z NEXT a INPUT #1, b, b, l1, l2, l3 FOR a = 1 TO inpo - 1 -INPUT #1, b, b, l1!, l2!, l3! -nlin1! = l1! -nlin2! = l2! -GOSUB addlin -nlin1! = l2! -nlin2! = l3! -GOSUB addlin -nlin1! = l1! -nlin2! = l3! -GOSUB addlin -LOCATE 4, 10 -PRINT STR$(INT(a / (inpo - 1) * 100)) + "% valmis" + INPUT #1, b, b, l1!, l2!, l3! + nlin1! = l1! + nlin2! = l2! + GOSUB addlin + nlin1! = l2! + nlin2! = l3! + GOSUB addlin + nlin1! = l1! + nlin2! = l3! + GOSUB addlin + LOCATE 4, 10 + PRINT STR$(INT(a / (inpo - 1) * 100)) + "% valmis" NEXT a CLOSE 1 CLS + 3 tim = tim + 1 sj$ = INKEY$ @@ -421,22 +377,21 @@ s2 = SIN(an2) c2 = COS(an2) IF ehi >= 1 THEN -nlt = nlt + ehi -ehi = ehi + .03 -IF nlt > nl THEN nlt = nl: ehi = 0 + nlt = nlt + ehi + ehi = ehi + .03 + IF nlt > nl THEN nlt = nl: ehi = 0 END IF FOR a = 0 TO np -x = px(a) -y = py(a) -z = pz(a) - -z2 = z * s1 + y * c1 -y1 = y * s1 - z * c1 + x = px(a) + y = py(a) + z = pz(a) -z1 = z2 * s2 + x * c2 -x1 = x * s2 - z2 * c2 + z2 = z * s1 + y * c1 + y1 = y * s1 - z * c1 + z1 = z2 * s2 + x * c2 + x1 = x * s2 - z2 * c2 z1 = z1 + 100 @@ -448,18 +403,18 @@ py1(a) = y1 + 80 NEXT a FOR a = 1 TO nlt -l1 = lin1!(a) -l2 = lin2!(a) -x1 = px1(l1) -y1 = py1(l1) -x2 = px1(l2) -y2 = py1(l2) -LINE (lbx1(a), lby1(a))-(lbx2(a), lby2(a)), 0 -LINE (x1, y1)-(x2, y2), 255 -lbx1(a) = x1 -lby1(a) = y1 -lbx2(a) = x2 -lby2(a) = y2 + l1 = lin1!(a) + l2 = lin2!(a) + x1 = px1(l1) + y1 = py1(l1) + x2 = px1(l2) + y2 = py1(l2) + LINE (lbx1(a), lby1(a))-(lbx2(a), lby2(a)), 0 + LINE (x1, y1)-(x2, y2), 255 + lbx1(a) = x1 + lby1(a) = y1 + lbx2(a) = x2 + lby2(a) = y2 NEXT a SOUND 0, .5 IF tim < 280 THEN GOTO 3 @@ -467,13 +422,18 @@ GOTO 4 addlin: FOR b = 1 TO nl -IF lin1!(b) = nlin1! THEN IF lin2!(b) = nlin2! THEN RETURN -IF lin1!(b) = nlin2! THEN IF lin2!(b) = nlin1! THEN RETURN + IF lin1!(b) = nlin1! THEN + IF lin2!(b) = nlin2! THEN RETURN + END IF + IF lin1!(b) = nlin2! THEN + IF lin2!(b) = nlin1! THEN RETURN + END IF NEXT b nl = nl + 1 lin1!(nl) = nlin1! lin2!(nl) = nlin2! RETURN + 4 angl1 = an1 angl2 = an2 @@ -496,17 +456,16 @@ pri 30, 70 + y, 1, 250, "approach for anhanced" y = y + 13 pri 30, 70 + y, 1, 250, "understanding. M.Adjouadi," y = y + 13 -pri 30, 70 + y, 1, 250, "J.Riley;" +pri 30, 70 + y, 1, 250, "J.Riley; " y = y + 13 pri 30, 70 + y, 1, 250, "Journal of Rehabilitation" y = y + 13 pri 30, 70 + y, 1, 250, "Research & Development," y = y + 13 -pri 30, 70 + y, 1, 250, "Oct 95,Vol. 32 issue 3" +pri 30, 70 + y, 1, 250, "Oct 95, Vol. 32 issue 3" inpur - END SUB SUB sc2 @@ -535,21 +494,21 @@ INPUT #1, inco INPUT #1, inpo FOR a = 1 TO inco -INPUT #1, x, y, z -px(np) = x - 100 -py(np) = y -pz(np) = z -np = np + 1 + INPUT #1, x, y, z + px(np) = x - 100 + py(np) = y + pz(np) = z + np = np + 1 NEXT a INPUT #1, b, b, l1, l2, l3 FOR a = 1 TO inpo - 1 -INPUT #1, b, b, l1, l2, l3 -nl = nl + 1 -pol1(nl) = l1 -pol2(nl) = l2 -pol3(nl) = l3 + INPUT #1, b, b, l1, l2, l3 + nl = nl + 1 + pol1(nl) = l1 + pol2(nl) = l2 + pol3(nl) = l3 NEXT a CLOSE 1 @@ -559,19 +518,19 @@ s2 = SIN(angl2) c2 = COS(angl2) FOR a = 0 TO np -x = px(a) -y = py(a) -z = pz(a) -z2 = z * s1 + y * c1 -y1 = y * s1 - z * c1 -z1 = z2 * s2 + x * c2 -x1 = x * s2 - z2 * c2 -z1 = z1 + 100 -x1 = x1 / z1 * 74 * 2 -y1 = y1 / z1 * 65 * 2 -rpx(a) = x1 + 160 -rpy(a) = y1 + 80 -rpz(a) = z1 + x = px(a) + y = py(a) + z = pz(a) + z2 = z * s1 + y * c1 + y1 = y * s1 - z * c1 + z1 = z2 * s2 + x * c2 + x1 = x * s2 - z2 * c2 + z1 = z1 + 100 + x1 = x1 / z1 * 74 * 2 + y1 = y1 / z1 * 65 * 2 + rpx(a) = x1 + 160 + rpy(a) = y1 + 80 + rpz(a) = z1 NEXT a 'FOR a = 1 TO 63 @@ -579,38 +538,37 @@ NEXT a 'NEXT a FOR a = 1 TO 49 -pal a * 1.1 + 20, a * 1.1 + 10, a * 1.1, a + pal a * 1.1 + 20, a * 1.1 + 10, a * 1.1, a NEXT a DIM polz(1 TO nl) FOR a = 1 TO nl -polz(a) = (rpz(pol1(a)) + rpz(pol2(a)) + rpz(pol3(a))) + polz(a) = (rpz(pol1(a)) + rpz(pol2(a)) + rpz(pol3(a))) NEXT a e = nl FOR a = 1 TO nl -su = -10000 -sun = 1 -FOR b = 1 TO e -IF polz(b) > su THEN su = polz(b): sun = b -NEXT b - -p1 = pol1(sun) -p2 = pol2(sun) -p3 = pol3(sun) - -polz(sun) = polz(e) -pol1(sun) = pol1(e) -pol2(sun) = pol2(e) -pol3(sun) = pol3(e) -e = e - 1 -calc rpx(p1), rpy(p1), rpz(p1), rpx(p2), rpy(p2), rpz(p2), rpx(p3), rpy(p3), rpz(p3), d -fp INT(rpx(p1)), INT(rpy(p1)), INT(rpx(p2)), INT(rpy(p2)), INT(rpx(p3)), INT(rpy(p3)), INT(d) + su = -10000 + sun = 1 + FOR b = 1 TO e + IF polz(b) > su THEN su = polz(b): sun = b + NEXT b + + p1 = pol1(sun) + p2 = pol2(sun) + p3 = pol3(sun) + + polz(sun) = polz(e) + pol1(sun) = pol1(e) + pol2(sun) = pol2(e) + pol3(sun) = pol3(e) + e = e - 1 + calc rpx(p1), rpy(p1), rpz(p1), rpx(p2), rpy(p2), rpz(p2), rpx(p3), rpy(p3), rpz(p3), d + fp INT(rpx(p1)), INT(rpy(p1)), INT(rpx(p2)), INT(rpy(p2)), INT(rpx(p3)), INT(rpy(p3)), INT(d) 'SOUND 0, .07 NEXT a - END SUB SUB sc3 @@ -618,24 +576,24 @@ DIM buf(1 TO 10000) DIM buf1(0 TO 35) FOR a = 1 TO 20 -SOUND 0, 1 + SOUND 0, 1 NEXT a FOR a = 0 TO 30 -IF a <= 5 THEN buf1(a) = 120 + (SQR((20 - a) * a)) -IF (a > 5) AND (a < 25) THEN buf1(a) = 120 + 10 -IF a >= 25 THEN buf1(a) = 120 + (SQR((30 - a) * (a - 10))) + IF a <= 5 THEN buf1(a) = 120 + (SQR((20 - a) * a)) + IF (a > 5) AND (a < 25) THEN buf1(a) = 120 + 10 + IF a >= 25 THEN buf1(a) = 120 + (SQR((30 - a) * (a - 10))) NEXT a FOR y = 0 TO 30 -FOR x = 10 TO 300 STEP 10 -GET (x, 0)-(x + 9, 198), buf(1) -PUT (x, 1), buf(1), PSET -NEXT x -FOR a = 1 TO 49 -pal a * 1.1 + (20 - y), a * 1.1 + 10 + (y / 1.5), a * 1.1, a -NEXT a -SOUND 0, 1 -LINE (160 - buf1(y), 20)-(160 + buf1(y), 20), 255 + FOR x = 10 TO 300 STEP 10 + GET (x, 0)-(x + 9, 198), buf(1) + PUT (x, 1), buf(1), PSET + NEXT x + FOR a = 1 TO 49 + pal a * 1.1 + (20 - y), a * 1.1 + 10 + (y / 1.5), a * 1.1, a + NEXT a + SOUND 0, 1 + LINE (160 - buf1(y), 20)-(160 + buf1(y), 20), 255 NEXT y LOCATE 1, 1 @@ -644,25 +602,25 @@ pal 0, 0, 0, 254 PRINT "Tehisintellekt" pal 63, 0, 0, 253 FOR y = 0 TO 8 -FOR x = 0 TO 120 -c = POINT(x, y) -IF c > 0 THEN CIRCLE (x * 2 + 50, y * 3 + 26), 2, 0 -NEXT x -FOR x = 0 TO 120 -c = POINT(x, y + 1) -IF c > 0 THEN CIRCLE (x * 2 + 50, (y + 1) * 3 + 26), 2, 253 -NEXT x -SOUND 0, 2 + FOR x = 0 TO 120 + c = POINT(x, y) + IF c > 0 THEN CIRCLE (x * 2 + 50, y * 3 + 26), 2, 0 + NEXT x + FOR x = 0 TO 120 + c = POINT(x, y + 1) + IF c > 0 THEN CIRCLE (x * 2 + 50, (y + 1) * 3 + 26), 2, 253 + NEXT x + SOUND 0, 2 NEXT y RANDOMIZE 1 FOR a = 1 TO 10 -y = RND * 100 + 50 -FOR x = 10 TO 300 STEP 10 -GET (x, y)-(x + 9, 198), buf(1) -PUT (x, y - 1), buf(1), PSET -NEXT x + y = RND * 100 + 50 + FOR x = 10 TO 300 STEP 10 + GET (x, y)-(x + 9, 198), buf(1) + PUT (x, y - 1), buf(1), PSET + NEXT x NEXT a COLOR 253 @@ -674,8 +632,8 @@ LOCATE 1 PRINT " " PUT (0, 190), buf(1), PSET FOR a = 1 TO 32 -pal 0, a, a * 2, 253 -SOUND 0, 1 + pal 0, a, a * 2, 253 + SOUND 0, 1 NEXT a inpur END SUB @@ -688,11 +646,11 @@ box 30, 50, 290, 150 pal 32, 64, 32, 250 y = 0 -pri 30, 70 + y, 1, 250, " Ruumiliselt laiendatud n�gemise" +pri 30, 70 + y, 1, 250, " Spatial vision" y = y + 16 -pri 30, 70 + y, 1, 250, "l�henemine kujutise tuvastamiseks" +pri 30, 70 + y, 1, 250, "Object recognition" y = y + 20 -pri 30, 70 + y, 1, 250, "eesm�rk: + interpriteerimine" +pri 30, 70 + y, 1, 250, "Goal: + interpriteerimine" y = y + 16 pri 30, 70 + y, 1, 250, " + automaatjuhtimine" @@ -719,9 +677,7 @@ pri 30, 70 + y, 1, 250, "c) h�perveeru teooria lihtsate" y = y + 12 pri 30, 70 + y, 1, 250, " rakkude p�him�tted." - inpur - END SUB SUB sc6 @@ -732,35 +688,33 @@ box 30, 50, 290, 150 pal 32, 64, 32, 250 y = -8 -pri 30, 70 + y, 1, 250, "* S�gavusinfo ekstraheerimine" +pri 30, 70 + y, 1, 250, "* Depth extraction" y = y + 20 -pri 30, 70 + y, 1, 250, "* Ruumilise n�gemise kasutamine" +pri 30, 70 + y, 1, 250, "* Usage of spatial vision" y = y + 20 -pri 30, 70 + y, 1, 250, "* Sarnasusm��de" +pri 30, 70 + y, 1, 250, "* Similarity" y = y + 20 -pri 30, 70 + y, 1, 250, "* Sobitamisstrateegia" +pri 30, 70 + y, 1, 250, "* Matching strategy" inpur - END SUB SUB sc7 pal 0, 0, 0, 0 FOR a = 0 TO 19 -FOR y = a TO 199 STEP 20 -LINE (0, y)-(319, y), 0 -NEXT y -SOUND 0, .5 + FOR y = a TO 199 STEP 20 + LINE (0, y)-(319, y), 0 + NEXT y + SOUND 0, .5 NEXT a END SUB SUB sc8 FOR a = 1 TO 50 -pal 0, 0, 0, a + pal 0, 0, 0, a NEXT a - DIM px(0 TO 800) DIM py(0 TO 800) DIM pz(0 TO 800) @@ -803,54 +757,55 @@ np = 0 nl = 0 RANDOMIZE 100 s = 64 + 14 sp = s / 2 FOR y = 0 TO 100 STEP s -FOR x = 0 TO 100 STEP s -c1 = POINT(x, y) -c2 = POINT(x + s, y) -c3 = POINT(x, y + s) -c4 = POINT(x + s, y + s) -c5 = (c1 + c2 + c3 + c4) / 4 + RND * s * 6 - sp * 7 -c6 = (c2 + c4) / 2 + RND * s * 6 - sp * 7 -c7 = (c3 + c4) / 2 + RND * s * 6 - sp * 7 -IF c5 > 50 THEN c5 = 50 -IF c5 < 0 THEN c5 = 0 -IF c6 > 50 THEN c6 = 50 -IF c6 < 0 THEN c6 = 0 -IF c7 > 50 THEN c7 = 50 -IF c7 < 0 THEN c7 = 0 -PSET (x + sp, y + sp), c5 -PSET (x + s, y + sp), c6 -PSET (x + sp, y + s), c7 -NEXT x + FOR x = 0 TO 100 STEP s + c1 = POINT(x, y) + c2 = POINT(x + s, y) + c3 = POINT(x, y + s) + c4 = POINT(x + s, y + s) + c5 = (c1 + c2 + c3 + c4) / 4 + RND * s * 6 - sp * 7 + c6 = (c2 + c4) / 2 + RND * s * 6 - sp * 7 + c7 = (c3 + c4) / 2 + RND * s * 6 - sp * 7 + IF c5 > 50 THEN c5 = 50 + IF c5 < 0 THEN c5 = 0 + IF c6 > 50 THEN c6 = 50 + IF c6 < 0 THEN c6 = 0 + IF c7 > 50 THEN c7 = 50 + IF c7 < 0 THEN c7 = 0 + PSET (x + sp, y + sp), c5 + PSET (x + s, y + sp), c6 + PSET (x + sp, y + s), c7 + NEXT x NEXT y s = s / 2 IF s > 1 THEN GOTO 14 + 'a$ = INPUT$(1) FOR z = 1 TO 400 STEP 20 -FOR x = 1 TO 400 STEP 20 -np = np + 1 -px(np) = x -py(np) = POINT(z / 20 + 10, x / 20 + 10) * 2 -pz(np) = z -IF x > 1 THEN -nl = nl + 1 -lin1(nl) = np -lin2(nl) = np - 1 -linc(nl) = 1 -END IF -IF z > 1 THEN -nl = nl + 1 -lin1(nl) = np -lin2(nl) = np - 20 -linc(nl) = 1 -END IF -NEXT x + FOR x = 1 TO 400 STEP 20 + np = np + 1 + px(np) = x + py(np) = POINT(z / 20 + 10, x / 20 + 10) * 2 + pz(np) = z + IF x > 1 THEN + nl = nl + 1 + lin1(nl) = np + lin2(nl) = np - 1 + linc(nl) = 1 + END IF + IF z > 1 THEN + nl = nl + 1 + lin1(nl) = np + lin2(nl) = np - 20 + linc(nl) = 1 + END IF + NEXT x NEXT z - LINE (0, 0)-(319, 199), 0, BF pal 0, 0, 0, 0 @@ -872,6 +827,7 @@ OPEN "data2.dat" FOR INPUT AS #1 a = 0 b = 0 hlkin = np + 1 + 15 INPUT #1, x, y, z IF x = 999 THEN GOTO 16 @@ -880,6 +836,7 @@ hlkx(a) = x hlky(a) = -y hlkz(a) = z GOTO 15 + 16 INPUT #1, x, y IF x = 999 THEN GOTO 17 @@ -888,6 +845,7 @@ lin1(nl) = x + np + 1 lin2(nl) = y + np + 1 linc(nl) = 2 GOTO 16 + 17 CLOSE #1 np = np + a @@ -896,69 +854,67 @@ hlknu = a RANDOMIZE 10 c = 3 FOR a = 1 TO 25 -p = RND * 396 + 2 -x = px(p) -z = pz(p) -yy = py(p) - 4 - -px(np + 1) = x - 5 -py(np + 1) = yy -pz(np + 1) = z - 5 + p = RND * 396 + 2 + x = px(p) + z = pz(p) + yy = py(p) - 4 -px(np + 2) = x + 5 -py(np + 2) = yy -pz(np + 2) = z - 5 + px(np + 1) = x - 5 + py(np + 1) = yy + pz(np + 1) = z - 5 -px(np + 3) = x + 5 -py(np + 3) = yy -pz(np + 3) = z + 5 + px(np + 2) = x + 5 + py(np + 2) = yy + pz(np + 2) = z - 5 -px(np + 4) = x - 5 -py(np + 4) = yy -pz(np + 4) = z + 5 + px(np + 3) = x + 5 + py(np + 3) = yy + pz(np + 3) = z + 5 -px(np + 5) = x -py(np + 5) = yy - 5 -pz(np + 5) = z + px(np + 4) = x - 5 + py(np + 4) = yy + pz(np + 4) = z + 5 + px(np + 5) = x + py(np + 5) = yy - 5 + pz(np + 5) = z -lin1(nl + 1) = np + 1 -lin2(nl + 1) = np + 2 -linc(nl + 1) = c + lin1(nl + 1) = np + 1 + lin2(nl + 1) = np + 2 + linc(nl + 1) = c -lin1(nl + 2) = np + 2 -lin2(nl + 2) = np + 3 -linc(nl + 2) = c + lin1(nl + 2) = np + 2 + lin2(nl + 2) = np + 3 + linc(nl + 2) = c -lin1(nl + 3) = np + 3 -lin2(nl + 3) = np + 4 -linc(nl + 3) = c + lin1(nl + 3) = np + 3 + lin2(nl + 3) = np + 4 + linc(nl + 3) = c -lin1(nl + 4) = np + 4 -lin2(nl + 4) = np + 1 -linc(nl + 4) = c + lin1(nl + 4) = np + 4 + lin2(nl + 4) = np + 1 + linc(nl + 4) = c -lin1(nl + 5) = np + 1 -lin2(nl + 5) = np + 5 -linc(nl + 5) = c + lin1(nl + 5) = np + 1 + lin2(nl + 5) = np + 5 + linc(nl + 5) = c -lin1(nl + 6) = np + 2 -lin2(nl + 6) = np + 5 -linc(nl + 6) = c + lin1(nl + 6) = np + 2 + lin2(nl + 6) = np + 5 + linc(nl + 6) = c -lin1(nl + 7) = np + 3 -lin2(nl + 7) = np + 5 -linc(nl + 7) = c + lin1(nl + 7) = np + 3 + lin2(nl + 7) = np + 5 + linc(nl + 7) = c -lin1(nl + 8) = np + 4 -lin2(nl + 8) = np + 5 -linc(nl + 8) = c + lin1(nl + 8) = np + 4 + lin2(nl + 8) = np + 5 + linc(nl + 8) = c -np = np + 5 -nl = nl + 8 + np = np + 5 + nl = nl + 8 NEXT a - 10 SOUND 0, 1 IF INKEY$ <> "" THEN miin = 1 @@ -970,47 +926,47 @@ mz = hlaz SELECT CASE eta CASE 1 -desx = px(np) -desz = pz(np) -getan desx, desz, hlax, hlaz, desa -IF desa - hlka > pi THEN desa = desa - (pi * 2) -IF hlka - desa > pi THEN desa = desa + (pi * 2) -eta = 2 -FOR a = nl - 7 TO nl -linc(a) = 4 -NEXT a + desx = px(np) + desz = pz(np) + getan desx, desz, hlax, hlaz, desa + IF desa - hlka > pi THEN desa = desa - (pi * 2) + IF hlka - desa > pi THEN desa = desa + (pi * 2) + eta = 2 + FOR a = nl - 7 TO nl + linc(a) = 4 + NEXT a CASE 2 -a = desa - hlka -IF desa = hlka THEN eta = 3 -IF a > .05 THEN a = .05 -IF a < -.05 THEN a = -.05 -hlka = hlka + a + a = desa - hlka + IF desa = hlka THEN eta = 3 + IF a > .05 THEN a = .05 + IF a < -.05 THEN a = -.05 + hlka = hlka + a CASE 3 -x = desx - hlax -z = desz - hlaz -v = SQR(x * x + z * z) -IF v < 5 THEN eta = 4 -v = v / 2 -hlax = hlax + x / v -hlaz = hlaz + z / v + x = desx - hlax + z = desz - hlaz + v = SQR(x * x + z * z) + IF v < 5 THEN eta = 4 + v = v / 2 + hlax = hlax + x / v + hlaz = hlaz + z / v CASE 4 -FOR a = np - 4 TO np -py(a) = py(a) - 1 -NEXT a -IF py(np) < 3 - hlay THEN -FOR a = nl - 7 TO nl -LINE (lbx1(a), lby1(a))-(lbx2(a), lby2(a)), 0 -NEXT a -np = np - 5 -nl = nl - 8 -mil = mil - 1 -eta = 6 -IF mil <= 0 THEN eta = 7 -END IF + FOR a = np - 4 TO np + py(a) = py(a) - 1 + NEXT a + IF py(np) < 3 - hlay THEN + FOR a = nl - 7 TO nl + LINE (lbx1(a), lby1(a))-(lbx2(a), lby2(a)), 0 + NEXT a + np = np - 5 + nl = nl - 8 + mil = mil - 1 + eta = 6 + IF mil <= 0 THEN eta = 7 + END IF CASE 6 -eta = 5 + eta = 5 CASE 5 -eta = 1 + eta = 1 END SELECT y = 60 - py(INT((hlaz + 10) / 20) * 20 + INT((hlax + 10) / 20)) @@ -1018,26 +974,26 @@ IF hlay > y + 5 THEN hlay = hlay - 1 IF hlay < y THEN hlay = hlay + 1 IF hlay > y + 25 THEN hlay = hlay - 1: ' SOUND 1000, 1 IF hlay < y - 20 THEN hlay = hlay + 1: ' SOUND 1000, 1 - + s1 = SIN(hlka) c1 = COS(hlka) FOR a = 0 TO hlknu - 5 -x = hlkx(a + 1) -z = hlkz(a + 1) -px(a + hlkin) = x * s1 + z * c1 + hlax -py(a + hlkin) = hlky(a + 1) - hlay -pz(a + hlkin) = z * s1 - x * c1 + hlaz + x = hlkx(a + 1) + z = hlkz(a + 1) + px(a + hlkin) = x * s1 + z * c1 + hlax + py(a + hlkin) = hlky(a + 1) - hlay + pz(a + hlkin) = z * s1 - x * c1 + hlaz NEXT a hlkr = hlkr + .5 s1 = SIN(hlkr) c1 = COS(hlkr) FOR a = hlknu - 4 TO hlknu - 1 -x = hlkx(a + 1) -z = hlkz(a + 1) -px(a + hlkin) = x * s1 + z * c1 + hlax -py(a + hlkin) = hlky(a + 1) - hlay -pz(a + hlkin) = z * s1 - x * c1 + hlaz + x = hlkx(a + 1) + z = hlkz(a + 1) + px(a + hlkin) = x * s1 + z * c1 + hlax + py(a + hlkin) = hlky(a + 1) - hlay + pz(a + hlkin) = z * s1 - x * c1 + hlaz NEXT a tim = tim + 1 @@ -1051,9 +1007,9 @@ s2 = SIN(an2) c2 = COS(an2) FOR a = 0 TO np -x = px(a) - mx -y = py(a) - my -z = pz(a) - mz + x = px(a) - mx + y = py(a) - my + z = pz(a) - mz z2 = z * s1 + x * c1 x1 = x * s1 - z * c1 @@ -1062,30 +1018,30 @@ z1 = z2 * s2 + y * c2 y1 = y * s2 - z2 * c2 -z1 = z1 + kau -IF z1 < 1 THEN px1(a) = -1: GOTO 11 -x1 = x1 / z1 * 74 * 2 -y1 = y1 / z1 * 65 * 2 + z1 = z1 + kau + IF z1 < 1 THEN px1(a) = -1: GOTO 11 + x1 = x1 / z1 * 74 * 2 + y1 = y1 / z1 * 65 * 2 -px1(a) = x1 + 160 -py1(a) = y1 + 80 + px1(a) = x1 + 160 + py1(a) = y1 + 80 11 NEXT a FOR a = 1 TO nl -l1 = lin1!(a) -l2 = lin2!(a) -x1 = px1(l1) -x2 = px1(l2) -LINE (lbx1(a), lby1(a))-(lbx2(a), lby2(a)), 0 -IF (x1 = -1) OR (x2 = -1) THEN GOTO 12 -y1 = py1(l1) -y2 = py1(l2) -LINE (x1, y1)-(x2, y2), linc(a) -lbx1(a) = x1 -lby1(a) = y1 -lbx2(a) = x2 -lby2(a) = y2 + l1 = lin1!(a) + l2 = lin2!(a) + x1 = px1(l1) + x2 = px1(l2) + LINE (lbx1(a), lby1(a))-(lbx2(a), lby2(a)), 0 + IF (x1 = -1) OR (x2 = -1) THEN GOTO 12 + y1 = py1(l1) + y2 = py1(l2) + LINE (x1, y1)-(x2, y2), linc(a) + lbx1(a) = x1 + lby1(a) = y1 + lbx2(a) = x2 + lby2(a) = y2 12 NEXT a IF kau > 200 THEN kau = kau - 10 @@ -1094,6 +1050,7 @@ IF tim < 28000 THEN GOTO 10 END SUB SUB sc9 + RANDOMIZE 45 mkback @@ -1104,8 +1061,6 @@ y = -8 pri 30, 70 + y, 1, 250, " T�nan t�helepanu eest" inpur - - END SUB SUB start @@ -1115,4 +1070,3 @@ pii = pi fac = 360 / (pi * 2) getfnt END SUB -