Пример #1
0
 def test_move_code(self):
     n = Nibble('c', self.world)
     assert_equal(n._position._x, 0)
     assert_equal(n._position._y, 0)
     n.move_code(18)
     assert_equal(n._energy, 27)
     assert_equal(n._position._x, 1)
     assert_equal(n._position._y, 1)
Пример #2
0
 def test_compare_energy(self):
     a = Nibble('a', self.world)
     b = Nibble('b', self.world)
     assert_equal(a.compare_energy(b), 0)
     a.move(1,1)
     assert_equal(a.compare_energy(b), -1)
     b.move(2,2)
     assert_equal(a.compare_energy(b), 1)
Пример #3
0
 def test_move(self):
     n = Nibble('a', self.world)
     n.move(2,2)
     assert_equal(n._energy, 23)
     assert_equal(n._position._x, 2)
     assert_equal(n._position._y, 2)
Пример #4
0
from shared.nibble import Nibble
from shared.world import NibbleWorld, WorldStringRenderer


world = NibbleWorld(10, 10)
wrender = WorldStringRenderer(world)

a = Nibble('a', world)
a.move(-1,1)
b = Nibble('b', world)
b.move_code(18)
c = Nibble('c', world)
c.move(-1,-2)


wrender.render()
print a, b, c

print world.get_view_of_nibble(a)

world.spawn_food(5)
wrender.render()