Jump to content
IGNORED

After a few hours with RBASIC


Christos

Recommended Posts

So if you have the time and you want to test your system or virtualjag for long term stability here's version 2.0

 

Many thanks to Reboot for adding PLOT and COLOUR and helping with the random number generator. Also note that though some optimizations for speed have been made, this is a simulation and so it takes a long time on the Jaguar. Also note that for something interesting to appear, at least 300 particles need to appear. I've left the debug prints commented out, so if you want to see what's going on, all you need to do is remove ther REM commands. Also two subroutines have been commented as well. If you want check them out as well. Anyway, it's not supposed to be too interesting to a non-Mathematician/non-Physicist. If you know ways to improve the speed, well... Patches Welcome

1 NUM=360*RND(0)
2 PRINT "MADE WITH RAPTOR AND RBASIC."
3 PRINT "SIMULATION OF"
4 PRINT "DIFFUSION LIMITED AGGREGATION"
5 FOR I=1 TO 10000
6 NEXT I
7 CLS
8 CLEAR
10 COLOUR(20):PLOT(160,100)
15 COUNTER=0
20 DIM SCREEN(320,200)
25 SCREEN(160,100)=1
30 REM GOSUB 500
31 REM GOSUB 400
35 XI=0:YI=0
40 GOSUB 100
50 GOSUB 205
60 GOTO 60
90  REM PROCEDURE FEED
100  SETCUR(0,0):PRINT "PARTICLES: ";COUNTER
110  FI=360*NUM
112  COLOUR(10)
115  IF COUNTER<=20 THEN R=5
116  IF COUNTER>20 AND COUNTER<=100 THEN R=15
117  IF COUNTER>100 AND COUNTER<=300 THEN R=30
118  IF COUNTER>300 AND COUNTER<=1000 THEN R=35
119  IF COUNTER>1000 THEN R=55
120  XI=160+INT(R*COS(360*FI)):YI=100+INT(R*SIN(360*FI))
130  IF SCREEN(XI,YI)=1 THEN NUM=RND(0):GOTO 100:REM SETCUR(0,2):PRINT "LOOP"
140  IF SCREEN(XI-1,YI-1)=1 OR SCREEN(XI-1,YI)=1 OR SCREEN(XI-1,YI+1)=1 OR SCREEN(XI,YI-1)=1 OR SCREEN(XI,YI+1)=1 OR SCREEN(XI+1,YI-1)=1 OR SCREEN(XI+1,YI)=1 OR SCREEN(XI+1,YI+1)=1 THEN NUM=RND(0):GOTO 100:REM SETCUR(0,2):PRINT "LOOP"    
150 RETURN
200 REM PROCEDURE FRACTAL
205 HZ=0
210 DO 
220 NUM=RND(0)
221 IF NUM<=0.17 THEN N=-1
222 IF NUM>0.17 AND NUM<=0.33 THEN N=0
223 IF NUM>0.33 AND NUM<=0.5 THEN N=1
224 IF NUM>0.5 AND NUM<=0.67 THEN M=-1
225 IF NUM>0.67 AND NUM<=0.84 THEN M=0
226 IF NUM>0.84 AND NUM<=1 THEN M=1
230 IF ABS(XI-160)>2*R OR ABS(XI-160)>75 THEN N=5*N
240    XI=XI+N:REM PLOT(XI,YI)
245    IF XI<5 THEN GOSUB 100:REM SETCUR(0,2):PRINT "LEFTX";HZ
260    IF XI>315 THEN GOSUB 100:REM SETCUR(0,2):PRINT "LEFTX";HZ
270    REM IF SCREEN(XI,YI)=1 THEN GOSUB 100:REM SETCUR(0,2):PRINT "LEFTM"
280    IF SCREEN(XI-1,YI-1)=1 OR SCREEN(XI-1,YI)=1 OR SCREEN(XI-1,YI+1)=1 OR SCREEN(XI,YI-1)=1 OR SCREEN(XI,YI+1)=1 OR SCREEN(XI+1,YI-1)=1 OR SCREEN(XI+1,YI)=1 OR SCREEN(XI+1,YI+1)=1 THEN SCREEN(XI,YI)=1:COLOUR(R):PLOT(XI,YI):INC COUNTER:GOSUB 100
290 
300 IF ABS(YI-100)>2*R OR ABS(YI-100)>75 THEN M=5*M
320    YI=YI+M:REM PLOT(XI,YI)    
330    IF YI<5 THEN GOSUB 100:REM SETCUR(0,2):PRINT "LEFTY";HZ
340    IF YI>195 THEN GOSUB 100:REM SETCUR(0,2):PRINT "LEFTY";HZ
350    IF SCREEN(XI-1,YI-1)=1 OR SCREEN(XI-1,YI)=1 OR SCREEN(XI-1,YI+1)=1 OR SCREEN(XI,YI-1)=1 OR SCREEN(XI,YI+1)=1 OR SCREEN(XI+1,YI-1)=1 OR SCREEN(XI+1,YI)=1 OR SCREEN(XI+1,YI+1)=1 THEN SCREEN(XI,YI)=1:COLOUR(R):PLOT(XI,YI):INC COUNTER:GOSUB 100
360    INC HZ
370    LOOP UNTIL COUNTER=3600
380 RETURN
400 FOR i=0 TO 179 
410 x1=160+COS(90+i)*10
420 y1=100+SIN(90+i)*10
430 x2=160-COS(90+i)*10
440 y2=y1
450 FOR j=x1 TO x2
460  SCREEN(j,y1)=1
465 COLOUR(10):PLOT(j,y1)
470  NEXT j
480 NEXT i
490 RETURN
500 FOR I=1 TO 15
510 FOR J=1 TO 15
520 X=INT(300*RND(0))
530 Y=INT(190*RND(0))
540 SCREEN(X,Y)=1:PLOT(X,Y)
550 NEXT J
560 NEXT I
570 RETURN

