# 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
            p = random.choice([random.random(), None])
            node = engine.add_fact(term, p)
            fact = engine.get_fact(node)
            self.assertEqual(fact.functor, term.functor)
            self.assertEqual(fact.args, term.args)
            if p is None:
                self.assertEqual(str(fact.probability), 'None')
            else:
                self.assertAlmostEqual(float(str(fact.probability)), p)

    def test_get_fact(self):
        engine = self.engines['sysadmin']
        instructions = engine.get_instructions_table()
        facts = instructions['fact']
        for node,fact in facts:
            self.assertTrue(engine.get_fact(node), fact)
        for instruction_type in instructions:
            if instruction_type != 'fact':
                for node,instruction in instructions[instruction_type]:
                    with self.assertRaises(IndexError):
                        not_a_fact = engine.get_fact(node)

    def test_add_rule(self):
        engine = self.engines['sysadmin']

        running = Term('running')
        c1 = Constant('c1')
        c2 = Constant('c2')
        c3 = Constant('c3')
        r1 = Fluent.create_fluent(running(c1), 1)

# 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

            p = random.choice([random.random(), None])
            node = engine.add_fact(term, p)
            fact = engine.get_fact(node)
            self.assertEqual(fact.functor, term.functor)
            self.assertEqual(fact.args, term.args)
            if p is None:
                self.assertEqual(str(fact.probability), 'None')
            else:
                self.assertAlmostEqual(float(str(fact.probability)), p)

    def test_get_fact(self):
        engine = self.engines['sysadmin']
        instructions = engine.get_instructions_table()
        facts = instructions['fact']
        for node,fact in facts:
            self.assertTrue(engine.get_fact(node), fact)
        for instruction_type in instructions:
            if instruction_type != 'fact':
                for node,instruction in instructions[instruction_type]:
                    with self.assertRaises(IndexError):
                        not_a_fact = engine.get_fact(node)

    def test_add_rule(self):
        engine = self.engines['sysadmin']

        running = Term('running')
        c1 = Constant('c1')
        c2 = Constant('c2')
        c3 = Constant('c3')
        r1 = Fluent.create_fluent(running(c1), 1)

        r2 = Fluent.create_fluent(running(c2), 1)