示例#1
0
    def test_iteration_count(self):
        g = GameOfLife(set())

        g.advance(0)
        self.assertEqual(0, g.iteration)

        g.advance(1)
        self.assertEqual(1, g.iteration)

        g.advance(10)
        self.assertEqual(11, g.iteration)

        g.advance(100)
        self.assertEqual(111, g.iteration)
示例#2
0
    def test_iteration_count(self):
        g = GameOfLife(set())

        g.advance(0)
        self.assertEqual(0, g.iteration)

        g.advance(1)
        self.assertEqual(1, g.iteration)

        g.advance(10)
        self.assertEqual(11, g.iteration)

        g.advance(100)
        self.assertEqual(111, g.iteration)
示例#3
0
 def test_alternative_tick(self):
     """Test that we can switch to alternative tick functions"""
     g = GameOfLife(patterns.BEEHIVE, life_function=life_alternative)
     for i in range(10):
         self.assertEqual(patterns.BEEHIVE, g.advance(i))
示例#4
0
 def test_current(self):
     g = GameOfLife(patterns.BLINKER_P1)
     ptns = [patterns.BLINKER_P1, patterns.BLINKER_P2]
     for i in range(100):
         self.assertEqual(ptns[i % len(ptns)], g.current())
         g.advance()
示例#5
0
 def test_beehive(self):
     # a beehive is a still life
     g = GameOfLife(patterns.BEEHIVE)
     for i in range(100):
         self.assertEqual(patterns.BEEHIVE, g.advance(i))
示例#6
0
 def test_block(self):
     # a block is a still life
     g = GameOfLife(patterns.BLOCK)
     for i in range(100):
         self.assertEqual(patterns.BLOCK, g.advance(i))
示例#7
0
 def test_alternative_tick(self):
     """Test that we can switch to alternative tick functions"""
     g = GameOfLife(patterns.BEEHIVE, life_function=life_alternative)
     for i in range(10):
         self.assertEqual(patterns.BEEHIVE, g.advance(i))
示例#8
0
 def test_current(self):
     g = GameOfLife(patterns.BLINKER_P1)
     ptns = [patterns.BLINKER_P1, patterns.BLINKER_P2]
     for i in range(100):
         self.assertEqual(ptns[i % len(ptns)], g.current())
         g.advance()
示例#9
0
 def test_beehive(self):
     # a beehive is a still life
     g = GameOfLife(patterns.BEEHIVE)
     for i in range(100):
         self.assertEqual(patterns.BEEHIVE, g.advance(i))
示例#10
0
 def test_block(self):
     # a block is a still life
     g = GameOfLife(patterns.BLOCK)
     for i in range(100):
         self.assertEqual(patterns.BLOCK, g.advance(i))