DLA2.ABS

  • Like 5
Link to comment
Share on other sites

And here's the Henon Strange Attractor. Strange attractors are very interesting both as physical phenomena and as demonstrations :). I found this online, and it only took 1 minute to get it running with rbasic. Including the time to run the build script.

1000 PRINT "Quite BASIC Math Project"
1010 PRINT "The Henon Map"
1015 PRINT "PORTED TO RBASIC"
1016 PRINT "USING RAPTOR & U235SE"
1017 FOR J=1 TO 3000:NEXT J
1020 CLS
2000 REM Set the parameters A and B
2010 LET A = 1.4
2020 LET B = 0.3
2030 REM Set initial values for X and Y
2040 LET X = 0.5
2050 LET Y = 0.5
2060 REM Initialize the iteration counter I
2070 LET I = 0
3000 REM Main iteration loop. Start plotting after 25 iterations
3010 FOR I = 1 TO 10000
3020 LET Z = X
3030 LET X = Y + 1 - A * X * X
3040 LET Y = B * Z
3050 IF I>25 THEN COLOUR(20):PLOT(36*(X + 1.4),100*(Y + 0.5))
3060 LET I = I + 1
3070 NEXT I

HENON.ABS

Edited by Christos
  • Like 4
Link to comment
Share on other sites

i have tried it, and the rally game too ;)

good work !

do you think you will add later a function to draw tiles or something like this ?

in 2012 i have done a remake in basic of barbarian (an atari st game of the 80's) and it would be great to port it on jaguar !

see ya

Link to comment
Share on other sites

 

Anyway, it's not supposed to be too interesting to a non-Mathematician/non-Physicist. If you know ways to improve the speed, well... Patches Welcome

 

Nice work - as for the speed.... I've been working on that ;)

 

Expect a nice speed boost in 0.1.7 - EhBASIC was clearly built for portability (and rightly so!) but there are many places the inner loops can be optimized... which is what I've been working on.

Link to comment
Share on other sites

  • 1 month later...

Thanks for the binary forms of game/demo sources as I forgot how to compile after setting up a Jagdev environment, lol, I think I'll go grab Belboz's dev environment files now.

 

And that will undoubtedly be 0% help. With the recent versions of RBASIC all you need to do is put the .bas file in its own project folder and type build dla et voila!

Edited by Christos
  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...