mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
An HTN (https://en.wikipedia.org/wiki/Hierarchical_task_network) is similar to a decision tree, but it is able to reset to an earlier stage if a subtask fails and tasks are able to account for the changes in world state caused by earlier tasks. Currently this just uses exactly the same strategy as before so we can prove the system, but it should make it simpler to improve on task planning.
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
from collections import Iterator
|
|
from dataclasses import dataclass
|
|
|
|
from game.commander.tasks.compound.aewcsupport import PlanAewcSupport
|
|
from game.commander.tasks.compound.attackairinfrastructure import (
|
|
AttackAirInfrastructure,
|
|
)
|
|
from game.commander.tasks.compound.attackbuildings import AttackBuildings
|
|
from game.commander.tasks.compound.attackgarrisons import AttackGarrisons
|
|
from game.commander.tasks.compound.degradeiads import DegradeIads
|
|
from game.commander.tasks.compound.destroyships import DestroyShips
|
|
from game.commander.tasks.compound.frontlinedefense import FrontLineDefense
|
|
from game.commander.tasks.compound.interdictreinforcements import (
|
|
InterdictReinforcements,
|
|
)
|
|
from game.commander.tasks.compound.protectairspace import ProtectAirSpace
|
|
from game.commander.tasks.compound.refuelingsupport import PlanRefuelingSupport
|
|
from game.commander.theaterstate import TheaterState
|
|
from game.htn import CompoundTask, Method
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class PlanNextAction(CompoundTask[TheaterState]):
|
|
aircraft_cold_start: bool
|
|
|
|
def each_valid_method(self, state: TheaterState) -> Iterator[Method[TheaterState]]:
|
|
yield [PlanAewcSupport()]
|
|
yield [PlanRefuelingSupport()]
|
|
yield [ProtectAirSpace()]
|
|
yield [FrontLineDefense()]
|
|
yield [DegradeIads()]
|
|
yield [InterdictReinforcements()]
|
|
yield [DestroyShips()]
|
|
yield [AttackGarrisons()]
|
|
yield [AttackAirInfrastructure(self.aircraft_cold_start)]
|
|
yield [AttackBuildings()]
|