java 中的元胞自动机

Cellular Automata in java

谁能帮帮我? 我们老师给了我们一个任务,是关于"game of life",他居然给了我们 我们可以使用的方法,但我真的不知道如何开始! 他要求我们使用 3 classes:class cellule,class ruleand class Automata(当然还有主要的)

package jeu_de_vie;


public class Cellule {
    private int state; // should be equal to 0 (if alive) or 1 (if dead)

    public Cellule(int state) { // constructor
        this.state = state;

    }
    public void SetEtat(int state){}

    public void Calculate_future_state(Cellule Cg, Cellule Cd,Regle R){} // to calculate the next state

    public boolean Equals (Cellule A,Cellule B){} // to verify if the cellular are equal
}

看来您必须为这 3 个函数编写代码,它应该是这样工作的:

设置数据:

这个函数将用于设置细胞的状态,所以它很简单,就像构造函数一样工作,获取参数值并将其分配给全局变量状态

public void SetEtat(int state){
    this.state = state;
}

等于:

根据我的说法,这个函数应该 return 一个布尔值,所以 return 类型应该是布尔值而不是 void,因为你会用它来检查并且你需要一个 return 值.为此,state 需要为 public 或者你需要一个 getter 函数。

public boolean Equals(Cellule A, Cellule B){
    return (A.state==B.state);
 }

计算未来状态函数似乎不完整,因为没有 Regle 类型对象的上下文。