Пример #1
0
total_mass = 20000
test_xsize, test_ysize, test_k = 30, 20, 15
test_total_mass = 200
minmaxsize, maxmaxsize = 5, 5
minuptake, maxuptake = 0.4, 0.4
minmaxage, maxmaxage = 1600, 1600
num_dna = 3
ininum = 150

merge_thres = 0.04
mut_per_diff = 3.0

exputil.set_size(xsize, ysize)
exputil.set_traits_range(ms1=minmaxsize,
                         ms2=maxmaxsize,
                         ut1=minuptake,
                         ut2=maxuptake,
                         ma1=minmaxage,
                         ma2=maxmaxage)
exputil.set_heredity(merge_thres, mut_per_diff)


#>>>initial run>>>
def init_world():
    return exputil.construct_world(xsize, ysize, total_mass, num_dna, ininum)


def do_init(limit,
            period,
            runnum,
            screen_off=False,
            print_moment=True,
Пример #2
0
import sys
sys.path.append("./core")
import exputil_cy

xsize, ysize, k = 300, 200, 5
num_dna = 3
ininum = 120
limit = 1100
total_mass = 20000

merge_thres = 0.04
mut_per_diff = 3.0

exputil_cy.set_size(xsize, ysize)
exputil_cy.set_traits_range(ms1=3, ms2=8, ut1=0.1, ut2=0.7, ma1=1500, ma2=1500)
exputil_cy.set_heredity(merge_thres, mut_per_diff)

w = exputil_cy.construct_world(xsize,
                               ysize,
                               total_mass,
                               num_dna,
                               ininum,
                               record_pedigree=True)


def get_num_child(pedigree, id, end_moment):
    s = {id}
    count = 0
    for mid, fid, cid, moment in pedigree:
        if moment > end_moment:
            break