Pavgran wrote: ↑November 15th, 2022, 3:05 pm
Lua viewer script:
This version of RCT was obtained by taking a 'path of least resistance' from RCT16, i.e. modifying as few things as possible to reach target. The most glaring example is at the start: In RCT15 the elbow is first pushed quite far, and then it is retracted back to the start to build something. That's because in RCT16 the elbow started all the way back, and it was necessary to pull it. And the easiest way to adapt RCT15 with its fixed elbow position was to just push the elbow to the same starting point as it was in RCT16.
There are some plans to do optimizations that would reduce total cost from ~1.6M bits to ~1.5M bits, or about 5-10%. These are not specific to RCT15, but it seems pointless to do any work on RCT16 now.
I have made few changes in lua viewer script ... now you can stop the script run it at your will and restart from current position.
I had to change duration to duration+end format, what allows adding new checkpoints ... let one of the parameters nil and script tels you what to fill. (English in comments could definitely be improved...)
Code: Select all
local number = 195435859872
local showtext = ""
local g = golly()
g.setbase(2)
g.setpos("0","0")
local bn = require "../gplus.bignum"
local false_literal = false
local true_literal = true
local startGen = g.getgen()
local bnZero = BigNum.new(0)
g.autoupdate(true_literal)
local function smoothmag(imag, fmag)
while imag ~= fmag do
if imag < fmag then
imag = imag + 1
else
imag = imag - 1
end
g.setmag(imag)
g.sleep(200)
end
return imag
end
local function run_for_to(n, targetgen, istep, fstep, mags)
local bnGen=BigNum.new(g.getgen())
local bnEnterGen=bnGen
local bnTargetGen
local bnN
local magindex
fstep = fstep or 11
if (targetgen == nil) and (n == nil) then
g.note(showtext.." - run_for_to with unknown duration")
return
end
if targetgen ~= nil then
bnTargetGen = BigNum.new(targetgen)
end
if n ~= nil then
bnN = BigNum.new(n)
end
if (targetgen ~= nil) and (n ~= nil) then
if bnN+bnGen ~= bnTargetGen then
if startGen > bnTargetGen then return end -- skipping milestones to restart
if startGen + bnN < bnTargetGen then -- must be script error
g.note(showtext.." - run_for_to for not matching to"..BigNum.mt.tostring(bnGen).." + "..BigNum.mt.tostring(bnN).."->"..BigNum.mt.tostring(bnTargetGen))
return
else
--g.note(showtext.." : "..BigNum.mt.tostring(bnGen).." + "..BigNum.mt.tostring(bnN).."->"..BigNum.mt.tostring(bnTargetGen).." running to first milestone after restart")
bnN = bnTargetGen - bnGen
fstep = 0
end
end
end
if (n==nil) then -- helper for editting
bnN = bnTargetGen - bnGen
--g.note(showtext.." : "..BigNum.mt.tostring(bnGen).." + "..BigNum.mt.tostring(bnN).."->"..BigNum.mt.tostring(bnTargetGen))
end
if (targetgen == nil) then -- helper for editting
bnTargetGen = bnN + bnGen
g.note(showtext.." : "..BigNum.mt.tostring(bnGen).." + "..BigNum.mt.tostring(bnN).."->"..BigNum.mt.tostring(bnTargetGen))
end
local sTargetGen = BigNum.mt.tostring(bnTargetGen)
if bnN<=0 then return end
local nn=BigNum.mt.tostring(bnN)
istep = istep or math.min(30, math.floor(math.log(nn)/math.log(2))-6)
local cstep = g.getstep()
if cstep<fstep then cstep = fstep end
if cstep>istep then cstep = istep end
if mags then
magindex = 1
currmag = mags[magindex]
g.setmag(currmag)
magindex = magindex + 1
end
local bn3Eistep = BigNum.new(3*2^istep)
g.setstep(cstep)
while bnN > bnZero do
g.show(showtext.." : "..BigNum.mt.tostring(bnN).."->"..BigNum.mt.tostring(bnTargetGen).." i"..istep.." f"..fstep)
if (istep > fstep) and (bnN < bn3Eistep) then
istep = istep - 2
if istep < 0 then istep = 0 end
bn3Eistep = BigNum.new(3*2^istep)
cstep = istep
if mags and magindex <= #mags then
currmag = smoothmag(currmag, mags[magindex])
magindex = magindex + 1
end
g.setstep(cstep)
end
g.step()
bnGen=BigNum.new(g.getgen())
bnN = bnTargetGen - bnGen
cstep = g.getstep()
if (cstep<istep) then -- owerwriting manual slowdown
cstep = cstep+1
g.setstep(cstep)
end
if (cstep>istep) then -- owerwriting manual speedup
cstep = cstep-1
g.setstep(cstep)
end
end
if n==nil then
bnN=bnGen-bnEnterGen
g.note(showtext.." final generation: "..BigNum.mt.tostring(bnEnterGen).." + "..BigNum.mt.tostring(bnN).."->"..BigNum.mt.tostring(bnGen))
end
end
showtext="Fast-forwarding to first collision of gliders from GPSEs..."
run_for_to("781743440768", "781743440768", 30, 6, {-30, -26, -23, -20, -18, -16, -14, -12, -10, -8, -6, -4, -2})
showtext="Note the gliders going from the center..."
run_for_to("1546", "781743442314", 4, 4, {0})
showtext="Fast-forwarding to first bit-reading gliders..."
run_for_to("1172615157952", "1954358600272",30, 6, {-2})
showtext="Note the gliders going from the center ..."
run_for_to("2048","1954358602320", 4, 4, {0})
showtext="Transform the initial crash site into a usable (inserted bits speeded up sloooo ooowly returning gliders) blinker elbow"
run_for_to("16621568", "1954375223888")
g.setpos("768", "-768")
showtext="Move the blinker elbow a bit to the northeast to make room for construction arms"
run_for_to("1038089520","1955413313408", nil, nil, {-2})
g.setpos("768", "-1536")
showtext="Position some blocks in useful locations"
run_for_to(653883392,"1956067197520",nil,nil,{-2})
run_for_to("4480","1956067202000", 6, 6)
run_for_to("3962880","1956071164880",nil,nil,{-2})
showtext="Construct the decoder and better construction arm (DBCA)"
run_for_to("81722276800","2037793441680",30,6)
showtext="Launch a Corderrake to activate the meteor shower seed and pass control to the DBCA"
run_for_to("105840640","2037899282320",nil,6)
showtext="Initialise DBCA and position construction elbow"
run_for_to("13303808","2037912586128")
g.setpos("0", "0")
showtext="The DBCA removes the pi explosion"
run_for_to("7667712","2037920253840",nil, 6, {0})
g.setpos("768", "-1536")
showtext="The DBCA constructs some switching circuitry and lounches first glider far SE"
run_for_to("12374000","2037932627840",14,4,{-2})
g.setpos("0", "0")
showtext="The DBCA lounches third glider far SE to make one time reflector"
run_for_to("5302784","2037937930624",nil,6,{0})
run_for_to("992","2037937931616",3,3)
g.setpos("1024", "0")
showtext="The DBCA constructs some switching circuitry"
run_for_to("386351648","2038324283264",nil,5,{-2})
showtext="The DBCA constructs the extreme compression construction arm (ECCA)"
run_for_to("10528358400","2048852641664")
g.setpos("1024", "-1024")
showtext="The DBCA constructs some additional switching circuitry and jumps southeast"
run_for_to("172052480","2049024694144",nil,6,{-2})
showtext="Notice one glider phase and color will emit gliders, which are counted by the circuitry trash"
run_for_to("36864","2049024731008",6,6)
showtext="The DBCA constructs a BSRD and some Corderabsorbers in the far south-east"
run_for_to("1389174784","2050413905792",30,6)
g.setpos("768", "-1536")
showtext="The trash is gone and the last glider-emission activates switching circuitry to redirect future bits to the BSRD and closes DBCA"
run_for_to("557056","2050414462848",nil,6)
run_for_to("32768","2050414495616",6,6)
showtext="The p8 reflectors are activated and the 'few' remaining gliders are rerouted to the BSRD"
run_for_to("753664","2050415249280")
showtext="Remaining bits generated"
g.setpos("0", "0")
run_for_to("294815055872","2345230305152",nil,6,{-4, -4, -4, -4, -4, -4, -3})
run_for_to("20480","2345230325632",5,5,{-2})
showtext="Now we wait for recepies to reach far SE (creating reflectors and corder absorbers)"
run_for_to("89524727808","2434755053440")
g.setpos("195435860019", "195435859863")
showtext="SE one time reflector is almost created"
run_for_to("384920715264","2819675768704",nil,nil,{0})
showtext="SE one time reflector is created"
run_for_to("11534336","2819687303040",nil,6)
showtext="The DBCA jump to far SE arrives"
run_for_to("11080855040","2830768158080",nil,6)
g.setpos("195435859968", "195435859968")
showtext="The BSRD and Corderabsorbers commence construction in the far south-east"
run_for_to("8092","2830768166172",8,8,{-3})
run_for_to("1456288256","2832224454528")
g.setpos("195435860736", "195435859200")
showtext="The BSRD in the far south-east begins reflecting gliders"
run_for_to("196096","2832224651136",nil,6,{-3})
g.setpos("195435860736", "195435859200")
showtext="The BSRD continues reflecting gliders (grab a coffee and come back in 15 minutes; we will wait for you)"
run_for_to("13113229312","2845337880448",25,nil,{-4})
showtext="The recipe returns from the BSRD to the ECCA"
run_for_to("768630145024","3613968025472",nil,nil,{-30})
g.note("Gliders reaching ECCA! Press OK when ready", false_literal)
g.setpos("1024", "0")
showtext="The ECCA reflects the first glider back to destroy the BSRD"
run_for_to("65536","3613968091008",nil,nil,{-2})
g.setpos("512", "-1024")
showtext="The ECCA destroys the remnants of the DBCA"
run_for_to("250347520","3614218438528",nil,nil,{-3})
showtext="The ECCA fires a glider to switch the direction of subsequent gliders"
run_for_to("11730944", "3614230169472")
g.setpos("0", "0")
showtext="The ECCA eliminates ash from the GPSE collision"
run_for_to("41680896","3614271850368",nil,nil,{0})
showtext="The ECCA builds an elbow in the far northwest"
run_for_to("50331648","3614322182016")
showtext="The ECCA launches a salvo of Corderships to clean the south-east trail"
run_for_to("3425239040","3617747421056",nil,nil,{0})
showtext="The ECCA builds some Corderabsorbers in the far south-west"
run_for_to("1643511808","3619390932864")
showtext="The ECCA launches a salvo of Corderships to clean the south-west trail"
run_for_to("1363542016","3620754474880",nil,nil,{-2})
showtext="The ECCA launches a salvo of Corderships to clean the north-west trail"
run_for_to("1968111616","3622722586496")
showtext="The ECCA prepares circuitry to destroy its own elbow"
run_for_to("20709376","3622743295872")
showtext="The ECCA builds a seed for the ATBC"
run_for_to("3812425728","3626555721600")
showtext="The ECCA constructs Corderabsorbers in the far north-west"
run_for_to("525205504","3627080927104")
showtext="The ECCA returns to a known state for self-destruction"
run_for_to("393216","3627081320320")
showtext="The Corderships embark on their journey to clean up the ash trails"
run_for_to("772409540608","4399490860928",nil,nil,{-30})
g.setpos("-195435859568", "195435859568")
showtext="The Corderabsorbers commence construction using slow^2 gliders"
run_for_to("1643511808","4401134372736",nil,nil,{0})
showtext="The Corderabsorbers are fully complete"
run_for_to("7164788736","4408299161472")
g.setpos("-195435859968", "-195435859968")
showtext="The Corderabsorbers commence construction in the far north-west"
run_for_to("525205504","4408824366976",nil,nil,{-2})
g.setpos("0", "0")
showtext="The Corderships continue cleaning the ash trails"
run_for_to("1550728134656","5959552501632",nil,nil,{-30})
g.setpos("195435859968", "195435859968")
showtext="The Corderships begin colliding with the SE Corderabsorbers"
run_for_to("3425239040","5962977740672",nil,nil,{-2})
showtext="The Corderships have finished colliding with the SE Corderabsorbers"
run_for_to("1643511808","5964621252480", nil, nil, {-13})
g.setpos("-195435859968", "195435859968")
showtext="The Corderships begin colliding with the SW Corderabsorbers"
run_for_to("1363542016","5965984794496", nil, nil, {-13})
g.setpos("-195435860365", "-195435860351")
showtext="The Corderships begin colliding with the NW Corderabsorbers"
run_for_to("1901569536","5967886364032",nil, 6, {-13, -13, -13, -10, -8, -6, -4, -2, -1})
run_for_to("2464","5967886366496",2,2)
g.setpos("-195435860000", "-195435860800")
showtext="The last NW Cordership sends a return signal back to destroy the ECCA"
run_for_to("3656","5967886370152",2,2,{-2})
showtext="The ECCA awaits the return glider before self-destructing and emitting an MWSS"
g.setpos("768", "0")
run_for_to("781743439552", "6749629809704", 30, 6,{-30, -28, -26, -24, -22, -20, -18, -16, -14, -12, -10, -8, -6, -4})
showtext="The MWSS triggers the ATBC seed"
run_for_to("30296","6749629840000",0,0,{-1})
I had to find some bignum library, but the one I have downloaded was buggy in tostring, so I have made small changes (and removed some not needed parts) ... it should work with any unbuggy bignum library.
Code: Select all
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%{{{1
--
-- File Name: bignum.lua
-- Package Name: BigNum
--
-- Project: Big Numbers library for Lua
-- Mantainers: fmp - Frederico Macedo Pessoa
-- msm - Marco Serpa Molinaro
-- vm - Vladan Majerech
--
-- History:
-- Version Autor Date Notes
-- 2.0 vm 12/11/2022 Edited for personal needs (just +,-,<,=,>,tostring) bug fixing tostring
-- 1.1 fmp/msm 12/11/2004 Some bug fixes (thanks Isaac Gouy)
-- alfa fmp/msm 03/22/2003 Start of Development
-- beta fmp/msm 07/11/2003 Release
--
-- Description:
-- Big numbers manipulation library for Lua.
-- A Big Number is a table with as many numbers as necessary to represent
-- its value in base 'RADIX'. It has a field 'len' containing the num-
-- ber of such numbers and a field 'signal' that may assume the values
-- '+' and '-'.
--
--$.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--%%%%%%%% Constants used in the file %%%%%%%%--{{{1
RADIX_LEN = 6 ;
RADIX_FIL = "000000" ; -- length >= RADIX_LEN
RADIX = 10^RADIX_LEN ;
--%%%%%%%% Start of Code %%%%%%%%--
BigNum = {} ;
BigNum.mt = {} ;
--BigNum.new{{{1
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--
-- Function: New
--
--
-- Description:
-- Creates a new Big Number based on the parameter num.
--
-- Parameters:
-- num - a string, number or BigNumber.
--
-- Returns:
-- A Big Number, or a nil value if an error occured.
--
--
-- %%%%%%%% --
function BigNum.new( num ) --{{{2
local bignum = {} ;
setmetatable( bignum , BigNum.mt ) ;
BigNum.change( bignum , num ) ;
return bignum ;
end
--%%%%%%%%%%%%%%%%%%%% Functions for metatable %%%%%%%%%%%%%%%%%%%%--{{{1
--BigNum.mt.sub{{{2
function BigNum.mt.sub( num1 , num2 )
local temp = BigNum.new() ;
local bnum1 = BigNum.new( num1 ) ;
local bnum2 = BigNum.new( num2 ) ;
BigNum.sub( bnum1 , bnum2 , temp ) ;
return temp ;
end
--BigNum.mt.add{{{2
function BigNum.mt.add( num1 , num2 )
local temp = BigNum.new() ;
local bnum1 = BigNum.new( num1 ) ;
local bnum2 = BigNum.new( num2 ) ;
BigNum.add( bnum1 , bnum2 , temp ) ;
return temp ;
end
--BigNum.mt.tostring{{{2
function BigNum.mt.tostring( bnum )
local i = 0
local j
local temp = ""
local str
local dotpos
if bnum == nil then
return "nil"
elseif bnum.len > 0 then
for i = bnum.len - 2 , 0 , -1 do
str = tostring(bnum[i])
dotpos = string.find(str..".","%.")
temp = temp .. string.sub(RADIX_FIL..string.sub(str,1,dotpos-1),-RADIX_LEN)
end
str = tostring(bnum[bnum.len - 1])
dotpos = string.find(str..".","%.")
temp = string.sub(str,1,dotpos-1) .. temp
if bnum.signal == '-' then
temp = bnum.signal .. temp
end
return temp
else
return ""
end
end
--BigNum.mt.eq{{{2
function BigNum.mt.eq( num1 , num2 )
local bnum1 = BigNum.new( num1 ) ;
local bnum2 = BigNum.new( num2 ) ;
return BigNum.eq( bnum1 , bnum2 ) ;
end
--BigNum.mt.lt{{{2
function BigNum.mt.lt( num1 , num2 )
local bnum1 = BigNum.new( num1 ) ;
local bnum2 = BigNum.new( num2 ) ;
return BigNum.lt( bnum1 , bnum2 ) ;
end
--BigNum.mt.le{{{2
function BigNum.mt.le( num1 , num2 )
local bnum1 = BigNum.new( num1 ) ;
local bnum2 = BigNum.new( num2 ) ;
return BigNum.le( bnum1 , bnum2 ) ;
end
--BigNum.mt.unm{{{2
function BigNum.mt.unm( num )
local ret = BigNum.new( num )
if ret.signal == '+' then
ret.signal = '-'
else
ret.signal = '+'
end
return ret
end
--%%%%%%%%%%%%%%%%%%%% Metatable Definitions %%%%%%%%%%%%%%%%%%%%--{{{1
BigNum.mt.__metatable = "hidden" ; -- answer to getmetatable(aBignum)
-- BigNum.mt.__index = "inexistent field" ; -- attempt to acess nil valued field
-- BigNum.mt.__newindex = "not available" ; -- attempt to create new field
BigNum.mt.__tostring = BigNum.mt.tostring ;
-- arithmetics
BigNum.mt.__add = BigNum.mt.add ;
BigNum.mt.__sub = BigNum.mt.sub ;
BigNum.mt.__unm = BigNum.mt.unm ;
-- Comparisons
BigNum.mt.__eq = BigNum.mt.eq ;
BigNum.mt.__le = BigNum.mt.le ;
BigNum.mt.__lt = BigNum.mt.lt ;
--concatenation
-- BigNum.me.__concat = ???
setmetatable( BigNum.mt, { __index = "inexistent field", __newindex = "not available", __metatable="hidden" } ) ;
--%%%%%%%%%%%%%%%%%%%% Basic Functions %%%%%%%%%%%%%%%%%%%%--{{{1
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%{{{2
--
-- Function: ADD
--
--
-- Description:
-- Adds two Big Numbers.
--
-- Parameters:
-- bnum1, bnum2 - Numbers to be added.
-- bnum3 - result
--
-- Returns:
-- 0
--
-- Exit assertions:
-- bnum3 is the result of the sum.
--
-- %%%%%%%% --
--Funcao BigNum.add{{{2
function BigNum.add( bnum1 , bnum2 , bnum3 )
local maxlen = 0 ;
local i = 0 ;
local carry = 0 ;
local signal = '+' ;
local old_len = 0 ;
--Handle the signals
if bnum1 == nil or bnum2 == nil or bnum3 == nil then
error("Function BigNum.add: parameter nil") ;
elseif bnum1.signal == '-' and bnum2.signal == '+' then
bnum1.signal = '+' ;
BigNum.sub( bnum2 , bnum1 , bnum3 ) ;
if not rawequal(bnum1, bnum3) then
bnum1.signal = '-' ;
end
return 0 ;
elseif bnum1.signal == '+' and bnum2.signal == '-' then
bnum2.signal = '+' ;
BigNum.sub( bnum1 , bnum2 , bnum3 ) ;
if not rawequal(bnum2, bnum3) then
bnum2.signal = '-' ;
end
return 0 ;
elseif bnum1.signal == '-' and bnum2.signal == '-' then
signal = '-' ;
end
--
old_len = bnum3.len ;
if bnum1.len > bnum2.len then
maxlen = bnum1.len ;
else
maxlen = bnum2.len ;
bnum1 , bnum2 = bnum2 , bnum1 ;
end
--School grade sum
for i = 0 , maxlen - 1 do
if bnum2[i] ~= nil then
bnum3[i] = bnum1[i] + bnum2[i] + carry ;
else
bnum3[i] = bnum1[i] + carry ;
end
if bnum3[i] >= RADIX then
bnum3[i] = bnum3[i] - RADIX ;
carry = 1 ;
else
carry = 0 ;
end
end
--Update the answer's size
if carry == 1 then
bnum3[maxlen] = 1 ;
end
bnum3.len = maxlen + carry ;
bnum3.signal = signal ;
for i = bnum3.len, old_len do
bnum3[i] = nil ;
end
return 0 ;
end
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%{{{2
--
-- Function: SUB
--
--
-- Description:
-- Subtracts two Big Numbers.
--
-- Parameters:
-- bnum1, bnum2 - Numbers to be subtracted.
-- bnum3 - result
--
-- Returns:
-- 0
--
-- Exit assertions:
-- bnum3 is the result of the subtraction.
--
-- %%%%%%%% --
--Funcao BigNum.sub{{{2
function BigNum.sub( bnum1 , bnum2 , bnum3 )
local maxlen = 0 ;
local i = 0 ;
local carry = 0 ;
local old_len = 0 ;
--Handle the signals
if bnum1 == nil or bnum2 == nil or bnum3 == nil then
error("Function BigNum.sub: parameter nil") ;
elseif bnum1.signal == '-' and bnum2.signal == '+' then
bnum1.signal = '+' ;
BigNum.add( bnum1 , bnum2 , bnum3 ) ;
bnum3.signal = '-' ;
if not rawequal(bnum1, bnum3) then
bnum1.signal = '-' ;
end
return 0 ;
elseif bnum1.signal == '-' and bnum2.signal == '-' then
bnum1.signal = '+' ;
bnum2.signal = '+' ;
BigNum.sub( bnum2, bnum1 , bnum3 ) ;
if not rawequal(bnum1, bnum3) then
bnum1.signal = '-' ;
end
if not rawequal(bnum2, bnum3) then
bnum2.signal = '-' ;
end
return 0 ;
elseif bnum1.signal == '+' and bnum2.signal == '-' then
bnum2.signal = '+' ;
BigNum.add( bnum1 , bnum2 , bnum3 ) ;
if not rawequal(bnum2, bnum3) then
bnum2.signal = '-' ;
end
return 0 ;
end
--Tests if bnum2 > bnum1
if BigNum.compareAbs( bnum1 , bnum2 ) == 2 then
BigNum.sub( bnum2 , bnum1 , bnum3 ) ;
bnum3.signal = '-' ;
return 0 ;
else
maxlen = bnum1.len ;
end
old_len = bnum3.len ;
bnum3.len = 0 ;
--School grade subtraction
for i = 0 , maxlen - 1 do
if bnum2[i] ~= nil then
bnum3[i] = bnum1[i] - bnum2[i] - carry ;
else
bnum3[i] = bnum1[i] - carry ;
end
if bnum3[i] < 0 then
bnum3[i] = RADIX + bnum3[i] ;
carry = 1 ;
else
carry = 0 ;
end
if bnum3[i] ~= 0 then
bnum3.len = i + 1 ;
end
end
bnum3.signal = '+' ;
--Check if answer's size if zero
if bnum3.len == 0 then
bnum3.len = 1 ;
bnum3[0] = 0 ;
end
if carry == 1 then
error( "Error in function sub" ) ;
end
for i = bnum3.len , max( old_len , maxlen - 1 ) do
bnum3[i] = nil ;
end
return 0 ;
end
--%%%%%%%%%%%%%%%%%%%% Comparison Functions %%%%%%%%%%%%%%%%%%%%--{{{1
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%{{{2
--
-- Function: EQ
--
--
-- Description:
-- Compares two Big Numbers.
--
-- Parameters:
-- bnum1, bnum2 - numbers
--
-- Returns:
-- Returns true if they are equal or false otherwise.
--
-- %%%%%%%% --
--BigNum.eq{{{2
function BigNum.eq( bnum1 , bnum2 )
if BigNum.compare( bnum1 , bnum2 ) == 0 then
return true ;
else
return false ;
end
end
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%{{{2
--
-- Function: LT
--
--
-- Description:
-- Verifies if bnum1 is lesser than bnum2.
--
-- Parameters:
-- bnum1, bnum2 - numbers
--
-- Returns:
-- Returns true if bnum1 is lesser than bnum2 or false otherwise.
--
-- %%%%%%%% --
--BigNum.lt{{{2
function BigNum.lt( bnum1 , bnum2 )
if BigNum.compare( bnum1 , bnum2 ) == 2 then
return true ;
else
return false ;
end
end
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%{{{2
--
-- Function: LE
--
--
-- Description:
-- Verifies if bnum1 is lesser or equal than bnum2.
--
-- Parameters:
-- bnum1, bnum2 - numbers
--
-- Returns:
-- Returns true if bnum1 is lesser or equal than bnum2 or false otherwise.
--
-- %%%%%%%% --
--BigNum.le{{{2
function BigNum.le( bnum1 , bnum2 )
local temp = -1 ;
temp = BigNum.compare( bnum1 , bnum2 )
if temp == 0 or temp == 2 then
return true ;
else
return false ;
end
end
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%{{{2
--
-- Function: Compare Absolute Values
--
--
-- Description:
-- Compares absolute values of bnum1 and bnum2.
--
-- Parameters:
-- bnum1, bnum2 - numbers
--
-- Returns:
-- 1 - |bnum1| > |bnum2|
-- 2 - |bnum1| < |bnum2|
-- 0 - |bnum1| = |bnum2|
--
-- %%%%%%%% --
--BigNum.compareAbs{{{2
function BigNum.compareAbs( bnum1 , bnum2 )
if bnum1 == nil or bnum2 == nil then
error("Function compare: parameter nil") ;
elseif bnum1.len > bnum2.len then
return 1 ;
elseif bnum1.len < bnum2.len then
return 2 ;
else
local i ;
for i = bnum1.len - 1 , 0 , -1 do
if bnum1[i] > bnum2[i] then
return 1 ;
elseif bnum1[i] < bnum2[i] then
return 2 ;
end
end
end
return 0 ;
end
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%{{{2
--
-- Function: Compare
--
--
-- Description:
-- Compares values of bnum1 and bnum2.
--
-- Parameters:
-- bnum1, bnum2 - numbers
--
-- Returns:
-- 1 - |bnum1| > |bnum2|
-- 2 - |bnum1| < |bnum2|
-- 0 - |bnum1| = |bnum2|
--
-- %%%%%%%% --
--BigNum.compare{{{2
function BigNum.compare( bnum1 , bnum2 )
local signal = 0 ;
if bnum1 == nil or bnum2 == nil then
error("Funtion BigNum.compare: parameter nil") ;
elseif bnum1.signal == '+' and bnum2.signal == '-' then
return 1 ;
elseif bnum1.signal == '-' and bnum2.signal == '+' then
return 2 ;
elseif bnum1.signal == '-' and bnum2.signal == '-' then
signal = 1 ;
end
if bnum1.len > bnum2.len then
return 1 + signal ;
elseif bnum1.len < bnum2.len then
return 2 - signal ;
else
local i ;
for i = bnum1.len - 1 , 0 , -1 do
if bnum1[i] > bnum2[i] then
return 1 + signal ;
elseif bnum1[i] < bnum2[i] then
return 2 - signal ;
end
end
end
return 0 ;
end
--%%%%%%%%%%%%%%%%%%%% Low level Functions %%%%%%%%%%%%%%%%%%%%--{{{1
--BigNum.copy{{{2
function BigNum.copy( bnum1 , bnum2 )
if bnum1 ~= nil and bnum2 ~= nil then
local i ;
for i = 0 , bnum1.len - 1 do
bnum2[i] = bnum1[i] ;
end
bnum2.len = bnum1.len ;
else
error("Function BigNum.copy: parameter nil") ;
end
end
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%{{{2
--
-- Function: Change
--
-- Description:
-- Changes the value of a BigNum.
-- This function is called by BigNum.new.
--
-- Parameters:
-- bnum1, bnum2 - numbers
--
-- Returns:
-- 1 - |bnum1| > |bnum2|
-- 2 - |bnum1| < |bnum2|
-- 0 - |bnum1| = |bnum2|
--
-- %%%%%%%% --
--BigNum.change{{{2
function BigNum.change( bnum1 , num )
local j = 0 ;
local len = 0 ;
local num = num ;
local l ;
local oldLen = 0 ;
if bnum1 == nil then
error( "BigNum.change: parameter nil" ) ;
elseif type( bnum1 ) ~= "table" then
error( "BigNum.change: parameter error, type unexpected" ) ;
elseif num == nil then
bnum1.len = 1 ;
bnum1[0] = 0 ;
bnum1.signal = "+";
elseif type( num ) == "table" and num.len ~= nil then --check if num is a big number
--copy given table to the new one
for i = 0 , num.len do
bnum1[i] = num[i] ;
end
if num.signal ~= '-' and num.signal ~= '+' then
bnum1.signal = '+' ;
else
bnum1.signal = num.signal ;
end
oldLen = bnum1.len ;
bnum1.len = num.len ;
elseif type( num ) == "string" or type( num ) == "number" then
if string.sub( num , 1 , 1 ) == '+' or string.sub( num , 1 , 1 ) == '-' then
bnum1.signal = string.sub( num , 1 , 1 ) ;
num = string.sub(num, 2) ;
else
bnum1.signal = '+' ;
end
num = string.gsub( num , " " , "" )
local sf = string.find( num , "e" )
--Handles if the number is in exp notation
if sf ~= nil then
local e = string.sub( num , sf + 1 )
num = string.sub( num , 1 , sf - 1 )
e = tonumber(e) ;
if e ~= nil and e > 0 then
e = tonumber(e) ;
else
error( "Function BigNum.change: string is not a valid number" ) ;
end
local dotpos=string.find(num..".","%.")
num = string.gsub( num , "%." , "" )
local dotshift = string.len(num)+1-dotpos
for i = 1 , e do
num = num .. "0"
end
if dotshift>0 then num = string.sub(num,1,-dotshift-1) end
else
sf = string.find( num , "%." ) ;
if sf ~= nil then
num = string.sub( num , 1 , sf - 1 ) ;
end
end
l = string.len( num ) ;
oldLen = bnum1.len ;
if (l > RADIX_LEN) then
local mod = l-( math.floor( l / RADIX_LEN ) * RADIX_LEN ) ;
for i = 1 , l-mod, RADIX_LEN do
bnum1[j] = tonumber( string.sub( num, -( i + RADIX_LEN - 1 ) , -i ) );
--Check if string dosn't represents a number
if bnum1[j] == nil then
error( "Function BigNum.change: string is not a valid number" ) ;
bnum1.len = 0 ;
return 1 ;
end
j = j + 1 ;
len = len + 1 ;
end
if (mod ~= 0) then
bnum1[j] = tonumber( string.sub( num , 1 , mod ) ) ;
bnum1.len = len + 1 ;
else
bnum1.len = len ;
end
--Eliminate trailing zeros
for i = bnum1.len - 1 , 1 , -1 do
if bnum1[i] == 0 then
bnum1[i] = nil ;
bnum1.len = bnum1.len - 1 ;
else
break ;
end
end
else
-- string.len(num) <= RADIX_LEN
bnum1[j] = tonumber( num ) ;
bnum1.len = 1 ;
end
else
error( "Function BigNum.change: parameter error, type unexpected" ) ;
end
--eliminates the deprecated higher order 'algarisms'
if oldLen ~= nil then
for i = bnum1.len , oldLen do
bnum1[i] = nil ;
end
end
return 0 ;
end
--BigNum.put{{{2
--Places int in the position pos of bignum, fills before with zeroes and
--after with nil.
function BigNum.put( bnum , int , pos )
if bnum == nil then
error("Function BigNum.put: parameter nil") ;
end
local i = 0 ;
for i = 0 , pos - 1 do
bnum[i] = 0 ;
end
bnum[pos] = int ;
for i = pos + 1 , bnum.len do
bnum[i] = nil ;
end
bnum.len = pos ;
return 0 ;
end
--printraw{{{2
function printraw( bnum )
local i = 0 ;
if bnum == nil then
error( "Function printraw: parameter nil" ) ;
end
while 1 == 1 do
if bnum[i] == nil then
io.write( ' len '..bnum.len ) ;
if i ~= bnum.len then
io.write( ' ERRO!!!!!!!!' ) ;
end
io.write( "\n" ) ;
return 0 ;
end
io.write( 'r'..bnum[i] ) ;
i = i + 1 ;
end
end
--max{{{2
function max( int1 , int2 )
if int1 > int2 then
return int1 ;
else
return int2 ;
end
end
--decr{{{2
function decr( bnum1 )
local temp = {} ;
temp = BigNum.new( "1" ) ;
BigNum.sub( bnum1 , temp , bnum1 ) ;
return 0 ;
end
If some of my DBCA versions would replace current DBCA, the delaying trash counting gliders (N gliders absorber) of one color and phase should be either roughly twice prolonged, as in my version it would count all gliders of that color. Or ... the p256 filtering stream should be used to filter one of phases out.
I bet changing the trash counter would be much cheaper.
BTW: I do not know why (on my comp) the cofee waiting phase is slower when run with 2^{30} steps. This is why I have forced 2^{25}. Surprisingly following phases are fine with 2^{30}.
To make the script adjustable, eon units should be introduced (number?)... added parameter ... number of duration eons and global variable current eon.
For editting purposes nil, target generation is good input, which should be translated to generation raletive to current eon when in duration+target format.
So ... nil, targetGeneration,..., (target eon increment) / duration, nil,...., (target eon increment) / duration, target generation in target eon, ...., (target eon increment) will be used. Hmmm, another todo.