mirror of
https://github.com/JackHopkins/factorio-learning-environment.git
synced 2025-09-06 13:23:58 +00:00
removed unused tool
This commit is contained in:
44
fle/env/tools/admin/production_stats/client.py
vendored
44
fle/env/tools/admin/production_stats/client.py
vendored
@@ -1,44 +0,0 @@
|
||||
from typing import Dict
|
||||
|
||||
from fle.env.tools import Tool
|
||||
|
||||
|
||||
class ProductionStats(Tool):
|
||||
def __init__(self, lua_script_manager, game_state):
|
||||
self.state = {"input": {}, "output": {}}
|
||||
super().__init__(lua_script_manager, game_state)
|
||||
|
||||
def __call__(self) -> Dict[str, Dict[str, int]]:
|
||||
"""
|
||||
Gets the difference in production statistics since the last measurement.
|
||||
Returns a dictionary of item names to net production/consumption counts.
|
||||
"""
|
||||
|
||||
result, _ = self.execute(self.player_index)
|
||||
|
||||
if isinstance(result, str):
|
||||
raise Exception(result)
|
||||
|
||||
result = self.clean_response(result)
|
||||
|
||||
# Calculate the difference in production statistics
|
||||
input_diff = {}
|
||||
for item, count in result["input"].items():
|
||||
input_diff[item] = count - self.state["input"].get(item, 0)
|
||||
|
||||
output_diff = {}
|
||||
for item, count in result["output"].items():
|
||||
output_diff[item] = count - self.state["output"].get(item, 0)
|
||||
|
||||
self.state = result
|
||||
|
||||
return {"input": input_diff, "output": output_diff}
|
||||
|
||||
def reset_production_stats(self):
|
||||
"""Resets the production statistics to current values"""
|
||||
lua_command = """
|
||||
local scores = production_score.get_production_scores()
|
||||
global.initial_score = scores
|
||||
return true
|
||||
"""
|
||||
self.execute(lua_command)
|
48
fle/env/tools/admin/production_stats/server.lua
vendored
48
fle/env/tools/admin/production_stats/server.lua
vendored
@@ -1,48 +0,0 @@
|
||||
global.actions.production_stats = function(player)
|
||||
local production_diff = {}
|
||||
local consumption_diff = {}
|
||||
local harvested_items = global.harvested_items
|
||||
local crafted_items = global.crafted_items
|
||||
-- Get total production counts for force
|
||||
local force = game.forces.player
|
||||
|
||||
local item_input_counts = force.item_production_statistics.input_counts
|
||||
local item_production_counts = force.item_production_statistics.output_counts
|
||||
local fluid_input_counts = force.fluid_production_statistics.input_counts
|
||||
local fluid_production_counts = force.fluid_production_statistics.output_counts
|
||||
|
||||
for name, count in pairs(item_input_counts) do
|
||||
consumption_diff[name] = count
|
||||
end
|
||||
|
||||
for name, count in pairs(item_production_counts) do
|
||||
production_diff[name] = count
|
||||
end
|
||||
|
||||
for name, count in pairs(fluid_input_counts) do
|
||||
consumption_diff[name] = count
|
||||
end
|
||||
|
||||
for name, count in pairs(fluid_production_counts) do
|
||||
production_diff[name] = count
|
||||
end
|
||||
return {
|
||||
output = consumption_diff,
|
||||
input = production_diff,
|
||||
harvested = harvested_items,
|
||||
crafted = crafted_items
|
||||
}
|
||||
end
|
||||
|
||||
global.actions.reset_production_stats = function(player)
|
||||
local force = game.forces.player
|
||||
-- Reset item statistics
|
||||
force.item_production_statistics.clear()
|
||||
|
||||
-- Reset fluid statistics
|
||||
force.fluid_production_statistics.clear()
|
||||
|
||||
global.harvested_items = {}
|
||||
global.crafted_items = {}
|
||||
end
|
||||
|
Reference in New Issue
Block a user