Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lbforaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time
import gym
import numpy as np
import lbforaging
import lbforaging.gym_env


logger = logging.getLogger(__name__)
Expand Down
25 changes: 0 additions & 25 deletions lbforaging/__init__.py
Original file line number Diff line number Diff line change
@@ -1,25 +0,0 @@
from gym.envs.registration import registry, register, make, spec
from itertools import product

sizes = range(5, 20)
players = range(2, 20)
foods = range(1, 10)
coop = [True, False]
grid_observation = [True, False]

for s, p, f, c, grid_obs in product(sizes, players, foods, coop, grid_observation):
for sight in range(1, s + 1):
register(
id="Foraging{5}{4}-{0}x{0}-{1}p-{2}f{3}-v2".format(s, p, f, "-coop" if c else "", "" if sight == s else f"-{sight}s", "-grid" if grid_obs else ""),
entry_point="lbforaging.foraging:ForagingEnv",
kwargs={
"players": p,
"max_player_level": 3,
"field_size": (s, s),
"max_food": f,
"sight": sight,
"max_episode_steps": 50,
"force_coop": c,
"grid_observation": grid_obs,
},
)
2 changes: 1 addition & 1 deletion lbforaging/agents/hba.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from . import QAgent
from foraging import Env
from gym_env import Env
import random
import numpy as np
from agents import H1, H2, H3, H4
Expand Down
4 changes: 2 additions & 2 deletions lbforaging/agents/heuristic_agent.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import random
import numpy as np
from foraging import Agent
from foraging.environment import Action
from gym_env import Agent
from gym_env.environment import Action


class HeuristicAgent(Agent):
Expand Down
2 changes: 1 addition & 1 deletion lbforaging/agents/monte_carlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import plotly.graph_objs as go
from networkx.drawing.nx_pydot import graphviz_layout

from foraging import Agent, Env
from gym_env import Agent, Env

MCTS_DEPTH = 15

Expand Down
2 changes: 1 addition & 1 deletion lbforaging/agents/nn_agent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import random

from foraging import Agent
from gym_env import Agent


class NNAgent(Agent):
Expand Down
4 changes: 2 additions & 2 deletions lbforaging/agents/q_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import pandas as pd

from agents import H1
from lbforaging import Agent, Env
from lbforaging.environment import Action
from gym_env import Agent, Env
from gym_env.environment import Action

_CACHE = None

Expand Down
2 changes: 1 addition & 1 deletion lbforaging/agents/random_agent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import random

from lbforaging import Agent
from gym_env import Agent


class RandomAgent(Agent):
Expand Down
1 change: 0 additions & 1 deletion lbforaging/foraging/__init__.py

This file was deleted.

26 changes: 26 additions & 0 deletions lbforaging/gym_env/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from lbforaging.gym_env.environment import ForagingEnv
from gym.envs.registration import registry, register, make, spec
from itertools import product

sizes = range(5, 20)
players = range(2, 20)
foods = range(1, 10)
coop = [True, False]
grid_observation = [True, False]

for s, p, f, c, grid_obs in product(sizes, players, foods, coop, grid_observation):
for sight in range(1, s + 1):
register(
id="Foraging{5}{4}-{0}x{0}-{1}p-{2}f{3}-v2".format(s, p, f, "-coop" if c else "", "" if sight == s else f"-{sight}s", "-grid" if grid_obs else ""),
entry_point="lbforaging.foraging:ForagingEnv",
kwargs={
"players": p,
"max_player_level": 3,
"field_size": (s, s),
"max_food": f,
"sight": sight,
"max_episode_steps": 50,
"force_coop": c,
"grid_observation": grid_obs,
},
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions lbforaging/petting_zoo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .environment import env, parallel_env
Loading