File size: 2,625 Bytes
a162e39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from dataclasses import dataclass

import param_
import streamlit as st
import numpy as np


@dataclass
class Settings:

    perimeter: int = param_.PERIMETER
    perimeter_z: int = param_.PERIMETER_Z
    groundzone: int = param_.GROUNDZONE

    latlon = param_.LATLON['Paris']['lat'], param_.LATLON['Paris']['lon']

    blues: int = param_.BLUES

    blues_per_circle = np.array(param_.BLUES_PER_CIRCLE)
    blue_circles_rho = param_.BLUE_CIRCLES_RHO
    blue_circles_theta = param_.BLUE_CIRCLES_THETA
    blue_circles_zed = param_.BLUE_CIRCLES_ZED
    blue_distance_factor: float = param_.BLUE_DISTANCE_FACTOR

    is_unkillable: bool = param_.BLUE_IS_UNKILLABLE

    blue_speed_init: int = param_.BLUE_SPEED_INIT

    reds: int = param_.REDS

    red_squads = param_.RED_SQUADS
    red_squads_rho = np.array(param_.RED_SQUADS_RHO)
    red_squads_theta = param_.RED_SQUADS_THETA
    red_squads_zed = param_.RED_SQUADS_ZED
    red_distance_factor: float = param_.RED_DISTANCE_FACTOR

    red_rho_noise = np.array(param_.RED_RHO_NOISE)
    red_theta_noise = np.array(param_.RED_THETA_NOISE)
    red_zed_noise = np.array(param_.RED_ZED_NOISE)

    red_speed_init: int = param_.RED_SPEED_INIT

    policy_folder: str = param_.POLICY_FOLDER


def define_(with_streamlit: bool = True, blues: int = Settings.blues, reds: int = Settings.reds):
    """"
        shows the blue and red swarms in Streamlit
        :return:
        """
    blues = blues
    reds = reds

    if with_streamlit:
        st.title('Blues against Reds by hexamind.ai')
        st.write('controlled by Reinforcement Learning.')
        st.text('<- Set parameters')

        st.sidebar.subheader("Define the battlefield")
        blues = st.sidebar.slider("how many blues on defense?", 1, 20, 6)
        Settings.blues = blues
        blue_dispersion = st.sidebar.slider("set the average blue dispersion", 0.3, 1.0, 0.8)
        Settings.reds = reds
        reds = st.sidebar.slider("how many reds are on the attack?", 1, 20, 6)
        Settings.reds = reds
        red_dispersion = st.sidebar.slider("set the average red dispersion", 0.3, 1.0, 0.7)

        Settings.blue_distance_factor = 3 * blue_dispersion
        Settings.red_distance_factor = 3 * red_dispersion

        location = st.sidebar.radio("Location", ['Paris', 'Puilaurens', 'San Francisco'])

        lat_tg = param_.LATLON[location]['lat']
        lon_tg = param_.LATLON[location]['lon']

        Settings.latlon = lat_tg, lon_tg

        st.sidebar.write(
            'you probably need more drones '
            'No worries, we have plenty at www.hexamind.ai ')

    return blues, reds