mirror of
https://github.com/JackHopkins/factorio-learning-environment.git
synced 2025-09-06 13:23:58 +00:00

Some checks failed
Lint and Format / lint (push) Has been cancelled
* sessions based * try out caching + no sleep * update fixture usage * better reset usge * state less on tech, probably breaking change * better fixtures + decouple resets * use pytest-xdist w 2 servers * using diff grouping for dep * formatting * formatting * caching for image * formatting * formatting * use uv * use uv caching * remove docker caching (its slower) * how about 4 workers? * no redundant resets * parameterize * change names * update all_technologies_researched usage change log: - used uv and cache dependencies - used 2 factorio headless server instances - added pytest-xdist & used 2 pytest workers - parametrized the slowest test -- `test_sleep.py` so as to balance it across workers - clarified resets in `instance.py` so separate instances arent needed for research testing - better fixture usage, with autouse reset - added configure_game callback for per test file setup of inventories & research state. - updated task abc all_technologies_researched usage, its now a param for reset - using 4 workers instead of 2, can probably double it again lol - pytest parameterized a slow test - fixed redundant reset in conftest final speedup: 9m 4s -> 1m, ≈9.07× faster
25 lines
637 B
Python
25 lines
637 B
Python
from fle.env.entities import Position
|
|
from fle.env.game_types import Resource
|
|
|
|
|
|
def test_nearest_resource(game):
|
|
"""
|
|
Test distance to the nearest coal resource.
|
|
:param game:
|
|
:return:
|
|
"""
|
|
coal: Position = game.nearest(Resource.Coal)
|
|
assert coal.y == -0.5
|
|
assert coal.x == 15.5
|
|
|
|
|
|
def test_move_to_nearest(game):
|
|
"""
|
|
Test that when the player moves to the nearest water resource, the nearest water resource remains the same.
|
|
:param game:
|
|
:return:
|
|
"""
|
|
water: Position = game.nearest(Resource.Water)
|
|
game.move_to(water)
|
|
assert abs(water.x - game.nearest(Resource.Water).x) <= 1
|