コード例 #1
0
from eaters import tiles
from eaters.tiles.tile import Tile

class Space(Tile):
    char = '.'
tiles.register(Space)

class Wall(tiles.Tile):
    char = '#'
tiles.register(Wall)

class Plant(tiles.Tile):
    char = '%'
tiles.register(Plant)
コード例 #2
0
            self.genome.simscore += 1
            colors[(self.y, self.x)] = 2

    def do_east(self, neighbors, world, colors):
        if neighbors[1] not in [Wall, Peater]:
            world[(self.y, self.x)] = Space()
            self.x += 1
            world[(self.y, self.x)] = self
        if neighbors[1] == Plant():
            self.genome.simscore += 1
            colors[(self.y, self.x)] = 2

    def do_south(self, neighbors, world, colors):
        if neighbors[2] not in [Wall, Peater]:
            world[(self.y, self.x)] = Space()
            self.y += 1
            world[(self.y, self.x)] = self
        if neighbors[2] == Plant():
            self.genome.simscore += 1
            colors[(self.y, self.x)] = 2

    def do_west(self, neighbors, world, colors):
        if neighbors[3] not in [Wall, Peater]:
            world[(self.y, self.x)] = Space()
            self.x -= 1
            world[(self.y, self.x)] = self
        if neighbors[3] == Plant():
            self.genome.simscore += 1
            colors[(self.y, self.x)] = 2
tiles.register(Peater)