예제 #1
0
    for x in d:
        #print "x0", x[0].split("_")[0]
        #print "x1", x[0].split("_")[1]
        #print "w", x[1]
        key_x = int(x[0].split("_")[0])
        key_y = int(x[0].split("_")[1])

       matrix[mapping[key_x]][mapping[key_y]] = matrix[mapping[key_y]][mapping[key_x]]=float(x[1])/r

    return matrix

if __name__=="__main__":
    try:
        import psycho
        psycho.full()
    except ImportError:
        pass

    if len(sys.argv)>1:
        period = sys.argv[1]
    else:
        period = "sixmonths"

    if len(sys.argv)>2:
        path = sys.argv[2]
    else:
        path = os.getcwd()+"/"

    if period =="quarter":
        path = path+"5_points_network_2010/data/new_networks/"+str(period)+"s"+"/"+str(period)+"s"+"/"
예제 #2
0
파일: isle.py 프로젝트: rik0/rk-exempla
import itertools
import random
import copy
import sys
import pickle

try:
    import psycho
    psycho.full()
except ImportError:
    pass

def random_plant(left, top, width, height):
    pos_x = random.randint(left, left+width-1)
    pos_y = random.randint(top, top+height-1)
    PLANTS.add((pos_x, pos_y))

def add_plants():
    random_plant(*JUNGLE)
    random_plant(*BOARD)


class Animal(object):
    def __init__(self, x, y, energy, dir, genes):
        self.x = x
        self.y = y
        self.energy = energy
        self.dir = dir
        self.genes = genes

    def move(self):