Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
from typing import List, Dict
from typing import Union

from fle.agents.data.blueprints_to_policies.models.blueprint_entity import BlueprintEntity
from fle.env import EntityGroup
from fle.env import FactorioInstance
from fle.env.game_types import prototype_by_name
from data.blueprints_to_policies.models.blueprint_entity import BlueprintEntity
from fle.logger import info, error
#from data.blueprints_to_policies.models.blueprint_entity import BlueprintEntity


class BlueprintAnalyzerWithConnect:
Expand Down Expand Up @@ -351,11 +353,11 @@ def _name_to_prototype_string(self, name: str) -> str:
#if os.path.exists(execution_dir + filename.replace(".json", ".py")):
# continue
with open(execution_dir + filename, "r") as f:
print(filename)
info(filename)
blueprint_json = f.read()
blueprint = json.loads(blueprint_json)
if len(blueprint['entities']) > 200:
print("Skipping large blueprint")
info("Skipping large blueprint")
continue
analyzer = BlueprintAnalyzerWithConnect(blueprint)
code = analyzer.generate_program()
Expand All @@ -374,17 +376,17 @@ def _name_to_prototype_string(self, name: str) -> str:
if "error" in result:
raise Exception(result["error"])
except Exception as e:
print(e)
print("Error in blueprint")
error(str(e))
error("Error in blueprint")
continue

print(code)
info(code)
game_entities = instance.get_entities()
try:
analyzer.verify_placement(game_entities)
except AssertionError as e:
print(e)
print("Error in blueprint")
error(str(e))
error("Error in blueprint")
continue
# Write the code to a python file of the same name
with open(execution_dir + filename.split('.json')[0] + " with connect"+ ".py", "w") as f1:
Expand Down
2 changes: 1 addition & 1 deletion fle/agents/data/blueprints_to_policies/parse_blueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import matplotlib.pyplot as plt
from dataclasses import dataclass, field

from game_types import Prototype
from fle.env import Prototype


@dataclass(frozen=True) # Make the class immutable and hashable
Expand Down
15 changes: 8 additions & 7 deletions fle/agents/data/run_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from fle.commons.db_client import DBClient
from fle.env import FactorioInstance
from fle.logger import info, error, debug, warning

# Load environment variables
load_dotenv()
Expand Down Expand Up @@ -99,20 +100,20 @@ def game_instance():
traces = cur.fetchall()

# Evaluate each code snippet in the trace
print(f"Found {len(traces)} entries in the program trace")
info(f"Found {len(traces)} entries in the program trace")
for i, trace in enumerate(traces):
code = trace[1] # code is the second column
print(f"\nEvaluating trace {i + 1}/{len(traces)}")
print(f"Program ID: {trace[3]}") # id is the fourth column
info(f"Evaluating trace {i + 1}/{len(traces)}")
info(f"Program ID: {trace[3]}") # id is the fourth column

try:
# Evaluate the code
reward, _, result = instance.eval(code, timeout=30)
print(f"Evaluation result:")
print(f"Reward: {reward}")
print(f"Result: {result}")
info(f"Evaluation result:")
info(f"Reward: {reward}")
info(f"Result: {result}")
except Exception as e:
print(f"Error evaluating code: {e}")
error(f"Error evaluating code: {e}")
continue


Expand Down
18 changes: 0 additions & 18 deletions fle/cluster/docker/build.sh

This file was deleted.

32 changes: 0 additions & 32 deletions fle/cluster/docker/build_alternative_installation_location.sh

This file was deleted.

98 changes: 0 additions & 98 deletions fle/cluster/docker/config/docker-entrypoint.sh

This file was deleted.

28 changes: 0 additions & 28 deletions fle/cluster/docker/config/docker-update-mods.sh

This file was deleted.

8 changes: 0 additions & 8 deletions fle/cluster/docker/config/mod-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
{
"name": "base",
"enabled": true
},
{
"name": "stdlib",
"enabled": true
},
{
"name": "headless-player",
"enabled": true
}
]
}
96 changes: 0 additions & 96 deletions fle/cluster/docker/config/update-mods.sh

This file was deleted.

Loading