Skip to content

Commit

Permalink
Remove arguments already handled by **kwargs from environment configu…
Browse files Browse the repository at this point in the history
…rations.

PiperOrigin-RevId: 681502774
Change-Id: I4277ec049c072c8fdfdde3148918c659df0bfd19
  • Loading branch information
vezhnick authored and copybara-github committed Oct 2, 2024
1 parent 9c3cba1 commit 987e2d4
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 188 deletions.
39 changes: 1 addition & 38 deletions examples/modular/environment/haggling_gullible.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,25 @@

"""A Concordia Environment Configuration."""

from collections.abc import Callable, Sequence
import types

from examples.modular.environment import haggling
from concordia.factory.agent import basic_agent
from concordia.language_model import language_model
from concordia.utils import measurements as measurements_lib
import numpy as np


class Simulation(haggling.Simulation):
"""Simulation with pub closures."""

def __init__(
self,
*,
model: language_model.LanguageModel,
embedder: Callable[[str], np.ndarray],
measurements: measurements_lib.Measurements,
agent_module: types.ModuleType = basic_agent,
resident_visitor_modules: Sequence[types.ModuleType] = (),
supporting_agent_module: types.ModuleType | None = None,
time_and_place_module: str | None = None,
**kwargs,
):
"""Initialize the simulation object.
The launch script assumes this API object has a run() method.
Args:
model: the language model to use.
embedder: the sentence transformer to use.
measurements: the measurements object to use.
agent_module: the agent module to use for all main characters.
resident_visitor_modules: optionally, use different modules for majority
and minority parts of the focal population.
supporting_agent_module: agent module to use for all supporting players. A
supporting player is a non-player character with a persistent memory
that plays a specific role in defining the task environment. Their role
is not incidental but rather is critcal to making the task what it is.
Supporting players are not necessarily interchangeable with focal or
background players.
time_and_place_module: optionally, specify a module containing settings
that create a sense of setting in a specific time and place. If not
specified, a random module will be chosen from the default options.
**kwargs: additional arguments to pass to the superclass constructor.
**kwargs: arguments to pass to the base class.
"""

