示例#1
0
 def process(self, resource_bank: ResourceBank):
     """Process elements"""
     max_mass = 2000
     steam_element = resource_bank.get(Steam)
     if not steam_element.amount or steam_element.temperature < 125:
         return
     if steam_element.amount <= max_mass:
         resource_bank.add(
             Water(amount=steam_element.amount, temperature=95))
         resource_bank.subtract(steam_element)
     else:
         resource_bank.add(Water(amount=max_mass, temperature=95))
         resource_bank.subtract(
             Steam(amount=max_mass, temperature=steam_element.temperature))
示例#2
0
import pytest

from bionic.buildings.steam_turbine import SteamTurbine
from bionic.elements.element import Element
from bionic.resources.resource_bank import ResourceBank
from bionic.elements.steam import Steam
from bionic.elements.water import Water


@pytest.mark.parametrize(
    "initial_state, expected_state",
    [
        (
            [
                Steam(amount=4000, temperature=150),
                Water(amount=1000, temperature=95)
            ],
            [
                Steam(amount=2000, temperature=150),
                Water(amount=3000, temperature=95)
            ],
        ),
        (
            [Steam(amount=4000, temperature=110)],
            [Steam(amount=4000, temperature=110)],
        ),
        (
            [Steam(amount=1000, temperature=150)],
            [Water(amount=1000, temperature=95)],
        ),
    ],
示例#3
0
 def ingredient_list(self) -> List[Resource]:
     """Ingredient list property"""
     return [NoshBean(amount=6), Water(amount=50000)]
示例#4
0
import pytest

from bionic.buildings.steam_turbine import SteamTurbine
from bionic.elements.element import Element
from bionic.resources.resource_bank import ResourceBank
from bionic.elements.steam import Steam
from bionic.elements.water import Water
from bionic.simulation.step import simulation_step
from tests.buildings.test_geyser import TEST_GEYSER, TEST_GEYSER_OUTPUT_ELEMENT


@pytest.mark.parametrize(
    "current_time, initial_state, expected_state",
    [
        (0, [], [TEST_GEYSER_OUTPUT_ELEMENT]),
        (
            0,
            [Steam(amount=2000, temperature=125)],
            [Water(amount=2000, temperature=95), TEST_GEYSER_OUTPUT_ELEMENT],
        ),
    ],
)
def test_simulation_step(current_time: int, initial_state: List[Element],
                         expected_state: List[Element]):
    """Test simulation step"""
    steam_turbine = SteamTurbine()
    element_bank = ResourceBank(*initial_state)
    simulation_step(steam_turbine, TEST_GEYSER, element_bank, current_time)
    assert element_bank.resource_dict == ResourceBank(
        *expected_state).resource_dict
示例#5
0
from bionic.processors.processor import Processor
from bionic.recipes.gristle_berry_recipe import GristleBerryRecipe
from bionic.recipes.spicy_tofu_recipe import SpicyTofuRecipe
from bionic.recipes.stuffed_berry_recipe import StuffedBerryRecipe
from bionic.recipes.tofu_recipe import TofuRecipe
from bionic.resources.resource import Resource
from bionic.resources.resource_bank import ResourceBank


@pytest.mark.parametrize(
    "processor_list, expected_resource_balance, expected_calories",
    [
        (
            [TofuRecipe(amount=4)],
            [NoshBean(amount=-24),
             Water(amount=-200000),
             Tofu(amount=4)],
            14400,
        ),
        (
            [TofuRecipe(amount=2.5)],
            [NoshBean(amount=-15),
             Water(amount=-125000),
             Tofu(amount=2.5)],
            9000,
        ),
        (
            [TofuRecipe(amount=1),
             SpicyTofuRecipe(amount=1)],
            [
                NoshBean(amount=-6),
示例#6
0
 def irrigation(self) -> Resource:
     """Return irrigation per cycle of the plant"""
     return Water(amount=20000)
示例#7
0
from bionic.plants.bristle_blossom import BristleBlossom
from bionic.plants.nosh_sprout import NoshSprout
from bionic.plants.plant import Plant
from bionic.resources.resource import Resource


@pytest.mark.parametrize(
    "plant, expected_production, expected_consumption",
    [
        (NoshSprout(), [NoshBean(amount=1 / 7)], []),
        (
            NoshSprout(domesticated=True),
            [NoshBean(amount=4 / 7)],
            [Ethanol(amount=20000), Dirt(amount=5000)],
        ),
        (
            BristleBlossom(domesticated=True),
            [BristleBerry(amount=1 / 6)],
            [Water(amount=20000)],
        ),
    ],
)
def test_plant(
    plant: Plant,
    expected_production: List[Resource],
    expected_consumption: List[Resource],
):
    """Test plant"""
    assert plant.resource_production_per_unit == expected_production
    assert plant.resource_consumption_per_unit == expected_consumption
示例#8
0
"""Test element bank"""

from typing import List, Type

import pytest

from bionic.elements.element import Element
from bionic.resources.resource_bank import ResourceBank
from bionic.elements.water import Water


@pytest.mark.parametrize(
    "first_argument_list, second_argument_list",
    [
        ([Water(amount=1000, temperature=50)
          ], [Water(amount=1000, temperature=50)]),
        (
            [
                Water(amount=1000, temperature=50),
                Water(amount=2000, temperature=50)
            ],
            [Water(amount=3000, temperature=50)],
        ),
    ],
)
def test_resource_bank_init(first_argument_list: List[Element],
                            second_argument_list: List[Element]):
    """Test resource bank init"""
    assert ResourceBank(*first_argument_list) == ResourceBank(
        *second_argument_list)
示例#9
0
"""Test element"""

from typing import List, Union

import pytest

from bionic.elements.element import Element, calculate_combined_element_temperature
from bionic.elements.hydrogen import Hydrogen
from bionic.elements.igneous_rock import IgneousRock
from bionic.elements.water import Water


@pytest.mark.parametrize(
    "element, expected_heat",
    [
        (Water(amount=1000, temperature=10), 41790),
        (Hydrogen(amount=2000, temperature=20), 96000),
    ],
)
def test_element_heat(element: Element, expected_heat: float):
    """Test element calculations"""
    assert element.heat == expected_heat


@pytest.mark.parametrize(
    "base_element, added_element, expected_element",
    [
        (
            Water(amount=1000, temperature=10),
            Water(amount=1000, temperature=10),
            Water(amount=2000, temperature=10),