Ejemplo n.º 1
0
	def testStep_callsSetOrientation_whenIsCollisionIsTrue(self):
		global setOrientationCalled
		setOrientationCalled = False
		setupFakes(self, ori = self.b.ORIENTATION_UP, collision = True, direction = self.b.DIRECTION_FOREWARD)
		b = theseusBrain.TheseusBrain(self.inputs, self.outputs)
		b.step()
		self.assertEqual(True, setOrientationCalled)
Ejemplo n.º 2
0
	def testStep_setsFinishedStateToTrueWhenNextPosIsFirstCollisionPos(self):
		setupFakes(self, ori = self.b.ORIENTATION_RIGHT, collision = False, direction = self.b.DIRECTION_FOREWARD)
		b = theseusBrain.TheseusBrain(self.inputs, self.outputs)
		b.mObj.expandMap(6, 6, True, True)
		b.firstCollision = c.Coordinate(3, 4)
		b.pos = c.Coordinate(2, 4)
		b.step()
		self.assertEqual(True, b.finished)
Ejemplo n.º 3
0
	def testStep_doesNotCallMoveWhenIsCollisionIsTrue(self):
		global moveCalled
		moveCalled = False
		self.outputs["move"] = fakeMove
		setupFakes(self, ori = self.b.ORIENTATION_UP, collision = True, direction = self.b.DIRECTION_FOREWARD)
		b = theseusBrain.TheseusBrain(self.inputs, self.outputs)
		b.step()
		self.assertEqual(False, moveCalled)
Ejemplo n.º 4
0
	def testStep_translatesFirstCollisionPosWhenPrependingVertically(self):
		global getOrientationValue
		global isCollisionValue
		setupFakes(self, ori = self.b.ORIENTATION_RIGHT, collision = True, direction = self.b.DIRECTION_FOREWARD)
		b = theseusBrain.TheseusBrain(self.inputs, self.outputs)
		b.step()
		getOrientationValue = setOrientationValue
		isCollisionValue = False
		b.step()
		getOrientationValue = setOrientationValue
		isCollisionValue = False
		b.step()
		self.assertEqual(c.Coordinate(1, 3), b._getFirstCollisionPos())
Ejemplo n.º 5
0
	def setUp(self):
		self.cls = theseusBrain.TheseusBrain
		self.inputs = {"isCollision": fakeCallback, "getOrientation": fakeCallback, "getMovementDirection": fakeCallback, "isRightCollision": fakeCallback, "isBackCollision": fakeCallback, "isLeftCollision": fakeCallback}
		self.outputs = {"setOrientation": fakeCallback, "setMovementDirection": fakeCallback, "move": fakeCallback}
		self.b = theseusBrain.TheseusBrain(self.inputs, self.outputs)
Ejemplo n.º 6
0
	def testStep_storesFirstCollision(self):
		setupFakes(self, ori = self.b.ORIENTATION_UP, collision = True, direction = self.b.DIRECTION_FOREWARD)
		b = theseusBrain.TheseusBrain(self.inputs, self.outputs)
		b.step()
		self.assertEqual(c.Coordinate(1, 1), b._getFirstCollisionPos())
Ejemplo n.º 7
0
	def testStep_translatesStartPositionWhenPrependingBrainMapHorizontally(self):
		setupFakes(self, ori = self.b.ORIENTATION_LEFT, collision = True, direction = self.b.DIRECTION_FOREWARD)
		b = theseusBrain.TheseusBrain(self.inputs, self.outputs)
		b.step()
		self.assertEqual(c.Coordinate(2, 1), b._getStartPosition())