Beispiel #1
0
    def __init__(self, methodName, prop_file="models/party_for_test.props"):
        super().__init__(methodName=methodName)

        self.pa = props.read_props(MODEL_NM, prop_file)

        # Now we create a forest environment for our agents to act within:
        if self.pa["user_type"] == props.WEB:
            self.pa["base_dir"] = os.environ['base_dir']

        # Now we create an environment for our agents to act within:
        self.env = pm.PartyEnv("A cocktail party",
                               self.pa["grid_width"],
                               self.pa["grid_height"],
                               model_nm=self.pa.model_nm,
                               props=self.pa)

        for i in range(self.pa["num_men"]):
            self.env.add_agent(
                pm.Man(name="Man" + str(i),
                       goal="A good party.",
                       tol=0.5,
                       max_detect=self.pa['max_detect']))

        for i in range(self.pa["num_women"]):
            self.env.add_agent(
                pm.Woman(name="Woman" + str(i),
                         goal="A good party.",
                         tol=0.5,
                         max_detect=self.pa['max_detect']))

        self.env.add_agent(
            pm.Woman(name="Woman for tracking",
                     goal="A good party.",
                     tol=0.5,
                     max_detect=self.pa['max_detect']))
Beispiel #2
0
 def test_add_agent(self):
     announce('test_add_agent')
     self.env.add_agent(
         pm.Woman(name="new added Woman",
                  goal="A good party.",
                  tol=0.5,
                  max_detect=self.pa['max_detect']))
     # test if the add worked!
     # test by running
     new_agent = self.env.agent_inspect("new added Woman")
     self.assertIsNotNone(new_agent)
Beispiel #3
0
def run(prop_dict=None):
    pa = props.PropArgs.create_props(MODEL_NM, prop_dict)

    import indra.utils as utils
    import models.party as pm

    # set up some file names:
    (prog_file, log_file, prop_file,
     results_file) = utils.gen_file_names(MODEL_NM)
    # We store basic parameters in a "property" file; this allows us to save
    #  multiple parameter sets, which is important in simulation work.
    #  We can read these in from file or set them here.

    if pa["user_type"] == props.WEB:
        pa["base_dir"] = os.environ['base_dir']

    # Now we create an environment for our agents to act within:
    env = pm.PartyEnv("A cocktail party",
                      pa["grid_width"],
                      pa["grid_height"],
                      model_nm=pa.model_nm,
                      props=pa)

    # Now we loop creating multiple agents with numbered names
    # based on the loop variable:
    for i in range(pa["num_men"]):
        env.add_agent(
            pm.Man(name="Man" + str(i),
                   goal="A good party.",
                   tol=0.5,
                   max_detect=pa['max_detect']))

    for i in range(pa["num_women"]):
        env.add_agent(
            pm.Woman(name="Woman" + str(i),
                     goal="A good party.",
                     tol=0.5,
                     max_detect=pa['max_detect']))

    return utils.run_model(env, prog_file, results_file)