Press 'r' to randomize the field
Press 'e' to randomize the environment color
The idea is that the creatures (cubes) who more closely resemble their environment (backdrop color) are less likely to get eaten.
-When a cube disappears, is was a predator (or random death)
-The cubes most like the background color are less likely to be killed
-Over time, the cubes will interbreed and their color will average out
-Sometimes this may take 1000 'years' or 1000*12 turns (one predatory attack per 'month')
autocam off
dim PosX(25)
dim PosZ(25)
dim SkinTone(25)
for z=1 to 10 step 2
for x=1 to 10 step 2
inc count
PosX(count)=x
PosZ(count)=z
make object cube count,1
position object count,PosX(count),0,PosZ(count)
SkinTone(count)=rgb(rnd(255),rnd(255),rnd(255))
color object count,SkinTone(count)
NEXT
NEXT
Environment=rgb(rnd(255),rnd(255),rnd(255))
color backdrop Environment
move camera up 6
move camera right 5
pitch camera down 55
sync on
do
gosub Predator:`gosub HoldKey:`ActionTimer=timer()+5000
if KillCount>=25*.75 then gosub Procreate
if inkey$()="e" then gosub EnviroPaint:gosub HoldKey
if inkey$()="r" then gosub Randomization:gosub HoldKey
inc Months:if Months=13 then Months=1:inc Years
set cursor 0,0
print "Number of years: ";Years
print "Environment=RGB(";rgbr(Environment);",";rgbg(Environment);",";rgbb(Environment);")"
print " Average=RGB(";rgbr(Average);",";rgbg(Average);",";rgbb(Average);")"
sync
LOOP
HoldKey:
while scancode()<>0:endwhile
return
Predator:
for c=1 to 25
if object exist(c)=0 then goto DeadObject
v1=abs(rgbr(SkinTone(c))-rgbr(Environment))
v2=abs(rgbg(SkinTone(c))-rgbg(Environment))
v3=abs(rgbb(SkinTone(c))-rgbb(Environment))
Risk=abs(765-(v1+v2+v3))
if rnd(Risk/20)=1 then delete object c:inc KillCount
DeadObject:
NEXT
return
Procreate:
`get current mixology
KillCount=0
GeneCount=0
RTotal=0
GTotal=0
BTotal=0
for c=1 to 25
if object exist(c)=1
inc GeneCount
inc RTotal,rgbr(SkinTone(c))
inc GTotal,rgbg(SkinTone(c))
inc BTotal,rgbb(SkinTone(c))
ENDIF
next
RTotal=RTotal/GeneCount:if RTotal<0 then RTotal=0 `else
if RTotal>255 then RTotal=255
GTotal=GTotal/GeneCount:if GTotal<0 then GTotal=0 `else
if GTotal>255 then GTotal=255
BTotal=BTotal/GeneCount:if BTotal<0 then BTotal=0 `else
if BTotal>255 then BTotal=255
Average=rgb(RTotal,GTotal,BTotal)
for c=1 to 25
Randy=Risk/10
mutation1a=rnd(Randy):mutation2a=rnd(Randy):mutation3a=rnd(Randy):mutation1b=rnd(Randy):mutation2b=rnd(Randy):mutation3b=rnd(Randy)
if object exist(c)=0
Ra=rgbr(Average)+rnd(mutation1a)-rnd(mutation1b)
Ga=rgbg(Average)+rnd(mutation2a)-rnd(mutation2b)
Ba=rgbb(Average)+rnd(mutation3a)-rnd(mutation3b)
if Ra<0 then Ra=0 `else
if Ra>255 then Ra=255
if Ga<0 then Ga=0 `else
if Ga>255 then Ga=255
if Ba<0 then Ba=0 `else
if Ba>255 then Ba=255
SkinTone(c)=rgb(Ra,Ga,Ba)
make object cube c,1
position object c,PosX(c),0,PosZ(c)
color object c,SkinTone(c)
ENDIF
NEXT
return
Randomization:
for c=1 to 25
SkinTone(c)=rgb(rnd(255),rnd(255),rnd(255))
if object exist(c)=1 then color object c,SkinTone(c)
NEXT
Years=0:Months=0
return
EnviroPaint:
Environment=rgb(rnd(255),rnd(255),rnd(255))
color backdrop Environment
Years=0:Months=0
return