GameConfig:
    Type: RTS
    ActionTimer: 10s
    RoundLimit: 100

GameRenderer:
    Resolution:
        Width: 1280
        Height: 800
    Default Assets:
        Selected: ../../assets/Tiles/selected.png
        FogOfWar: ../../assets/Tiles/notVisible.png
    #Optional:
    #Font: ../../assets/arial.ttf
    #OutlineShader: ../../assets/OutLine.frag
    #Only for RTS
    #EntityCollider:
    #    Sprite: ../../assets/Tiles/circleCollider.png

Agents:
    - HumanAgent
    - OSLAAgent
#    - RHEAAgent:
#        Budget: TIME
#    - MCTSAgent:
#        Budget: TIME

Player:
    Actions: [Build, Research]
    CanSpawn: Buildings
    Parameters:
        Gold: [0,0,1000]
        Prod: [0,50,1000]

Tiles:
    Plain:
        Sprite: ../../assets/Tiles/plain.png
        Symbol: .
        IsWalkable: true
        DefaultTile: true
    Water:
        Sprite: ../../assets/Tiles/water.png
        Symbol: W
        IsWalkable: false
    Mountain:
        Sprite: ../../assets/Tiles/rock.png
        Symbol: M
        IsWalkable: false
        BlocksSight: true
    Forest:
        Sprite: ../../assets/Tiles/forest.png
        Symbol: F
        IsWalkable: true

Entities:
    City:
        Sprite: ../../assets/Entities/castle.png
        Symbol: c
        LineOfSightRange: 5
        Actions: [Spawn]
        CanSpawn: [Worker]
        Cost:
            Prod: 100
        Parameters:
            Health: 800
            StorageCapacity: 50
            Range: 6

    Barracks:
        Sprite: ../../assets/Entities/barracks.png
        LineOfSightRange: 3
        RequiredTechnology: Discipline
        Actions: [Spawn]
        CanSpawn: [Warrior, Archer]
        Cost:
            Prod: 200
        Parameters:
            Health: 500
            Range: 6

    MilitaryAcademy:
        Sprite: ../../assets/Entities/military.png
        LineOfSightRange: 3
        RequiredTechnology: Mathematics
        Actions: [Spawn]
        CanSpawn: [Catapult]
        Cost:
            Prod: 400
        Parameters:
            Health: 500

    Foundry:
        Sprite: ../../assets/Entities/foundry.png
        LineOfSightRange: 2
        RequiredTechnology: Metallurgy
        Actions: []
        Cost:
            Prod: 500
        Parameters:
            Health: 300
            
    Workshop:
        Sprite: ../../assets/Entities/storage.png
        LineOfSightRange: 2
        RequiredTechnology: Apprenticeship
        Actions: []
        Cost:
            Prod: 500
        Parameters:
            Health: 300

    Storage:
        Sprite: ../../assets/Entities/castle.png
        LineOfSightRange: 1
        RequiredTechnology: Pottery
        Actions: []
        Cost:
            Prod: 400
        Parameters:
            Cost: 40
            Health: 200
            StorageCapacity: 50

    Worker:
        Sprite: ../../assets/Entities/unit_5.png
        LineOfSightRange: 3
        Actions: [Move, Mine]
        Cost:
            Prod: 50
        Time: 5
        Parameters:
            ResourceCapacity: 10
            Armor: 5
            Speed: 1
            WeaponStrength: 0.05
            Health: 50
            Range: 3
            
    Warrior:
        Sprite: ../../assets/Entities/unit_2.png
        LineOfSightRange: 3
        Actions: [Move, Attack]
        RequiredTechnology: Bronze Working
        Cost:
            Prod: 100
        Parameters:
            Armor: 20
            Speed: 1
            Range: 3
            WeaponStrength: 0.25
            Morale: 10
            Health: 150
            
    Archer:
        Sprite: ../../assets/Entities/unit_3.png
        LineOfSightRange: 3
        Actions: [Move, Attack]
        RequiredTechnology: Archery
        Cost:
            Prod: 150
        Parameters:
            Armor: 15
            Speed: 1
            Range: 6
            WeaponStrength: 0.15
            ReloadTime: 2
            Morale: 10
            Health: 100
            
    Catapult:
        Sprite: ../../assets/Entities/unit_4.png
        LineOfSightRange: 3
        Actions: [Move, Attack]
        RequiredTechnology: Engineering
        Cost:
            Prod: 200
        Parameters:
            Armor: 10
            Speed: 1
            Range: 15
            WeaponStrength: 0.40
            ReloadTime: 3
            Morale: 5
            Health: 60

    GoldVein:
        Sprite: ../../assets/Entities/gold_chest.png
        Symbol: g
        LineOfSightRange: 6
        Actions: []
        Parameters:
            Gold: 200

