diff --git a/demos/animation_demo/README.md b/demos/animation_demo/README.md index d1cedcb..5795f53 100644 --- a/demos/animation_demo/README.md +++ b/demos/animation_demo/README.md @@ -1,11 +1,11 @@ # Animating Network Automata -Network Automata can be animated with the Netomaton `animate` function. +Network Automata can be animated with the Netomaton `animate_activities` function. For example, the evolution of a 2D 60x60 Cellular Automaton can be visualized using: ```python -ntm.animate(activities, shape=(60, 60), interval=150) +ntm.animate_activities(trajectory, shape=(60, 60), interval=150) ``` @@ -13,7 +13,7 @@ The evolution of a 1D Celluar Automaton with 200 cells can be visualized using: ```python # note that the shape specified is a tuple containing only a single value -ntm.animate(activities, shape=(200,)) +ntm.animate_activities(trajectory, shape=(200,)) ``` @@ -22,7 +22,7 @@ timestep, that vector can be reshaped and visualized however desired. For example, the evolution of a 1D Cellular Automaton with 225 cells can be visualized as if it were a 2D Cellular Automation, using: ```python -ntm.animate(activities, shape=(15, 15)) +ntm.animate_activities(trajectory, shape=(15, 15), interval=100) ``` diff --git a/demos/asynchronous_automata/README.md b/demos/asynchronous_automata/README.md index fd9b590..03f501b 100644 --- a/demos/asynchronous_automata/README.md +++ b/demos/asynchronous_automata/README.md @@ -22,19 +22,21 @@ automaton from Wolfram's NKS Notes on Chapter 9, section 10: ```python import netomaton as ntm -adjacency_matrix = ntm.topology.adjacency.cellular_automaton(n=21) +network = ntm.topology.cellular_automaton(n=21) initial_conditions =[0]*10 + [1] + [0]*10 r = ntm.AsynchronousRule(activity_rule=ntm.rules.nks_ca_rule(60), update_order=range(1, 20)) -activities, adjacencies = ntm.evolve(initial_conditions, adjacency_matrix, timesteps=19*20, - activity_rule=r) +trajectory = ntm.evolve(initial_conditions=initial_conditions, network=network, + timesteps=19*20, activity_rule=r) # plot every 19th row, including the first, as a cycle is completed every 19 rows +activities = ntm.get_activities_over_time_as_list(trajectory) ntm.plot_grid(activities[::19]) ``` + The full source code for this example can be found [here](asynchronous_automata_demo.py). diff --git a/demos/ca_density_classification/README.md b/demos/ca_density_classification/README.md index 612fd18..5e33b63 100644 --- a/demos/ca_density_classification/README.md +++ b/demos/ca_density_classification/README.md @@ -21,7 +21,7 @@ import netomaton as ntm import numpy as np # set r to 3, for a neighbourhood size of 7 -adjacency_matrix = ntm.topology.adjacency.cellular_automaton(149, r=3) +network = ntm.topology.cellular_automaton(149, r=3) initial_conditions = np.random.randint(0, 2, 149) @@ -30,11 +30,12 @@ rule_number = 6667021275756174439087127638698866559 print("density of 1s: %s" % (np.count_nonzero(initial_conditions) / 149)) -activities, adjacencies = ntm.evolve(initial_conditions, adjacency_matrix, timesteps=149, - activity_rule=ntm.rules.binary_ca_rule(rule_number)) +trajectory = ntm.evolve(initial_conditions=initial_conditions, network=network, + activity_rule=ntm.rules.binary_ca_rule(rule_number), timesteps=149) -ntm.plot_grid(activities) +ntm.plot_activities(trajectory) ``` + The full source code for this example can be found [here](ca_density_classification_demo.py). diff --git a/demos/continuous_automata/README.md b/demos/continuous_automata/README.md index 6fc2c70..2323792 100644 --- a/demos/continuous_automata/README.md +++ b/demos/continuous_automata/README.md @@ -10,22 +10,23 @@ from Wolfram's NKS book, found on page 157: import math import netomaton as ntm -adjacency_matrix = ntm.topology.adjacency.cellular_automaton(n=200) +network = ntm.topology.cellular_automaton(n=200) initial_conditions = [0.0]*100 + [1.0] + [0.0]*99 -# NKS page 157 + # NKS page 157 def activity_rule(ctx): - activities = ctx.activities + activities = ctx.neighbourhood_activities result = (sum(activities) / len(activities)) * (3 / 2) frac, whole = math.modf(result) return frac -activities, adjacencies = ntm.evolve(initial_conditions, adjacency_matrix, timesteps=150, - activity_rule=activity_rule) +trajectory = ntm.evolve(initial_conditions=initial_conditions, network=network, + activity_rule=activity_rule, timesteps=150) -ntm.plot_grid(activities) +ntm.plot_activities(trajectory) ``` + The full source code for this example can be found [here](continuous_automata_demo.py).