# Path: mdpproblog/fluent.py
# class Fluent(object):
#     """
#     Factory class for building fluent terms. A fluent term is a
#     problog.logic.Term with a problog.logic.Constant as last argument
#     representing its timestep.
#     """
# 
#     @classmethod
#     def create_fluent(cls, term, timestep):
#         """"
#         Return a new fluent made from `term` with given `timestep`.
# 
#         :param term: any problog term
#         :type term: problog.logic.Term
#         :param timestep: timestep numeric value
#         :type timestep: int
#         :rtype: problog.logic.Term
#         """
#         args = term.args + (Constant(timestep),)
#         return term.with_args(*args)


import os
import sys
import unittest
import random
import mdpproblog.engine as eng
from problog.logic import Term, Constant, AnnotatedDisjunction
from problog.program import PrologString
from mdpproblog.fluent import Fluent
                    self.assertEqual(value, expected_assignments[str(term)])

    def test_add_assignment(self):
        engine = self.engines['sysadmin']
        fluents = engine.declarations('state_fluent')
        for i in range(2**len(fluents)):
            state = Term('__s%d__' % i)
            value = (-1)**(i % 2) * 10.0*i
            node = engine.add_assignment(state, value)
            fact = engine.get_fact(node)
            self.assertEqual(fact.functor, 'utility')
            self.assertEqual(fact.args, (state, Constant(value)))

    def test_get_assignment(self):
        engine = self.engines['sysadmin']
        assignments = engine.assignments('utility')
        instructions = engine.get_instructions_table()
        facts = instructions['fact']
        for node, fact in facts:
            if fact.functor == 'utility':
                assignment = engine.get_assignment(node)
                self.assertEqual(assignment[0], fact.args[0])
                self.assertEqual(assignment[1], fact.args[1])
            else:
                with self.assertRaises(IndexError):
                    not_an_assignment = engine.get_assignment(node)

    def test_add_fact(self):
        engine = self.engines['sysadmin']
        terms = engine.declarations('state_fluent')

# Path: mdpproblog/fluent.py
# class Fluent(object):
#     """
#     Factory class for building fluent terms. A fluent term is a
#     problog.logic.Term with a problog.logic.Constant as last argument
#     representing its timestep.
#     """
# 
#     @classmethod
#     def create_fluent(cls, term, timestep):
#         """"
#         Return a new fluent made from `term` with given `timestep`.
# 
#         :param term: any problog term
#         :type term: problog.logic.Term
#         :param timestep: timestep numeric value
#         :type timestep: int
#         :rtype: problog.logic.Term
#         """
#         args = term.args + (Constant(timestep),)
#         return term.with_args(*args)


# Path: tests/test_engine.py
import os
import sys
import unittest
import random
import mdpproblog.engine as eng
from problog.logic import Term, Constant, AnnotatedDisjunction
from problog.program import PrologString
from mdpproblog.fluent import Fluent

                    self.assertEqual(value, expected_assignments[str(term)])

    def test_add_assignment(self):
        engine = self.engines['sysadmin']
        fluents = engine.declarations('state_fluent')
        for i in range(2**len(fluents)):
            state = Term('__s%d__' % i)
            value = (-1)**(i % 2) * 10.0*i
            node = engine.add_assignment(state, value)
            fact = engine.get_fact(node)
            self.assertEqual(fact.functor, 'utility')
            self.assertEqual(fact.args, (state, Constant(value)))

    def test_get_assignment(self):
        engine = self.engines['sysadmin']
        assignments = engine.assignments('utility')
        instructions = engine.get_instructions_table()
        facts = instructions['fact']
        for node, fact in facts:
            if fact.functor == 'utility':
                assignment = engine.get_assignment(node)
                self.assertEqual(assignment[0], fact.args[0])
                self.assertEqual(assignment[1], fact.args[1])
            else:
                with self.assertRaises(IndexError):
                    not_an_assignment = engine.get_assignment(node)

    def test_add_fact(self):
        engine = self.engines['sysadmin']
        terms = engine.declarations('state_fluent')

        terms = [Fluent.create_fluent(term, 0) for term in terms]