예제 #1
0
 def testAdvanceBoard(self):
     board_string = '....\n.XXX\nXXX.'
     actual = generateBoard(board_string)
     expected_string = '..X.\nX..X\nX..X\n.X..'
     expected_0 = generateBoard(board_string)
     expected_1 = generateBoard(expected_string)
     for _ in range(3):
         self.assertEqual(expected_0, actual)
         actual = advanceBoard(actual)
         self.assertEqual(expected_1, actual)
         actual = advanceBoard(actual)
예제 #2
0
 def testAdvanceEmptyBoard(self):
     alive = set()
     self.assertEqual(alive, advanceBoard(alive))
예제 #3
0
 def testAdvanceSingleCellBoard(self):
     board = set([Cell(0, 0)])
     expected = set()
     actual = advanceBoard(board)
     self.assertEqual(expected, actual)
예제 #4
0
import bpy
import os
from createGrass import *
from changeGrow import *
bpy.app.debug = True

if __name__ == '__main__':
    f = generateBoard("......X.\nXX......\n.X...XXX")
    oldf = []
    out = ""
    grass = bpy.context.selected_objects[0]
    grasses = []
    steps = 5
    fps = 5
    secPerStep = 4  #constant
    bpy.context.scene.render.fps = fps
    framesPerStep = secPerStep * fps
    bpy.data.scenes['Scene'].frame_end = (steps - 1) * framesPerStep
    for i in range(steps):
        for el in f:
            changed = False
            for g in grasses:
                if el.x == g[1] and el.y == g[2]:
                    grasses = changeGrow(el.x, el.y, el.grow, grasses)
                    changed = True
            if changed == False:
                grasses = createGrass(el.x, el.y, 0, el.grow, grass, grasses)
        oldf = f
        f = advanceBoard(f)
        bpy.data.scenes['Scene'].frame_current += framesPerStep
        print("out:\n" + out)