Esempio n. 1
0
     sg.Button('Create random link',
               tooltip='Create a random link',
               pad=((0, 10), (5, 0))),
     sg.Col([[
         sg.Button('Delete random link',
                   tooltip='Delete a random link',
                   pad=((10, 10), (5, 0)))
     ],
             [
                 sg.Button(
                     'Delete shortest-path link',
                     tooltip='Delete a random link on the shortest path',
                     pad=((0, 0), (5, 0)))
             ]])
 ],
 HOR_SEP(pad=((50, 0), (0, 0))),
 [
     sg.Text(
         'Repulsion coefficient',
         pad=((0, 10), (20, 0)),
         tooltip=
         'Negative means raise to the power and divide (like gravity).\n'
         'Larger magnitude means distince reduces repulsive force more.'),
     sg.Slider((1, 5),
               default_value=1,
               orientation='horizontal',
               key='rep_coef',
               pad=((0, 0), (0, 0)),
               size=(15, 20),
               tooltip='Larger is stronger.')
 ],
Esempio n. 2
0
         tooltip=
         "The radius, in patch-lengths, that defines an agent's flockmates")
 ],
 [
     sg.Text('speed',
             pad=((0, 5), (20, 0)),
             tooltip='The speed of the agents'),
     sg.Slider(key='speed',
               range=(0, 10),
               resolution=0.5,
               default_value=2,
               orientation='horizontal',
               size=(10, 20),
               tooltip='The speed of the agents')
 ],
 HOR_SEP(30, pad=((0, 0), (0, 0))),
 [
     sg.Text(
         'min separation',
         pad=((0, 5),
              (20,
               0)),
         tooltip='The minimum acceptable patch-lengths to nearest neighbor'
     ),
     sg.Slider(
         key='minimum separation',
         resolution=0.5,
         range=(1, 5),
         default_value=2,  # NetLogo=1
         orientation='horizontal',
         size=(10, 20),
Esempio n. 3
0
        gui_set('rows', value=len(self.ca_lines))


# ############################################## Define GUI ############################################## #
import PySimpleGUI as sg
""" 
The following appears at the top-left of the window. 
"""
ca_left_upper = [
    [
        sg.Text('Row justification'),
        sg.Combo(values=['Left', 'Center', 'Right'],
                 key='justification',
                 default_value='Right')
    ],
    HOR_SEP(30),
    [
        sg.Text('Initial row:',
                pad=(None, (20, 0)),
                tooltip="0's and 1's for the initial row. An empty \n" +
                "string will set the initial row to all 0's."),
        sg.Input(default_text="1",
                 key='init_line',
                 size=(20, 1),
                 text_color='white',
                 background_color='steelblue4',
                 justification='center')
    ],
    [
        sg.CB('Random?',
              key='Random?',
Esempio n. 4
0
                  resolution=1,
                  size=(20, 20),
                  default_value=10,
                  orientation='horizontal',
                  pad=((0, 0), (0, 20)),
                  tooltip='The ratio of alive cells to all cells')
    ],
    [
        sg.Button(Life_World.SELECT_FOREGROUND_TEXT),
        Life_World.fg_color_chooser
    ],
    [
        sg.Button(Life_World.SELECT_BACKGROUND_TEXT),
        Life_World.bg_color_chooser
    ],
    HOR_SEP(),
    [sg.Text('Cells can be toggled when\nthe system is stopped.')],
]

if __name__ == "__main__":
    from core.agent import PyLogo

    # Specify patch rows and columns, in case we want a larger/smaller grid
    gui.PATCH_COLS = 51
    gui.PATCH_ROWS = 51
    PyLogo(Life_World,
           '1D Elementary Cellular Automaton',
           gui_elements,
           patch_class=CA_Patch,
           bounce=None,
           fps=10,
Esempio n. 5
0
        Increment self.rows
        """
        ...


# ############################################## Define GUI ############################################## #
import PySimpleGUI as sg

""" 
The following appears at the top-left of the window. 
It puts a row consisting of a Text widgit and a ComboBox above the widgets from on_off.py
"""
ca_left_upper = [[sg.Text('Initial row:'),
                  sg.Combo(values=['Right', 'Center', 'Left', 'Random', 'All off'], key='init', default_value='Right')],
                 [sg.Text('Rows:'), sg.Text('     0', key='rows')],
                 HOR_SEP(30)] + \
                 on_off_left_upper


# bin_0_to_7 is ['000' .. '111']
bin_0_to_7 = [bin_str(n, 3) for n in range(8)]

# The switches are CheckBoxes with keys from bin_0_to_7 (in reverse).
# These are the actual GUI widgets, which we access through their keys.
# The pos_to_switch dictionary maps positions in the rule number as a binary number
# to these widgets. Each widget corresponds to a position in the rule number.
switches = [sg.CB(n+'\n 1', key=n, pad=((60, 0), (0, 0))) for n in reversed(bin_0_to_7)]

""" 
This  material appears above the screen: 
the rule number slider, its binary representation, and the switch settings.
                 key=SELECTION_ALGORITHM,
                 default_value=BEST_KNOWN,
                 tooltip='Selection Algorithm',
                 pad=((0, 5), (20, 0)))
    ],
    [
        sg.Text('Randomness', pad=((0, 5), (20, 0))),
        sg.Slider(key=RANDOMNESS,
                  default_value=16,
                  resolution=1,
                  range=(0, 100),
                  pad=((0, 5), (10, 0)),
                  orientation='horizontal',
                  size=(10, 20))
    ],
    HOR_SEP(pad=((30, 0), (0, 0))),
    [sg.Text('Average = '),
     sg.Text('         0', key=AVERAGE)],
    [sg.Text('Fastest Top Time = '),
     sg.Text('         0', key=FASTEST_TOP)],
    [
        sg.Text('Fastest Middle Time = '),
        sg.Text('         0', key=FASTEST_MIDDLE)
    ],
    [
        sg.Text('Fastest Bottom Time = '),
        sg.Text('         0', key=FASTEST_BOTTOM)
    ]
]

