コード例 #1
0
ファイル: genetic_sampler.py プロジェクト: 7yl4r/LifeGenes
from LifeGenes.lifegenes_core.genetic_sampler import collect_dna
import logging
from LifeGenes.lifegenes_core.setupLog import setupLog
setupLog('genetic_sampler.log')


collect_dna()
コード例 #2
0
ファイル: drawColors.py プロジェクト: 7yl4r/LifeGenes
# this script creates a cell genome for each cell in the current layer, 
# and then displays the genetic 'color' of each cell by creating another 
# layer using the custom rule 'constant.table' which allows for 255 
# unchanging states (and thus a nice range of colors).
# Please see the [LifeGenes project for genetic cellular automaton](https://github.com/7yl4r/LifeGenes) for more info.

from LifeGenes.lifegenes_core.environment import environment as lifegenes_environment
from LifeGenes.lifegenes_core.setupLog import setupLog
import logging
setupLog('drawColors.log')

import golly as g

lg_envmt = lifegenes_environment()
lg_envmt.drawColor()

コード例 #3
0
# this script allows for testing of lifegenes functionality from the python command line rather than the golly environment. Currently this is accomplished by using a mock-golly module called folly (short for fake-golly). The folly module does not actually perform all functions as golly would, it just looks like it for testing.

try:    # print a nice message if someone tries to open this script from w/in golly
    import golly as g
    g.exit('this script is for dev test only and cannot be run from within golly, check out the scripts in the "LifeGenes" folder instead')
except:
    from LifeGenes.lifegenes_core.tests.folly import folly as g

from LifeGenes.lifegenes_core.setupLog import setupLog
from LifeGenes.lifegenes_core.tests.optimization_tools import timedRuns
from os import system

import logging
setupLog('__test_LifeGenes.log')

def wait():
    try:
        system('pause')  #windows, doesn't require enter
    except:
        system('read -p "Press any key to continue"') #linux


# MAIN
logging.info('script started')
nruns = 10

print 'testing environment...'
from LifeGenes.lifegenes_core.environment import environment as lifegenes_environment
lg_envmt = lifegenes_environment()
testNames = list()
testTimes = list()
コード例 #4
0
ファイル: genetic_painter.py プロジェクト: 7yl4r/LifeGenes
#this script allows the user to select a genetic sample saved pallate and draw cells.

import golly as g
from LifeGenes.lifegenes_core.cellList import cellList
from LifeGenes.lifegenes_core.environment import environment 
from LifeGenes.lifegenes_core.cell import Cell

import logging
from LifeGenes.lifegenes_core.setupLog import setupLog
setupLog('genetic_filler.log')

from LifeGenes.lifegenes_core.cellPallate import cellPallate

def draw_dna():
    logging.debug('loading cell pallate')
    pallate = cellPallate()
    pallate.load()

    logging.debug('getting default pallate selection')
    chosenCell = pallate.getUserChoice()
    chosenName = pallate.getSelectedCellName()
    g.show('now drawing with DNA from '+chosenName)
    logging.debug('now drawing with DNA from '+chosenName+'='+str(chosenCell))

    # prepare environment
    env = environment()
    logging.debug('turning on golly even script access')
    event = g.getevent(True)  # turn on golly event script access
    # === let user draw
    g.setcursor("Draw")
    try:    #this try statement is just to ensure the 'finally' block is run
コード例 #5
0
ファイル: stress_test.py プロジェクト: 7yl4r/LifeGenes
# then displays the genetic 'color' of each cell.
# The script then begins cycling between rounds of cell movement and cell evolution.
# Please see the [LifeGenes project for genetic cellular automaton](https://github.com/7yl4r/LifeGenes) for more info.
try:
    import golly as g
except ImportError:
    from LifeGenes.lifegenes_core.tests.folly import folly as g

from LifeGenes.lifegenes_core.environment import environment as lifegenes_environment

from time import time    #for debugging timers

from LifeGenes.lifegenes_core.setupLog import setupLog

import logging
setupLog('stressTest.log')

def makeCheckerBoard(size):
    for x in range(size):
        for y in range(size):
            g.setcell(x,y,(x+y)%2)


class run():
    def __init__(self):
        try:
            g.show('setting up test')


            testSize = 100 #this is the size of one side of the square testing area
            g.select([-testSize/2,-testSize/2,testSize,testSize])
コード例 #6
0
ファイル: evolveMovingCells.py プロジェクト: 7yl4r/LifeGenes
# this script creates a cell genome for each cell in the current layer, 
# then displays the genetic 'color' of each cell.
# The script then begins cycling between rounds of cell movement and cell evolution.
# Please see the [LifeGenes project for genetic cellular automaton](https://github.com/7yl4r/LifeGenes) for more info.

import golly as g

from LifeGenes.lifegenes_core.environment import environment as lifegenes_environment

# import time    #for delays when debugging

from LifeGenes.lifegenes_core.setupLog import setupLog

import logging
setupLog('movingCells.log')


class run():
    def __init__(self):
        logging.info('script started')
        lg_envmt = lifegenes_environment()
        lg_envmt.drawColor()
        logging.info('setup complete; beginning evolution cycles')
        try:
            while(True):    #until stopped by golly
                g.show('cells moving')
                for i in range(5): # rounds of cell movement
                    #logging.debug('movement round '+str(i))
                    lg_envmt.cellMotions()
                    #logging.debug('cells moved')
                    lg_envmt.drawColor()
コード例 #7
0
# this script creates a cell genome for each cell in the current layer, 
# and then displays the genetic 'color' of each cell by creating another 
# layer using the custom rule 'constant.table' which allows for 255 
# unchanging states (and thus a nice range of colors).
# Please see the [LifeGenes project for genetic cellular automaton](https://github.com/7yl4r/LifeGenes) for more info.

from LifeGenes.lifegenes_core.environment import environment as lifegenes_environment
from LifeGenes.lifegenes_core.setupLog import setupLog

import golly as g
import logging
setupLog('evolveCellsWithColor.log')

class run():
	def __init__(self):
		logging.info('script started')
		lg_envmt = lifegenes_environment()
		lg_envmt.drawColor()
		logging.info('setup complete; beginning evolution cycles')
		try:
			while(True):	#until stopped by golly
				g.step()
				#g.update()
				lg_envmt.update()
				lg_envmt.drawColor()
				g.update()
		finally:
				logging.info('cycling halted from external source (probably golly)')
				g.show('closing gracefully, hold on just a sec...')
				lg_envmt.teardown()