EntityGroups:
    Units: [Worker, Warrior, Archer, Catapult]
    Buildings: [City, Barracks, MilitaryAcademy, Foundry, Workshop, Storage]
    Attackable: [City, Barracks, MilitaryAcademy, Foundry, Workshop, Storage, Worker, Warrior, Archer, Catapult]

Actions:
    # Attack Actions
    Attack:
        Type: EntityAction
        Cooldown: 1
        Targets:
            Target:
                Type: Entity
                ValidTargets: Attackable
                SamplingMethod:
                    Type: Neighbours
                    Options:
                        Shape: AllPositions
                Conditions:
                    - "DifferentPlayer(Source, Target)"
                    - "InRange(Source, Target, Source.Range)"
        Effects:
            - "Attack(Target.Health, Source.WeaponStrength)"

    # Move Actions
    Move:
        Type: EntityAction
        Cooldown: 1
        Targets:
            Target:
                Type: Position
                SamplingMethod: 
                #    Type: Dijkstra
                #    Options:
                #        SearchSize: 2
                #        AllowDiagonals: false
                    Type: Neighbours
                    Options:
                        Shape: AllPositions
                        #Size: 1
                Conditions:
                    - "IsWalkable(Target)"
        Effects:
            - "Move(Source, Target)"

    #Research
    Research:
        Type: PlayerAction
        Cooldown: 0
        Targets:
            Target:
                Type: Technology
                ValidTargets: All
                Conditions:
                    - "CanResearch(Source, Target)"
                    - "CanAfford(Source, Target)"
        TriggerComplete:
            - "HasElapsedTick(Target.Time)"
        OnStart:
            - "PayCost(Source, Target)"
        OnComplete:
            - "Research(Source, Target)"

    
    Mine:
        Type: EntityAction
        Cooldown: 1
        Targets:
            Target:
                Type: Entity
                ValidTargets: GoldVein
                SamplingMethod: 
                    Type: Neighbours
                    Options:
                        Shape: Circle
                        Size: 2
                Conditions:

                    - "ResourceGreaterEqual(Target.Gold, 0.1)"
        Effects:
            - "Transfer(Target.Gold, Source.Player.Gold, 0.1)"


    #Spawn
    Spawn:
        Type: EntityAction
        Cooldown: 0
        Targets:
            EntityTypeTarget:
                Type: EntityType
                ValidTargets: Units
                Conditions:
                    - "CanSpawn(Source, EntityTypeTarget)"
                    - "CanAfford(Source.Player, EntityTypeTarget)"

            TargetPosition:
                Type: Position
                SamplingMethod: 
                    Type: Neighbours
                    Options:
                        Shape: Circle
                        Size: 2
                Conditions:
                    - "IsWalkable(TargetPosition)"

        Effects:
            - "SpawnEntity(Source, EntityTypeTarget, TargetPosition)"
            - "PayCost(Source.Player, EntityTypeTarget)"

    #Build
    Build:
        Type: PlayerAction
        Cooldown: 1
        Targets:
            EntityTypeTarget:
                Type: EntityType
                ValidTargets: Buildings
                Conditions:
                    - "CanAfford(Source, EntityTypeTarget)"
                    - "CanSpawn(Source, EntityTypeTarget)"

            TargetPosition:
                Type: Position
                SamplingMethod:
                    Type: Neighbours
                    Options:
                        Shape: AllPositions
                Conditions:
                    - "IsWalkable(TargetPosition)"

        Effects:
            - "SpawnEntity(Source, EntityTypeTarget, TargetPosition)"
            - "PayCost(Source, EntityTypeTarget)"