if __name__ == "__main__":
Esempio n. 7
0
         tooltip=
         'The number of patch-lengths that define the current flockmates')
 ],
 [
     sg.Text('speed',
             pad=((0, 5), (20, 0)),
             tooltip='The speed of the agents'),
     sg.Slider(key='speed',
               range=(0, 10),
               resolution=0.5,
               default_value=2,
               orientation='horizontal',
               size=(10, 20),
               tooltip='The speed of the agents')
 ],
 HOR_SEP(30),
 [
     sg.Text(
         'min separation',
         pad=((0, 5),
              (20,
               0)),
         tooltip='The minimum acceptable patch-lengths to nearest neighbor'
     ),
     sg.Slider(
         key='minimum separation',
         resolution=0.5,
         range=(1, 5),
         default_value=1,
         orientation='horizontal',
         size=(10, 20),
Esempio n. 8
0
              tooltip='Node shape')
 ],
 [
     sg.CB('Directed Link?',
           enable_events=True,
           key='directed_link',
           default=False)
 ],
 [
     sg.CB('Clear Before Generating?',
           enable_events=True,
           default=True,
           size=(20, 1),
           key='clear')
 ],
 HOR_SEP(30, pad=(None, None)),
 [
     sg.Text('nb-nodes'),
     sg.Slider(key='nb-nodes',
               range=(0, 20),
               default_value=10,
               orientation='horizontal')
 ],
 [
     sg.Button(button_text='PreAtt', key='PreAtt'),
     sg.Button(button_text='Ring', key='Ring'),
     sg.Button(button_text='Star', key='Star')
 ],
 HOR_SEP(30, pad=(None, None)),
 [
     sg.Text('neighborhood-size'),