Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ __pycache__*
*.xml
*.iml
*.ipynb_checkpoints/
./blockference/.ipynb_checkpoints
.DS_Store
**checkpoint.py
2 changes: 1 addition & 1 deletion blockference/.ipynb_checkpoints/gridference-checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def __init__(self, grid, planning_length: int = 2, env_state: tuple = (0, 0)) ->

def get_A(self):
"""
State Matrix (identity matrix)
State Matrix (identity matrix for the single agent gridworld)
Params:
- n_observations: int: number of possible observations
- n_states: int: number of possible states
Expand Down
31 changes: 29 additions & 2 deletions blockference/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,33 @@ def __init__(
lr_pD=1.0,
use_BMA=True,
policy_sep_prior=False,
save_belief_hist=False
save_belief_hist=False,
):
super().__init__()
super().__init__(A,
B,
C=None,
D=None,
E=None,
pA=None,
pB=None,
pD=None,
num_controls=None,
policy_len=1,
inference_horizon=1,
control_fac_idx=None,
policies=None,
gamma=16.0,
use_utility=True,
use_states_info_gain=True,
use_param_info_gain=False,
action_selection="deterministic",
inference_algo="VANILLA",
inference_params=None,
modalities_to_learn="all",
lr_pA=1.0,
factors_to_learn="all",
lr_pB=1.0,
lr_pD=1.0,
use_BMA=True,
policy_sep_prior=False,
save_belief_hist=False,)
9 changes: 5 additions & 4 deletions blockference/envs/grid_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ def __init__(self, grid_len, num_agents, grid_dim=2) -> None:
self.grid = self.get_grid(grid_len, grid_dim)
self.grid_dim = grid_dim
self.no_actions = 2 * grid_dim + 1
self.agents = self.init_agents(num_agents)
self.n_observations = grid_len ** 2
self.n_states = grid_len ** 2
self.border = np.sqrt(self.n_states) - 1
# self.agents = self.init_agents(num_agents)

def get_grid(self, grid_len, grid_dim):
g = list(itertools.product(range(grid_len), repeat=grid_dim))
for i, p in enumerate(g):
g[i] += (0,)
return g

def move_grid(self, agent, chosen_action):
Expand All @@ -29,7 +30,7 @@ def move_grid(self, agent, chosen_action):
new_state[index] = state[index] - 1 if state[index] > 0 else state[index]
elif chosen_action % 2 == 0:
index = chosen_action / 2
new_state[index] = state[index] + 1 if state[index] < agent.border else state[index]
new_state[index] = state[index] + 1 if state[index] < self.border else state[index]
return new_state

def init_agents(self, no_agents):
Expand Down
Empty file.
136 changes: 0 additions & 136 deletions blockference/tools/.ipynb_checkpoints/policy-checkpoint.py

This file was deleted.

Loading