def abitgravity(vals): summer = 0 g = 2.5 for val in vals: summer += val.getprobamp(1) if summer > g: return elementa.Adambit(summer / len(vals)) else: return elementa.Adambit(summer / (len(vals) * 2))
def gravity(vals): summer = 0 g = 4 for val in vals: summer += val.observe() if summer > g: return elementa.Adambit(1) else: return elementa.Adambit(0)
def conway(vals): sumstart = 0 for i in range(8): sumstart += vals[i + 1].observe() if sumstart == 3: return elementa.Adambit(1) if (sumstart == 2) and vals[0].observe(): return elementa.Adambit(1) return elementa.Adambit(0)
def tangledup(vals): valLen = len(vals) if (len(vals) % 2) == 0 else len(vals) - 1 oldtangle = None for i in range(0, valLen, 2): if not oldtangle: oldtangle = elementa.twotangle(vals[i], vals[i + 1]) else: newtangle = elementa.twotangle(vals[i], vals[i + 1]) oldtangle = [og * ng for og, ng in zip(oldtangle, newtangle)] return elementa.Adambit(oldtangle[1])
def main(): if '--help' in sys.argv: print(HELP) exit() argind = 0 for i in range(len(sys.argv)): if (sys.argv[i] == '--load') and (len(sys.argv) >= (i + 2)): if '--no-display' in sys.argv: print("...time wasting dumbass...\n\n\n\n\nugh\n\n\n\n\n") print( "This combination of arguments makes no logical sense, quitting..." ) exit() argpath = sys.argv[i + 1] if argpath[-1] != '/': argpath += '/' setGlobalProperties(False) displayFromPng(loadPngArray(argpath)) exit() setGlobalsFromDict(loaderScreen()) thisfile = open('main.py', 'r') rulefuncs = [] for line in thisfile.readlines(): if (len(line) > 2) and (line[:2] == "##"): rulefuncs.append(line[2:-1]) thisfile.close() rulefunc = None while not (rulefunc in rulefuncs): print("Pick Rule to Use:") for possible in rulefuncs: print(' ', possible) rulefunc = input("Choose: ") rulefunc = eval(rulefunc) #setting the initial state to random crapspace = chunkspace.ChunkSpace( VOXELS_X, VOXELS_Y, VOXELS_T, elementa.Adambit(0)) #create size of demiverse for i in range(crapspace.wide): for j in range(crapspace.long): crapspace.setValue(i, j, 0, elementa.Adambit(random.uniform(0, 1))) #loading the demiverse according to the rules and inital state print("Loading!!!") loadtime = time() if '--mp' in sys.argv: halfwide = int(crapspace.wide / 2) firsthalf = mp.Process(target=crapspace.applyRules, args=( rulefunc, True, (0, halfwide), None, )) firsthalf.start() crapspace.applyRules(rulefunc, True, (halfwide, crapspace.wide), None) firsthalf.join() else: crapspace.applyRules(rulefunc, True, None, None) loadtime = time() - loadtime print("\nAll Loaded Up. And it only took", loadtime, "seconds!") for i in range(len(sys.argv)): if (sys.argv[i] == '--save') and (len(sys.argv) >= (i + 2)): argpath = sys.argv[i + 1] if argpath[-1] != '/': argpath += '/' print("Saving to PNG") crapspace.saveToPics(argpath) print("\nDone Saving") #displays the created demiverse if '--no-display' in sys.argv: exit() else: displayFromChunks(crapspace)