https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/p5.js

http://www.box2d.org

http://www.jbox2d.org

http://github.com/shiffman/PBox2D

 

第0章 引言 (已看)

第1章 向量 (已看)

第2章 力 (已看)

第3章 震荡  (已看)

第4章 粒子系统 (已看)

第5章 物理函数库 (已看)

第6章 自治智能体 (已看)

第7章 细胞自动机 (已看)

第8章 分形 (已看)

第9章 代码的进化 (已看)

第10章 神经网络 (已看)

参考文献

 

第0章 引言

  0.1 随机游走

  0.2 随机游走类

代码本色 用编程模拟自然系统 (Daniel Shiffman 著)

Walker w;

void setup() {
  size(640,360);
  w = new Walker();
  background(255);
}

void draw() {
  w.step();
  w.display();
}

class Walker {
  int x;
  int y;
  
  Walker() {
    x = width / 2;
    y = height / 2;
  }
  
  void display() {
    stroke(0);
    point(x,y);
  }
  
  void step() {
    int choice = int(random(4));
    
    if(choice == 0) {
      x++; 
    } else if(choice == 1) {
      x--; 
    } else if(choice == 2) {
      y++; 
    } else {
      y--; 
    }
  }
}
View Code

相关文章:

  • 2021-09-25
  • 2021-06-10
  • 2021-12-10
  • 2022-12-23
  • 2022-01-11
  • 2021-04-14
  • 2021-08-21
  • 2021-08-22
猜你喜欢
  • 2021-05-13
  • 2021-12-31
  • 2021-08-17
  • 2021-06-25
  • 2022-12-23
  • 2021-06-19
  • 2021-04-07
相关资源
相似解决方案