super().__init__(
model=model,
embedder=embedder,
measurements=measurements,
agent_module=agent_module,
resident_visitor_modules=resident_visitor_modules,
supporting_agent_module=supporting_agent_module,
time_and_place_module=time_and_place_module,
num_supporting_player=1,
only_match_with_support=True,
**kwargs,
Expand Down
38 changes: 1 addition & 37 deletions examples/modular/environment/pub_coordination_closures.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,25 @@

"""A Concordia Environment Configuration."""

from collections.abc import Callable, Sequence
import types

from examples.modular.environment import pub_coordination
from concordia.factory.agent import basic_agent
from concordia.language_model import language_model
from concordia.utils import measurements as measurements_lib
import numpy as np


class Simulation(pub_coordination.Simulation):
"""Simulation with pub closures."""

def __init__(
self,
model: language_model.LanguageModel,
embedder: Callable[[str], np.ndarray],
measurements: measurements_lib.Measurements,
agent_module: types.ModuleType = basic_agent,
resident_visitor_modules: Sequence[types.ModuleType] | None = None,
supporting_agent_module: types.ModuleType | None = None,
time_and_place_module: str | None = None,
**kwargs,
):
"""Initialize the simulation object.
The launch script assumes this API object has a run() method.
Args:
model: the language model to use.
embedder: the sentence transformer to use.
measurements: the measurements object to use.
agent_module: the agent module to use for all main characters.
resident_visitor_modules: optionally, use different modules for majority
and minority parts of the focal population.
supporting_agent_module: agent module to use for all supporting players. A
supporting player is a non-player character with a persistent memory
that plays a specific role in defining the task environment. Their role
is not incidental but rather is critcal to making the task what it is.
Supporting players are not necessarily interchangeable with focal or
background players.
time_and_place_module: optionally, specify a module containing settings
that create a sense of setting in a specific time and place. If not
specified, a random module will be chosen from the default options.
**kwargs: additional arguments to pass to the superclass.
**kwargs: arguments to pass to the base class.
"""

super().__init__(
model=model,
embedder=embedder,
measurements=measurements,
agent_module=agent_module,
resident_visitor_modules=resident_visitor_modules,
supporting_agent_module=supporting_agent_module,
time_and_place_module=time_and_place_module,
pub_closed_probability=0.7,
**kwargs,
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,26 @@

"""A Concordia Environment Configuration."""

from collections.abc import Callable, Sequence
import types

from examples.modular.environment import pub_coordination
from concordia.factory.agent import basic_agent
from concordia.language_model import language_model
from concordia.utils import measurements as measurements_lib
import numpy as np


class Simulation(pub_coordination.Simulation):
"""Simulation with pub closures."""

def __init__(
self,
model: language_model.LanguageModel,
embedder: Callable[[str], np.ndarray],
measurements: measurements_lib.Measurements,
agent_module: types.ModuleType = basic_agent,
resident_visitor_modules: Sequence[types.ModuleType] | None = None,
supporting_agent_module: types.ModuleType | None = None,
time_and_place_module: str | None = None,
**kwargs,
):
"""Initialize the simulation object.
The launch script assumes this API object has a run() method.
Args:
model: the language model to use.
embedder: the sentence transformer to use.
measurements: the measurements object to use.
agent_module: the agent module to use for all main characters.
resident_visitor_modules: optionally, use different modules for majority
and minority parts of the focal population.
supporting_agent_module: agent module to use for all supporting players. A
supporting player is a non-player character with a persistent memory
that plays a specific role in defining the task environment. Their role
is not incidental but rather is critcal to making the task what it is.
Supporting players are not necessarily interchangeable with focal or
background players.
time_and_place_module: optionally, specify a module containing settings
that create a sense of setting in a specific time and place. If not
specified, a random module will be chosen from the default options.
**kwargs: additional arguments to pass to the superclass.
**kwargs: arguments to pass to the base class.
"""

super().__init__(
model=model,
embedder=embedder,
measurements=measurements,
agent_module=agent_module,
resident_visitor_modules=resident_visitor_modules,
supporting_agent_module=supporting_agent_module,
time_and_place_module=time_and_place_module,
pub_closed_probability=0.7,
use_relational_matrix=True,
**kwargs,
Expand Down
43 changes: 2 additions & 41 deletions examples/modular/environment/pub_coordination_friendships.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,22 @@

"""A Concordia Environment Configuration."""

from collections.abc import Callable, Sequence
import types

from examples.modular.environment import pub_coordination
from concordia.factory.agent import basic_agent
from concordia.language_model import language_model
from concordia.utils import measurements as measurements_lib
import numpy as np


class Simulation(pub_coordination.Simulation):
"""Simulation with pub closures."""

def __init__(
self,
model: language_model.LanguageModel,
embedder: Callable[[str], np.ndarray],
measurements: measurements_lib.Measurements,
agent_module: types.ModuleType = basic_agent,
resident_visitor_modules: Sequence[types.ModuleType] | None = None,
supporting_agent_module: types.ModuleType | None = None,
time_and_place_module: str | None = None,
**kwargs,
):
def __init__(self, **kwargs):
"""Initialize the simulation object.
The launch script assumes this API object has a run() method.
Args:
model: the language model to use.
embedder: the sentence transformer to use.
measurements: the measurements object to use.
agent_module: the agent module to use for all main characters.
resident_visitor_modules: optionally, use different modules for majority
and minority parts of the focal population.
supporting_agent_module: agent module to use for all supporting players. A
supporting player is a non-player character with a persistent memory
that plays a specific role in defining the task environment. Their role
is not incidental but rather is critcal to making the task what it is.
Supporting players are not necessarily interchangeable with focal or
background players.
time_and_place_module: optionally, specify a module containing settings
that create a sense of setting in a specific time and place. If not
specified, a random module will be chosen from the default options.
**kwargs: additional arguments to pass to the superclass.
**kwargs: arguments to pass to the base class.
"""

super().__init__(
model=model,
embedder=embedder,
measurements=measurements,
agent_module=agent_module,
resident_visitor_modules=resident_visitor_modules,
supporting_agent_module=supporting_agent_module,
time_and_place_module=time_and_place_module,
use_relational_matrix=True,
**kwargs,
)
37 changes: 1 addition & 36 deletions examples/modular/environment/pub_coordination_mini.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,26 @@

"""A Concordia Environment Configuration."""

from collections.abc import Callable, Sequence
import types

from examples.modular.environment import pub_coordination
from concordia.factory.agent import basic_agent
from concordia.language_model import language_model
from concordia.utils import measurements as measurements_lib
import numpy as np


class Simulation(pub_coordination.Simulation):
"""Simulation with pub closures."""

def __init__(
self,
model: language_model.LanguageModel,
embedder: Callable[[str], np.ndarray],
measurements: measurements_lib.Measurements,
agent_module: types.ModuleType = basic_agent,
resident_visitor_modules: Sequence[types.ModuleType] | None = None,
supporting_agent_module: types.ModuleType | None = None,
time_and_place_module: str | None = None,
**kwargs,
):
"""Initialize the simulation object.
The launch script assumes this API object has a run() method.
Args:
model: the language model to use.
embedder: the sentence transformer to use.
measurements: the measurements object to use.
agent_module: the agent module to use for all main characters.
resident_visitor_modules: optionally, use different modules for majority
and minority parts of the focal population.
supporting_agent_module: agent module to use for all supporting players. A
supporting player is a non-player character with a persistent memory
that plays a specific role in defining the task environment. Their role
is not incidental but rather is critcal to making the task what it is.
Supporting players are not necessarily interchangeable with focal or
background players.
time_and_place_module: optionally, specify a module containing settings
that create a sense of setting in a specific time and place. If not
specified, a random module will be chosen from the default options.
**kwargs: additional arguments to pass to the superclass.
**kwargs: arguments to pass to the base class.
"""

super().__init__(
model=model,
embedder=embedder,
measurements=measurements,
agent_module=agent_module,
resident_visitor_modules=resident_visitor_modules,
supporting_agent_module=supporting_agent_module,
time_and_place_module=time_and_place_module,
pub_closed_probability=0.0,
num_games=1,
num_main_players=2,
Expand Down

0 comments on commit 987e2d4

Please sign in to comment.