How to use simpleai - 10 common examples

To help you get started, we’ve selected a few simpleai examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simpleai-team / simpleai / tests / search / test_utils.py View on Github external
def test_remove(self):
        q = BoundedPriorityQueue(2)
        a = DummyNode(1)
        b = DummyNode(2)
        q.append(a)
        q.append(b)
        q.remove(a)
        self.assertEqual(len(q), 1)
        self.assertIs(q[0], b)
github simpleai-team / simpleai / tests / search / test_utils.py View on Github external
def test_sorted_priority(self):
        q = BoundedPriorityQueue()
        q.append(DummyNode(3))
        q.append(DummyNode(1))
        q.append(DummyNode(2))
        self.assertTrue(sorted_equals_pop(q))
github simpleai-team / simpleai / tests / search / test_utils.py View on Github external
def test_limit_works_on_append(self):
        q = BoundedPriorityQueue(2)
        q.append(DummyNode(1))
        q.append(DummyNode(1))
        q.append(DummyNode(1))
        self.assertEqual(len(q), 2)
github simpleai-team / simpleai / tests / search / test_utils.py View on Github external
def test_limit_works_on_extend(self):
        q = BoundedPriorityQueue(2)
        q.extend([DummyNode(1), DummyNode(1), DummyNode(1)])
        self.assertEqual(len(q), 2)
github simpleai-team / simpleai / tests / search / test_utils.py View on Github external
def test_pop_works_with_order(self):
        q = BoundedPriorityQueue()
        q.append(DummyNode(3))
        q.append(DummyNode(1))
        q.append(DummyNode(2))
        self.assertEqual(q.pop().value, 1)
github simpleai-team / simpleai / tests / search / test_local.py View on Github external
def test_solution_is_node(self):
        node = genetic(self.problem, iterations_limit=1, mutation_chance=0, population_size=1)
        self.assertIsInstance(node, SearchNode)
github simpleai-team / simpleai / tests / search / test_models.py View on Github external
def test_equals(self):
        n1 = SearchNode(problem=self.problem, state='i')
        n2 = SearchNode(problem=self.problem, state='i')
        n3 = SearchNode(problem=self.problem, state='i', action='a')
        n4 = SearchNode(problem=self.problem, state='ia')

        self.assertTrue(n1 == n2)
        self.assertTrue(n1 == n3)
        self.assertFalse(n1 == n4)
github simpleai-team / simpleai / tests / search / test_models.py View on Github external
def test_path(self):
        n1 = SearchNode(problem=self.problem, state='i')
        n2 = SearchNode(action='a', state='ia', parent=n1)
        n3 = SearchNode(action='b', state='iab', parent=n2)

        path = [(None, 'i'), ('a', 'ia'), ('b', 'iab')]

        self.assertEqual(n3.path(), path)
github simpleai-team / simpleai / tests / search / test_models.py View on Github external
def test_path(self):
        n1 = SearchNode(problem=self.problem, state='i')
        n2 = SearchNode(action='a', state='ia', parent=n1)
        n3 = SearchNode(action='b', state='iab', parent=n2)

        path = [(None, 'i'), ('a', 'ia'), ('b', 'iab')]

        self.assertEqual(n3.path(), path)
github simpleai-team / simpleai / tests / search / test_models.py View on Github external
def test_equals(self):
        n1 = SearchNode(problem=self.problem, state='i')
        n2 = SearchNode(problem=self.problem, state='i')
        n3 = SearchNode(problem=self.problem, state='i', action='a')
        n4 = SearchNode(problem=self.problem, state='ia')

        self.assertTrue(n1 == n2)
        self.assertTrue(n1 == n3)
        self.assertFalse(n1 == n4)