PLUS4-ANTS-ON-THE-SCREEN-IN-MULTICOLOR --------------------------------------------------------------------------------------------------- TOOL: BASIC-3.5 {Commodore PLUS4} Language: BASIC Extra: none Author: Misel Zivanovic Note: (C) 06th of OCTOBER 2026 - www.lived.ch, mzretro.ch Doc Revision: 1.1 Last update: 14:22 07.11.2026 --------------------------------------------------------------------------------------------------- Because Commodore Plus4 BASIC 3.5 is pretty compatible with BASIC 7.0 {C128}, it wasn't so difficult to make Multicolor Ants be compatible. This is only the BASIC RND version {C128 version has also RND# produced in assembly} UPDATE: So i added another version but also this one is biased to squeeze its butt to the lower right corner. Can't tell for sure, but it is somehow obvious that BASIC RND is to blame! I noticed how I actually did not do anything to cover RANDOM # in assembly for Commodore Plus4. Need to change that first, and then I'll come back to update this code again! --------------------------------------------------------------------------------------------------- BASIC RANDOM NUMBERS: VERSION 1 --------------------------------------------------------------------------------------------------- 100 rem ------------------------------- 110 rem www.mzretro, www.lived.ch 120 rem ------------------------------- 130 graphic 3,1:color 0,1:color4,1 135 sw=159:sh=199:xy=10:max=10 141 dim x(xy),y(xy),mx(xy),my(xy) 142 for a=1 to max 143 x(a)=rnd(1)*sw+1:rem x coord 144 y(a)=rnd(1)*sh+1:rem y coord 151 next: 152 rem ******************************* 160 color1,7,7:color2,7,7:color 1,16,7 175 for a=1 to max 180 mx(a)=(rnd(1)*10+5)/10 181 my(a)=(rnd(1)*10+5)/10 182 tg=int(rnd(1)*4+1) 183 if tg=1 then x(a)=x(a)+(-mx(a)) 184 if tg=2 then x(a)=x(a)+abs(mx(a)) 185 if tg=3 then y(a)=y(a)+(-my(a)) 186 if tg=4 then y(a)=y(a)+abs(my(a)) 210 if x(a)>=sw then x(a)=159 220 if x(a)<=0 then x(a)=1 230 if y(a)>=sh then y(a)=159 240 if y(a)<=0 then y(a)=1 250 : 260 rem ---------------------------- 270 : 280 co=int(rnd(1)*3+1):h=rnd(1)*7+1 285 ifco=1thencolor1,int(rnd(1)*14+2),h 500 draw co,x(a),y(a):next 510 goto 175 --------------------------------------------------------------------------------------------------- BASIC RANDOM NUMBERS: VERSION 2 --------------------------------------------------------------------------------------------------- NOTE: still the same issues as in the previous version. The random number pattern is in majority building a group of numbers and then the pattern is repeated. Larger share is going towards the right side {again} which means how mostly positive numbers are appearing in this "random" pattern! After a while, also no NEW numbers are generated, which is resulting in ANTS jumping around in lower right corner! --------------------------------------------------------------------------------------------------- 100 rem ------------------------------- 110 rem www.mzretro, www.lived.ch 120 rem ------------------------------- 130 graphic 3,1:color 0,1:color4,1 140 sw=159:sh=199:xy=10:max=10 150 dim x(xy),y(xy),mx(xy),my(xy) 160 for a=1 to max 170 x(a)=rnd(1)*sw+1:rem x coord 180 y(a)=rnd(1)*sh+1:rem y coord 190 next: 210 color1,7,7:color2,7,2:color 1,16,5 220 for a=1 to max 230 mx(a)=(rnd(1)*31-15)/10 240 my(a)=(rnd(1)*31-15)/10 260 x(a)=x(a)+(mx(a)) 270 y(a)=y(a)+(my(a)) 280 if x(a)>=sw then x(a)=sw 290 if x(a)<=0 then x(a)=1 300 if y(a)>=sh then y(a)=sh 310 if y(a)<=0 then y(a)=1 320 co=int(rnd(1)*3+1):h=rnd(1)*7+1 330 ifco=1thencolor1,int(rnd(1)*14+2),h 340 draw co,x(a),y(a):next 350 goto 220 --------------------------------------------------------------------------------------------------- ASSEMBLY {still BASIC though} RANDOM NUMBERS: VERSION 3 --------------------------------------------------------------------------------------------------- NOTE: WORK IN PROGRESS, 20:21 07.11.2026 It's slightly better... According to instruction, first rnd(0) is to use, and then later rnd(1) to get constant random numbers... A short delay loop is added! Line 155. It's clock based RND number generation. Will it help?! -->>> Well, still going towards the bottom of the screen, just slower! You can say: Constant random numbers, my ass! Haha... --------------------------------------------------------------------------------------------------- 100 rem ------------------------------- 110 rem www.mzretro, www.lived.ch 120 rem ------------------------------- 130 graphic 3,1:color 0,1:color4,1 140 sw=159:sh=199:xy=10:max=10 150 dim x(xy),y(xy),mx(xy),my(xy) 155 mx(1)=rnd(0) 160 for a=1 to max 170 x(a)=rnd(1)*sw+1:rem x coord 180 y(a)=rnd(1)*sh+1:rem y coord 190 next: 210 color1,7,7:color2,7,2:color 1,16,5 220 for a=1 to max 230 mx(a)=(rnd(1)*31-15)/10 235 for b=1to100:next 240 my(a)=(rnd(1)*31-15)/10 260 x(a)=x(a)+(mx(a)) 270 y(a)=y(a)+(my(a)) 280 if x(a)>=sw then x(a)=sw 290 if x(a)<=0 then x(a)=1 300 if y(a)>=sh then y(a)=sh 310 if y(a)<=0 then y(a)=1 320 co=int(rnd(1)*3+1):h=rnd(1)*7+1 330 ifco=1thencolor1,int(rnd(1)*14+2),h 340 draw co,x(a),y(a):next 350 goto 220