stochastic simulation, predator/prey

Dependencies:   mbed

Revision:
0:fc1335b7b54f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 23 18:56:56 2019 +0000
@@ -0,0 +1,37 @@
+// predator play stochastic simulation
+// https://github.com/Kristjan93/Ants-and-bugs
+
+#include "mbed.h"
+
+#include "World.h"
+Serial pc(USBTX, USBRX);
+Timer tmr;
+#define micros tmr.read_us
+
+main()
+{
+    tmr.start();
+
+
+  printf("hit a key to step\n");
+
+  World myWorld(0);   // seed  analogRead(0)
+
+  myWorld.print();
+ // myWorld.display();  // TFT display
+  while (1) {
+#if 1
+    if (pc.readable() ) {
+      pc.getc();
+      myWorld.simulateOneStep();
+      myWorld.print();
+   //   myWorld.display();  // TFT display
+    }
+#else
+    myWorld.simulateOneStep();
+    myWorld.plot();  // for serialplotter
+  //  myWorld.display();  // TFT display
+    wait(.3);
+#endif
+  }
+}