TechnologyTrees:
    SingleTree:
        Mining:
            Description: Base technology
            Cost:
                Prod: 100
            Time: 200
        Discipline:
            Description: Enables barracks construction.
            Requirements: [Mining]
            Cost:
                Prod: 150
            Time: 200
        Pottery:
            Description: Allows to construct a Storage.
            Requirements: [Mining]
            Cost:
                Prod: 1000
            Time: 200
        Mathematics:
            Description: Here you can build a military academy
            Requirements: [Mining]
            Cost:
                Prod: 1500
            Time: 200
        Archery:
            Description: Here you can spawn archers.
            Requirements: [Discipline]
            Cost:
                Gold: 2000
            Time: 500
        Bronze Working:
            Description: Here you can spawn warriors.
            Requirements: [Discipline]
            Cost:
                Gold: 200
            Time: 500
        Apprenticeship:
            Description: Here you can build a workshop.
            Requirements: [Pottery]
            Cost:
                Gold: 3000
            Time: 500
        Metallurgy:
            Description: Here you can build a foundry.
            Requirements: [Apprenticeship]
            Cost:
                Gold: 4000
            Time: 800
        Engineering:
            Description: Here you can spawn a catapult.
            Requirements: [Mathematics]
            Cost:
                Gold: 3000
            Time: 500
            

Board:
    GenerationType: Manual
    Layout: |-
        M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M
        M  .  .  .  .  .  .  .  .  .  .  .  .  .  M  .  .  .  .  .  .  .  .  g  .  .  .  .  .  .  .  M
        M  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  g  .  .  .  .  .  M
        M  .  .  .  .  F  F  F  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  M
        M  .  .  .  .  .  F  .  .  W  W  .  .  .  .  .  .  .  .  .  .  .  .  .  .  g  .  .  .  .  .  M
        M  .  .  g  .  .  .  .  .  W  W  .  .  .  .  .  .  c1 .  .  .  .  M  M  .  .  .  .  .  M  M  M
        M  .  .  g  .  .  .  .  .  .  W  W  W  W  .  .  .  .  .  .  .  .  W  W  W  W  W  W  W  W  W  W
        M  .  .  g  .  .  g  g  g  .  W  W  W  W  .  .  .  .  .  .  .  .  W  W  W  W  W  W  W  W  W  W
        M  M  M  g  .  .  .  .  g  .  .  .  W  W  W  W  W  W  W  W  W  W  W  W  W  W  W  W  W  W  W  W
        M  .  .  .  .  .  .  .  .  .  .  .  .  W  W  W  W  W  W  W  W  W  W  W  W  W  W  W  W  W  W  W
        M  .  .  .  .  .  .  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  .  W  W  W  W  W
        M  M  M  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  W  W  W  W  W
        M  .  .  .  g  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  M
        M  .  .  g  .  .  F  F  F  F  .  .  .  .  .  .  .  c0 .  .  .  .  .  .  .  g  .  .  .  .  .  M
        M  M  M  g  .  .  .  F  F  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  g  .  .  .  .  .  M
        M  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  g  .  .  .  .  .  .  .  M
        M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M
                   
ForwardModel:
    LoseConditions: #If true: Player -> cant play
        HasNoCity:
        - "HasNoEntity(Source, City)"

    Trigger:
        - OnTick:
            Type: Entity
            ValidTargets: City
            Conditions:
                - "IsPlayerEntity(Source)"
            Effects:
                - "ModifyResource(Source.Player.Prod, 0.1)"
        - OnTick:
            Type: Entity
            ValidTargets: Workshop
            Conditions:
                - "IsPlayerEntity(Source)"
            Effects:
                - "ModifyResource(Source.Player.Prod, 0.2)"
        - OnTick:
            Type: Entity
            ValidTargets: Foundry
            Conditions:
                - "IsPlayerEntity(Source)"
                - "ResourceGreaterEqual(Source.Player.Gold, 2)"
            Effects:
                - "ModifyResource(Source.Player.Gold, -2)"
                - "ModifyResource(Source.Player.Prod, 0.4)"

#Action categories
GameDescription:
    Type: CombatGame
    Actions:
        Move: [Move]
        Research: [Research]
        Gather: [Mine]
        Spawn: [Spawn, Build]
        Attack: [Attack]
    Entities:
        Base: [City]
        Building: [City, Barracks, MilitaryAcademy, Foundry, Workshop, Storage]
        Spawner: [City, Barracks, MilitaryAcademy]
        Unit: [Worker, Warrior, Archer, Catapult]
        Fighter: [Warrior, Archer, Catapult]
        NoFighter: [Worker]
        Melee: [Warrior]
        Ranged: [Archer, Catapult]

GameRunner:
    AgentInitializationTime:
        Enabled: false
        BudgetTimeMs: 40
        DisqualificationTimeMs: 70
    AgentComputationTime:
        Enabled: false
        BudgetTimeMs: 40
        DisqualificationTimeMs: 70
        MaxNumberWarnings: 5