Board Logo
« Termites »

Welcome Guest. Please Login or Register.
Nov 22nd, 2017, 7:59pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Termites  (Read 308 times)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1213
xx Termites
« Thread started on: May 5th, 2017, 12:28pm »

Bluatigro has posted code called Termites at LB that looks interesting but I wonder if it might be sped up in some way,

yeah, I know, I am an impatient sort at times.
User IP Logged

B+
tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3618
xx Re: Termites
« Reply #1 on: May 5th, 2017, 1:23pm »

already
http://libertybasic.conforums.com/index.cgi?action=display&board=game&num=1493999225&start=0#1494007975
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1213
xx Re: Termites
« Reply #2 on: May 5th, 2017, 2:02pm »

Thanks tsh73,

I did just now finish translating and running in faster BASIC.

Kind of disappointed more tunnel like structures were not formed, like ant farm.

Maybe I mistook something in trans. Are the termites supposed to basically just go up and down vertically until they find and push a grain of wood once and then reverse direction?

Do I need to run this much longer than 1000 for more distinct tunnels?
User IP Logged

B+
tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3618
xx Re: Termites
« Reply #3 on: May 5th, 2017, 2:57pm »

Code:
Are the termites supposed to basically just go up and down vertically 

I think there is a line missing in source code. Try runing my version, they run in all directions, slightly changing direction (randomly), turning backwards on hit.

About number - I dunno, I think there should be some bablance between area, sand number and speed / proximity distance.

I run 1000 and 10000 - not much difference (on my smaller scale).
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1213
xx Re: Termites
« Reply #4 on: May 5th, 2017, 3:14pm »

Thanks, I will compare codes, yours, mine and blu's.

Code:
      'call rotate dx , dy , t.dir( t )
      dx = 4 * cos(t.dir( t ))
      dy = 4 * sin(t.dir( t ))

 


tsh73, I noticed same as you about pen up and down and smaller scales but with this code above, you never use rotate sub. I will try this in my BASIC translation.
« Last Edit: May 5th, 2017, 3:18pm by bplus » User IP Logged

B+
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1213
xx Re: Termites
« Reply #5 on: May 5th, 2017, 3:41pm »

Hi tsh73,

With your mod for rotate, I am still getting up and down.

I think it is this line which you haven't changed (i think)
t.dir( t ) = t.dir( t ) + atn( 1 ) * 4

atn(1) is 45 degrees, he is adding 45 degrees to t.dir but it's having effect of 180 degree change, at least in my code trans.

Well if it is not suppose to be up/down then I know where to look for error.

Wait 45 times 4 is 180! So need to start in random direction from beginning OR don't multiply by 4 that might be it!
« Last Edit: May 5th, 2017, 3:43pm by bplus » User IP Logged

B+
tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3618
xx Re: Termites
« Reply #6 on: May 5th, 2017, 4:25pm »

About up and down movement
Just after
Code:
      t.dir( t ) = t.dir( t ) + rnd( 0 ) - .5
      call rotate dx , dy , t.dir( t ) 

there should be two lines, one updating x by dx, another updating y by dy.
Bluatigro code has only one for 'y' hence it goes up and down only ;)

Line
Code:
t.dir( t ) = t.dir( t ) + atn( 1 ) * 4 

is indeed 180 degree change - it should happen after hitting blue particle.

As for rotate sub:
Bluatigro's is general-purpose rotation, for any dx dy
but actually he always sets (dx dy) = (4 0) then rotates. So I took shortcut.
And since JB is slow and calling functions is costly, I inlined it.
« Last Edit: May 5th, 2017, 4:25pm by tsh73 » User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1213
xx Re: Termites
« Reply #7 on: May 5th, 2017, 4:38pm »

Well, I experimented by removing the multiplication by 4 after atn(1), ran 50 termites in 5000 wood grains, still got up and down but I see vertical line formations in output screen after 1000 rounds.

The questions remains, is the effect enhanced or spoiled if we managed to get the termites working in random directions?

Actually, if they spiral outward from the start? hmm...

Maybe time to see if can find other termite code.

« Last Edit: May 5th, 2017, 4:39pm by bplus » User IP Logged

B+
tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3618
xx Re: Termites
« Reply #8 on: May 5th, 2017, 4:52pm »

So did you add
Code:
t.x( t ) = t.x( t ) + dx 

line?
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3618
xx Re: Termites
« Reply #9 on: May 5th, 2017, 4:58pm »

Quote:
I experimented by removing the multiplication by 4 after atn(1),

It made all termites run clockwise (45 degrees after each hit)
LOL
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1213
xx Re: Termites
« Reply #10 on: May 5th, 2017, 5:11pm »

Yeah CRAZY!

I added your missing line and got same! : D < laughing
Code:
      'dx = 4 ' only to right??
      'dy = 0 ' no up/down ??
      'tdir( t ) = tdir( t ) + rnd - .5  ' ah some random
      'rotate dx , dy , tdir( t ) 'this mixes x, y fro random direction off way but OK
      'call rotate dx , dy , t.dir( t )
      dx = 4 * cos(tdir( t ))  
      dy = 4 * sin(tdir( t ))
      tx( t ) = tx( t ) + dx     '<<<<<<<<<<<<<<!!!
      ty( t ) = ty( t ) + dy

 


They are all going around in circles undoing each other's work! But funny to watch.
« Last Edit: May 5th, 2017, 5:12pm by bplus » User IP Logged

B+
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1213
xx Re: Termites
« Reply #11 on: May 5th, 2017, 7:09pm »

OK with
Code:
winx = 640
winy = 480
qt = 50
qw = 20000
 

atn(1) * 4 'to reverse after hit

running very slow, it looks like bacillus forming in Petri dish long straight lines (of blu) at random angles.

I wonder if there are any ant farm sim's out there, I bet there are!
« Last Edit: May 5th, 2017, 7:10pm by bplus » User IP Logged

B+
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls