dan mackinlay avatar dan mackinlay committed 37efe37

sketch of flocking redux

Comments (0)

Files changed (1)

+#!/usr/bin/env python
+# encoding: utf-8
+"""
+traders.py
+
+Created by dan mackinlay on 2010-10-18.
+Copyright (c) 2010 __MyCompanyName__. All rights reserved.
+"""
+from __future__ import division
+
+import scipy
+import numpy as np
+from numpy import linalg as linalg
+
+class FlockState(object):
+    "A thin wrapper around some simulation state."
+    vels = None
+    locs = None
+    distances = None
+    params = None
+    def __init__(self, vels, locs, distances, params):
+        self.params = params.copy()
+        self.vels = vels
+        self.locs = locs
+        self.distances = distances
+
+def basic_flock_factory(vels=None, locs=None, distances=None, params):
+    # we expect params to contain the following keys:
+    # num_agents, delta, noise, radius, steps and optionally seed. we also allow a re-seed.
+    if vels is None:
+        vels = np.zeros() #random_unit_vectors(params['num_agents'])
+    else:
+        vels = vels
+    if locs is None:
+        locs = scipy.random.uniform(size=(params['num_agents'], params['dimensions']))
+    else:
+        locs = vels
+    # if distances is None:
+    #         distances = scipy.random.uniform(size=(params['num_agents'], params['dimensions']))
+    #     else:
+    #         distances = distances
+    
+    return FlockState(vels = vels, locs=locs, distances=None, params=params)
+
+def flocking_sim():
+    pass
+    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.