[英]Cellular automata on a Hex grid
I'm learning java so I try to code a basic cellular automata on a hexgrid. 我正在学习Java,所以我尝试在hexgrid上编写基本的细胞自动机。
I want to separate display code from simulation code so the simulation just process calculations and the display refresh itself based on it. 我想将显示代码与模拟代码分开,以便模拟仅处理计算,并且显示会根据其自身进行刷新。
I try to figure out for days how to properly do this but I'm still confused. 我试图寻找几天如何正确地做到这一点,但我仍然感到困惑。 I've found many resources on the internet but none gives a simple walkthrough to code this in a object oriented way.
我在互联网上发现了许多资源,但是没有一个提供了简单的演练以面向对象的方式对此进行编码。
For now I don't care about implementing any pattern, a simple continuous movement on the x and y axes would be good enough to check if it works. 现在,我不关心实现任何模式,只需在x和y轴上进行简单的连续移动就足以检查其是否有效。
So what I've done : 所以我做了什么:
If somebody could give me a method or skeleton or any advice on how to achieve this it'd be really appreciated. 如果有人能给我一种方法或框架或关于如何实现这一目标的任何建议,将不胜感激。
pseudocode: 伪代码:
class MyModel {
private int x;
private int y;
public int getX() { return x; }
public int getY() { return y; }
public void go() {
// sart a thread that changes x & y over time
}
public void stop() {
// stop the thread
}
public void reset() {
// reset x & y to their initial values
}
}
The above is your model. 以上是您的模型。 Your view should monitor changes in the model's x and y values and display movement based on that.
您的视图应监视模型的x和y值的变化,并基于此值显示运动。 Your controller should call the model's "go" method when the user taps the "go" button, etc.
当用户点击“执行”按钮等时,控制器应调用模型的“执行”方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.