mirror of
https://gitee.com/drinkjava2/frog.git
synced 2024-11-25 16:04:06 +08:00
Done earthquake test, update readme
This commit is contained in:
parent
2e50deda3d
commit
d65944f44c
2
.gitignore
vendored
2
.gitignore
vendored
@ -17,8 +17,8 @@ examples/**/build/
|
||||
*.log
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
*.ser
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
@ -103,8 +103,14 @@ Frog: 这是人工生命的主体,目前起名叫青蛙(Frog),其实叫什
|
||||
|
||||
2020-09-13 这次不是更新了,因为我最近太忙,所以先临时发布一个小开发任务,见下图,如果有兴趣的同学可以尝试一下看能不能做出来:
|
||||
![task1](task1.png)
|
||||
说明:详见图片,通过模拟一个虚拟的环境来淘汰青蛙,只有当青蛙进化出能够在震心的位置发出叫声,其它的青蛙能听到这个叫声跳在空中躲避震波时,青蛙的生存机率才会变高,但是跳起来也会消耗能量,只有听到报警后跳起来才正好。如果这个实验能做成功,就可以证明生物即使脑神经元随机排列,也会进化出发音和听力器官,这是挺有意义的,因为这是一个群体进化,对于单个青蛙来说,进化出能叫,或是能听到声音对它自己是意义不大的,但是对于群体的生存有利,这个进化相当于是语言和听力的萌芽。整个虚拟环境的设定,就是要逼迫这种群体进化现象产生出来,个人认为是有大概率能做出来的。这里说进化出器官,不是变出来,而是模拟生物体偶然变异出了听力细胞和发音器官,这个是没问题的,问题的重点在于听力细胞和发音器官是如何在进化过程演变成脑神经网络的一个组成部分的。
|
||||
说明:详见图片,通过模拟一个虚拟的环境来淘汰青蛙,只有当青蛙进化出能够在震心的位置发出叫声,其它的青蛙能听到这个叫声跳在空中躲避震波时,青蛙的生存机率才会变高,但是跳起来也会消耗能量,只有听到报警后跳起来才正好。如果这个实验能做成功,就可以证明生物即使脑神经元随机排列,也会进化出发音和听力器官,这是挺有意义的,因为这是一个群体进化,对于单个青蛙来说,进化出能叫,或是能听到声音对它自己是意义不大的,但是对于群体的生存有利,这个进化相当于是语言和听力的萌芽。整个虚拟环境的设定,就是要逼迫这种群体进化现象产生出来,个人认为是有大概率能做出来的。这里说进化出器官,不是变出来,而是模拟生物体偶然变异出了听力细胞和发音器官,这个是没问题的,问题的重点在于听力细胞和发音器官是如何在进化过程演变成脑神经网络的一个组成部分的。
|
||||
|
||||
2021-01-23 语言的诞生。好不容易,告别漫长的2020,去年出的题目我自己解出来了,下面是答案,运行根目录或core目录下的run.bat,可能看到类似下面的运行画面:
|
||||
![result9](result9_earthquake.gif)
|
||||
详细解说:这个题目的模拟环境被简化成左右两个区,设定地震发生时(用红框表示)会扣除所有青蛙的能量,但是只有位于左侧的青蛙可以看到地震发生和停止,右区的青蛙不能看到地震发生和停止,但是青蛙有发音器官和听音器官,如果左侧的青蛙发出叫声是可以被右侧的青蛙听到的。看到地震发生、看到地震停止、发出叫声、听到叫声、跳起、落地这6个器官分别对应6种器官并都偶然进化出来(这个无需证明),这个实验的目的是要验证青蛙会不会在环境逼迫下,在这6种器官对应的脑细胞间形成神经关联。结果可以看到,左侧的青蛙看到地震后,跳在空中(用黄色表示),并发出叫声,然后右侧的青蛙听到叫声后也跳在空中。左侧的青蛙通过叫声信号传递了信息给右侧的青蛙,从而让右侧的青蛙避开了它看不见的地震伤害。这是一个成功的群体进化的演示,它证明了即使是随机生成神经细胞连线,也可以进化出生物的发音-听力功能,也就是说进化出初步的语言功能。
|
||||
另外说一下,这个运行结果可能要运行多次才有可能遇到,这个可以用群友"背叛的细胞膜"提到的自然界的“顶端优势”来解释,生物进化有可能陷入局部最优解而绕不出来,对自然界来说就是没找到最优解的生物种群可能会被汰淘,存在即合理。
|
||||
|
||||
这个项目下面的目标将转回到体全息存贮的模式识别,真要剁手,不能再在2D模型上打转了,要利用体全息存贮存算一体化这个模式识别功能来帮助生命形成条件反射,比如说从图像上来区分有毒蘑菇和无毒蘑菇。(青蛙吃蘑菇? 这个有点说不过去,但没关系,在这个虚拟世界里,它不吃也得吃!)
|
||||
|
||||
## 运行方式 | Run
|
||||
运行core或history各个子目录下的run.bat批处理文件即可启动运行,history下有多个子目录,按时间顺序按列,存放着这个项目演化过程中的主要历史版本供演示。
|
||||
|
@ -49,8 +49,6 @@ public abstract class Animal {// 这个程序大量用到public变量而不是ge
|
||||
public int no; // 青蛙在Env.animals中的序号,从1开始, 会在运行期写到当前brick的最低位,可利用Env.animals.get(no-1)快速定位青蛙
|
||||
public int high=0; //青蛙跳在空中的高度, 用于听力测试
|
||||
public int crockRadius = 40; // 呱呱叫或哇哇叫的传播半径
|
||||
public boolean guagua = false; // 呱呱叫,不是那个呱呱叫的意思,就是呱呱叫的意思
|
||||
public boolean wawa = false; // 哇哇叫,哇哇叫和呱呱叫是两种不同的声音
|
||||
|
||||
public Image animalImage;
|
||||
|
||||
|
@ -46,14 +46,14 @@ public class Application {
|
||||
private static void checkIfShowBrainPicture(JButton button) {
|
||||
if (Env.SHOW_FIRST_ANIMAL_BRAIN) {
|
||||
button.setText("Hide brain");
|
||||
int y = Env.ENV_HEIGHT + 120;
|
||||
int y = Env.ENV_HEIGHT + 160;
|
||||
if (Env.FROG_BRAIN_DISP_WIDTH + 41 > y)
|
||||
y = Env.FROG_BRAIN_DISP_WIDTH + 41;
|
||||
mainFrame.setSize(Env.ENV_WIDTH + Env.FROG_BRAIN_DISP_WIDTH + 25, y);
|
||||
brainPic.requestFocus();
|
||||
} else {
|
||||
button.setText("Show brain");
|
||||
mainFrame.setSize(Env.ENV_WIDTH + 20, Env.ENV_HEIGHT + 120);
|
||||
mainFrame.setSize(Env.ENV_WIDTH + 20, Env.ENV_HEIGHT + 160);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ public class Application {
|
||||
mainFrame.add(env); // 添加虚拟环境Panel
|
||||
mainFrame.add(brainPic); // 添加脑图Panel
|
||||
|
||||
JButton button = new JButton("Show brain");// 按钮,显示或隐藏脑图
|
||||
JButton showBrainbutton = new JButton("Show brain");// 按钮,显示或隐藏脑图
|
||||
int buttonWidth = 100;
|
||||
int buttonHeight = 22;
|
||||
int buttonXpos = Env.ENV_WIDTH / 2 - buttonWidth / 2;
|
||||
@ -74,11 +74,11 @@ public class Application {
|
||||
radioFrog.setBounds(buttonXpos + buttonWidth + 10, Env.ENV_HEIGHT + 8, 50, buttonHeight);
|
||||
radioFrog.addActionListener(e -> {
|
||||
selectFrog = radioFrog.isSelected();
|
||||
checkIfShowBrainPicture(button);
|
||||
checkIfShowBrainPicture(showBrainbutton);
|
||||
});
|
||||
JRadioButton radioSnake = new JRadioButton("Snake");
|
||||
|
||||
button.setBounds(buttonXpos, Env.ENV_HEIGHT + 8, buttonWidth, buttonHeight);
|
||||
showBrainbutton.setBounds(buttonXpos, Env.ENV_HEIGHT + 8, buttonWidth, buttonHeight);
|
||||
ActionListener al = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {//显示或隐藏脑图
|
||||
@ -90,17 +90,18 @@ public class Application {
|
||||
radioFrog.setVisible(false);
|
||||
radioSnake.setVisible(false);
|
||||
}
|
||||
checkIfShowBrainPicture(button);
|
||||
checkIfShowBrainPicture(showBrainbutton);
|
||||
}
|
||||
};
|
||||
checkIfShowBrainPicture(button);
|
||||
button.addActionListener(al);
|
||||
mainFrame.add(button);
|
||||
checkIfShowBrainPicture(showBrainbutton);
|
||||
showBrainbutton.addActionListener(al);
|
||||
mainFrame.add(showBrainbutton);
|
||||
|
||||
//小蛇或青蛙脑图显示切换开关
|
||||
radioSnake.setBounds(buttonXpos + buttonWidth + 60, Env.ENV_HEIGHT + 8, 80, buttonHeight);
|
||||
radioSnake.addActionListener(e -> {
|
||||
selectFrog = radioFrog.isSelected();
|
||||
checkIfShowBrainPicture(button);
|
||||
checkIfShowBrainPicture(showBrainbutton);
|
||||
});
|
||||
ButtonGroup btnGroup = new ButtonGroup();
|
||||
btnGroup.add(radioFrog);
|
||||
@ -157,7 +158,7 @@ public class Application {
|
||||
radioSnake.setVisible(false);
|
||||
}
|
||||
});
|
||||
snakeModeCkBox.setSelected(true);
|
||||
snakeModeCkBox.setSelected(Env.SNAKE_MODE);
|
||||
mainFrame.add(snakeModeCkBox);
|
||||
|
||||
mainFrame.setVisible(true);
|
||||
|
@ -9,7 +9,6 @@ import java.util.List;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.gitee.drinkjava2.frog.brain.BrainPicture;
|
||||
import com.gitee.drinkjava2.frog.egg.Egg;
|
||||
import com.gitee.drinkjava2.frog.egg.FrogEggTool;
|
||||
import com.gitee.drinkjava2.frog.egg.SnakeEggTool;
|
||||
@ -17,6 +16,7 @@ import com.gitee.drinkjava2.frog.objects.EarthQuake;
|
||||
import com.gitee.drinkjava2.frog.objects.EnvObject;
|
||||
import com.gitee.drinkjava2.frog.objects.Food;
|
||||
import com.gitee.drinkjava2.frog.objects.Material;
|
||||
import com.gitee.drinkjava2.frog.objects.Trap;
|
||||
import com.gitee.drinkjava2.frog.util.RandomUtils;
|
||||
|
||||
/**
|
||||
@ -61,7 +61,7 @@ public class Env extends JPanel {
|
||||
public static final int ENV_HEIGHT = ENV_WIDTH; // 虚拟环境高度, 可调,通常取正方形
|
||||
|
||||
/** Frog's brain display width on screen, not important */
|
||||
public static final int FROG_BRAIN_DISP_WIDTH = 600; // Frog的脑图在屏幕上的显示大小,可调
|
||||
public static final int FROG_BRAIN_DISP_WIDTH = 400; // Frog的脑图在屏幕上的显示大小,可调
|
||||
|
||||
/** Steps of one test round */
|
||||
public static final int STEPS_PER_ROUND = 2000;// 每轮测试步数,可调
|
||||
@ -74,7 +74,7 @@ public class Env extends JPanel {
|
||||
|
||||
public static final boolean DELETE_SNAKE_EGGS = true;// 每次运行是否先删除保存的蛇蛋
|
||||
|
||||
public static boolean SNAKE_MODE = true; // 是否加小蛇加进来吃青蛙?
|
||||
public static boolean SNAKE_MODE = false; // 是否加小蛇加进来吃青蛙?
|
||||
|
||||
public static final int SNAKE_EGG_QTY = 10; // 每轮下n个蛇蛋,可调,只有最优秀的前n个蛇们才允许下蛋
|
||||
|
||||
@ -99,7 +99,7 @@ public class Env extends JPanel {
|
||||
|
||||
public static List<Egg> frog_eggs = new ArrayList<>(); // 这里存放新建或从磁盘载入上轮下的蛋,每个蛋可能生成几个青蛙,
|
||||
|
||||
public static EnvObject[] things = new EnvObject[] { new Food(), new EarthQuake() };// 所有外界物体,如食物、地震等都放在这个things里面
|
||||
public static EnvObject[] things = new EnvObject[] { new Food(), new EarthQuake(), new Trap() };// 所有外界物体,如食物、地震等都放在这个things里面
|
||||
|
||||
public static final int TOTAL_SNAKE_QTY = SNAKE_EGG_QTY * SNAKE_PER_EGG; // 蛇的总数
|
||||
|
||||
|
@ -49,18 +49,8 @@ public class Frog extends Animal {
|
||||
g.drawImage(animalImage, x - 8, y - 8, 16, 16, null);// 减去坐标,保证中心显示在当前x,y处
|
||||
if(high > 0){ //如果跳起来了,画个小黄标记出来
|
||||
g.setColor(Color.YELLOW);
|
||||
int r = 5;
|
||||
int r = 7;
|
||||
g.fillArc(x - r + 2, y - r, r, r, 0, 360);
|
||||
}
|
||||
|
||||
if(guagua){ //如果呱呱叫了,画个小红框标记出来
|
||||
g.setColor(Color.red);
|
||||
g.drawRect(x - crockRadius, y - crockRadius, crockRadius + crockRadius, crockRadius + crockRadius);
|
||||
}
|
||||
|
||||
if(wawa){ //如果哇哇叫了,画个小兰框标记出来
|
||||
g.setColor(Color.blue);
|
||||
g.drawRect(x - crockRadius, y - crockRadius, crockRadius + crockRadius, crockRadius + crockRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ public class BrainPicture extends JPanel {
|
||||
y1 = y;
|
||||
|
||||
g.setColor(picColor);
|
||||
g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, (int) round(textSize * scale)));
|
||||
g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, (int) round(textSize * scale*0.5)));
|
||||
g.drawString(text, (int) round(x1) + Env.FROG_BRAIN_DISP_WIDTH / 2 + xOffset,
|
||||
(int) round(y1) + Env.FROG_BRAIN_DISP_WIDTH / 2 + yOffset);
|
||||
|
||||
|
@ -32,6 +32,8 @@ public class Organ extends Zone {
|
||||
public float organActiveEnergy = 1; // 输出器官激活需要消耗每个脑细胞多少能量
|
||||
public float organOutputEnergy = 2; // 感觉器官激活会给每个脑细胞增加多少能量
|
||||
public boolean initilized; // 通过这个标记判断是否需要手工给定它的参数初值
|
||||
|
||||
public static boolean[] sound=new boolean[Env.FROG_BRAIN_XSIZE];
|
||||
|
||||
public boolean allowBorrow() { // 是否允许在精子中将这个器官借出
|
||||
return false;
|
||||
|
@ -30,14 +30,12 @@ import com.gitee.drinkjava2.frog.organ.frog.FrogEyes;
|
||||
import com.gitee.drinkjava2.frog.organ.frog.FrogGuaGua;
|
||||
import com.gitee.drinkjava2.frog.organ.frog.FrogGuaGuaStop;
|
||||
import com.gitee.drinkjava2.frog.organ.frog.FrogHearGuaGua;
|
||||
import com.gitee.drinkjava2.frog.organ.frog.FrogHearWaWa;
|
||||
import com.gitee.drinkjava2.frog.organ.frog.FrogHearGuaGuaStop;
|
||||
import com.gitee.drinkjava2.frog.organ.frog.FrogJump;
|
||||
import com.gitee.drinkjava2.frog.organ.frog.FrogMouth;
|
||||
import com.gitee.drinkjava2.frog.organ.frog.FrogMoves;
|
||||
import com.gitee.drinkjava2.frog.organ.frog.FrogSeeEarthquake;
|
||||
import com.gitee.drinkjava2.frog.organ.frog.FrogSeeEarthquakeStop;
|
||||
import com.gitee.drinkjava2.frog.organ.frog.FrogWaWa;
|
||||
import com.gitee.drinkjava2.frog.organ.frog.FrogWaWaStop;
|
||||
import com.gitee.drinkjava2.frog.util.LocalFileUtils;
|
||||
|
||||
/**
|
||||
@ -127,18 +125,18 @@ public class FrogEggTool {
|
||||
egg.organs.add(new FrogEyes.SeeLeft().setXYZRHN(200 - 90, 500, 500, r, h, "SeeLeft"));
|
||||
egg.organs.add(new FrogEyes.SeeRight().setXYZRHN(200 + 90, 500, 500, r, h, "SeeRight"));
|
||||
|
||||
egg.organs.add(new FrogSeeEarthquake().setXYZRHN(350, 30, 500, r / 4, h, "SeeEarthquake")); // 能看到震心是否活动
|
||||
egg.organs.add(new FrogSeeEarthquakeStop().setXYZRHN(350, 90, 500, r / 4, h, "SeeEarthquakeStop")); // 能看到震心不活动时激活
|
||||
egg.organs.add(new FrogJump().setXYZRHN(350, 150, 500, r / 4, h, "Jump")); // 跳
|
||||
egg.organs.add(new FrogDrop().setXYZRHN(350, 210, 500, r / 4, h, "Drop")); // 回地上
|
||||
|
||||
egg.organs.add(new FrogGuaGua().setXYZRHN(500, 30, 500, r / 4, h, "GuaGua")); // 呱呱叫
|
||||
egg.organs.add(new FrogGuaGuaStop().setXYZRHN(500, 90, 500, r / 4, h, "GuaGuaStop")); // 停止呱呱叫
|
||||
egg.organs.add(new FrogHearGuaGua().setXYZRHN(500, 150, 500, r / 4, h, "GuaGuaStop")); // 停止呱呱叫
|
||||
|
||||
egg.organs.add(new FrogWaWa().setXYZRHN(650, 30, 500, r / 4, h, "WaWa")); // 哇哇叫
|
||||
egg.organs.add(new FrogWaWaStop().setXYZRHN(650, 90, 500, r / 4, h, "WaWaStop")); // 停止哇哇叫
|
||||
egg.organs.add(new FrogHearWaWa().setXYZRHN(650, 150, 500, r / 4, h, "GuaGuaStop")); // 停止呱呱叫
|
||||
egg.organs.add(new FrogSeeEarthquake().setXYZRHN(800, 150, 500, r / 4, h, "SeeEarthQuake")); //看到地震开始了
|
||||
egg.organs.add(new FrogSeeEarthquakeStop().setXYZRHN(800, 210, 500, r / 4, h, "SeeEarthQuakeStop")); //看到地震停止了
|
||||
|
||||
for (int i = 0; i < 3; i++) { //以下分别是呱呱叫、停止呱呱叫、听到呱呱叫,听到呱呱叫停止器官
|
||||
egg.organs.add(new FrogGuaGua().setXYZRHN(400+i*80, 30, 500, 2, h, ""));
|
||||
egg.organs.add(new FrogGuaGuaStop().setXYZRHN(400+i*80, 60, 500, 2, h, ""));
|
||||
egg.organs.add(new FrogHearGuaGua().setXYZRHN(400+i*80, 90, 500, 2, h, ""));
|
||||
egg.organs.add(new FrogHearGuaGuaStop().setXYZRHN(400+i*80, 120, 500, 2, h, ""));
|
||||
}
|
||||
|
||||
Env.frog_eggs.add(egg);
|
||||
}
|
||||
|
@ -29,52 +29,43 @@ import com.gitee.drinkjava2.frog.util.RandomUtils;
|
||||
* @since 1.0
|
||||
*/
|
||||
public class EarthQuake implements EnvObject {
|
||||
public static int activate = 0;
|
||||
public static int centerRadius =130; //震心活动区半径,如果青蛙位于震心活动区内,就能看到地震是否已开始
|
||||
public static int activate = 0;
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
}
|
||||
@Override
|
||||
public void build() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destory() {
|
||||
}
|
||||
@Override
|
||||
public void destory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void active() {
|
||||
if (activate == 0 && RandomUtils.percent(0.5f)) { // 有小机率启动地震
|
||||
activate = 1;
|
||||
}
|
||||
@Override
|
||||
public void active() {
|
||||
if (activate == 0 && RandomUtils.percent(0.5f)) { // 有小机率启动地震
|
||||
activate = 1;
|
||||
}
|
||||
|
||||
if (activate > 0)
|
||||
activate++; // 地震如果启动,强度就开始变大
|
||||
if (activate > 0)
|
||||
activate++; // 地震如果启动,强度就开始变大
|
||||
|
||||
if (activate > 50)
|
||||
activate = 0; // 直到最大值后归零
|
||||
if (activate > 50)
|
||||
activate = 0; // 直到最大值后归零
|
||||
|
||||
if (activate > 0) {// 地震开始杀青蛙
|
||||
for (Frog frog : Env.frogs) {
|
||||
if (frog.high == 0)
|
||||
frog.energy -= 800;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (activate > 0) {// 地震开始杀所有没跳在空中的青蛙
|
||||
for (Frog frog : Env.frogs) {
|
||||
if (frog.high == 0)
|
||||
frog.energy -=1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display() {
|
||||
if (activate > 0) { // 地震杀掉所有地图上没有跳起的蛙
|
||||
Graphics g = Env.buffImg.getGraphics();
|
||||
g.setColor(Color.pink);
|
||||
//g.fillRect(0, 0, Env.ENV_WIDTH - 1, Env.ENV_HEIGHT - 1);
|
||||
g.drawRect(0, 0, Env.ENV_WIDTH - 1, Env.ENV_HEIGHT - 1);
|
||||
g.drawLine(0, 0, Env.ENV_WIDTH - 1, Env.ENV_HEIGHT - 1);
|
||||
g.drawLine(0, Env.ENV_WIDTH - 1, Env.ENV_HEIGHT - 1,0);
|
||||
|
||||
|
||||
|
||||
g.setColor(Color.blue); //但是地震的声音只位于小范围内,用红线表示声音范围,超出这个范围的青蛙是听不到地震的
|
||||
g.drawRect(Env.ENV_WIDTH / 2 - centerRadius, Env.ENV_HEIGHT / 2 - centerRadius,centerRadius*2, centerRadius*2);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void display() {
|
||||
if (activate > 0) {//如果地震了,在地图上画出红框
|
||||
Graphics g = Env.buffImg.getGraphics();
|
||||
g.setColor(Color.RED);
|
||||
g.drawRect(0, 0, Env.ENV_WIDTH - 1, Env.ENV_HEIGHT - 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,10 +22,10 @@ import com.gitee.drinkjava2.frog.Frog;
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class Trap implements EnvObject {
|
||||
private static final int X1 = Env.ENV_WIDTH / 2 - 350 / 2; // 陷阱左上角
|
||||
private static final int Y1 = Env.ENV_HEIGHT / 2 - 20 / 2; // 陷阱左上角
|
||||
private static final int X2 = Env.ENV_WIDTH / 2 + 350 / 2; // 陷阱右下角
|
||||
private static final int Y2 = Env.ENV_HEIGHT / 2 + 20 / 2; // 陷阱右下角
|
||||
private static final int X1 = Env.ENV_WIDTH / 2 - 2; // 陷阱左上角
|
||||
private static final int Y1 = 0; // 陷阱左上角
|
||||
private static final int X2 = Env.ENV_WIDTH / 2 +2; // 陷阱右下角
|
||||
private static final int Y2 = Env.ENV_HEIGHT -1; // 陷阱右下角
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
|
@ -19,7 +19,7 @@ import com.gitee.drinkjava2.frog.brain.Organ;
|
||||
* 这个器官激活,青蛙会回到地上
|
||||
*
|
||||
*/
|
||||
public class FrogDrop extends Organ {// FrogDrop这个器官的作用就是让青蛙回到地上
|
||||
public class FrogDrop extends Organ {// FrogDrop这个器官如果激活会让青蛙回到地上
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
|
@ -11,20 +11,20 @@
|
||||
package com.gitee.drinkjava2.frog.organ.frog;
|
||||
|
||||
import com.gitee.drinkjava2.frog.Animal;
|
||||
import com.gitee.drinkjava2.frog.Env;
|
||||
import com.gitee.drinkjava2.frog.brain.Organ;
|
||||
|
||||
/**
|
||||
* GuaGua create GuaGua sound
|
||||
*/
|
||||
public class FrogGuaGua extends Organ {// 呱呱这个器官的作用就是会发出呱呱叫声,这个叫声会被其它蛙听到
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void active(Animal a) {
|
||||
if(this.beActivedByCells(a)){
|
||||
a.guagua = true;
|
||||
a.energy-=100;
|
||||
}
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void active(Animal a) {
|
||||
if (a.x < Env.ENV_WIDTH / 2 && this.beActivedByCells(a)) { //只有青蛙位于左侧才能呱呱
|
||||
sound[this.roundX()] = true; //叫声的频道只取决于GuaGua器官在脑内的x位置
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,19 +11,20 @@
|
||||
package com.gitee.drinkjava2.frog.organ.frog;
|
||||
|
||||
import com.gitee.drinkjava2.frog.Animal;
|
||||
import com.gitee.drinkjava2.frog.Env;
|
||||
import com.gitee.drinkjava2.frog.brain.Organ;
|
||||
|
||||
/**
|
||||
* GuaGua stop GuaGua sound
|
||||
* GuaGuaStop stop GuaGua sound
|
||||
*/
|
||||
public class FrogGuaGuaStop extends Organ {// 呱呱这个器官的作用就是停止呱呱叫声
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void active(Animal a) {
|
||||
if(this.beActivedByCells(a)){
|
||||
a.guagua = false;
|
||||
}
|
||||
}
|
||||
public class FrogGuaGuaStop extends Organ {// 呱呱这个器官的作用就是停止发出呱呱叫声
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void active(Animal a) {
|
||||
if (a.x < Env.ENV_WIDTH / 2 && this.beActivedByCells(a)) { //只有青蛙位于左侧才能呱呱
|
||||
sound[this.roundX()] = false; //叫声的频道只取决于GuaGua器官在脑内的x位置
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,23 +11,19 @@
|
||||
package com.gitee.drinkjava2.frog.organ.frog;
|
||||
|
||||
import com.gitee.drinkjava2.frog.Animal;
|
||||
import com.gitee.drinkjava2.frog.Env;
|
||||
import com.gitee.drinkjava2.frog.Frog;
|
||||
import com.gitee.drinkjava2.frog.brain.Organ;
|
||||
|
||||
/**
|
||||
* Ear hear sound
|
||||
*/
|
||||
public class FrogHearGuaGua extends Organ {// 这个器官能听到附近青蛙呱呱叫声
|
||||
public class FrogHearGuaGua extends Organ {// 这个器官能听到左侧青蛙呱呱叫声
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void active(Animal a) {
|
||||
for (Frog frog : Env.frogs){
|
||||
if(frog.guagua && a.isClosePosition(frog.x, frog.y, frog.crockRadius)){
|
||||
activeCells(a, 30);
|
||||
return;
|
||||
}
|
||||
public void active(Animal a) {
|
||||
if( Organ.sound[this.roundX()]){ //这个听力器官能听到的频道只取决于此器官在脑内的x位置
|
||||
activeCells(a, 30);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,15 +14,16 @@ import com.gitee.drinkjava2.frog.Animal;
|
||||
import com.gitee.drinkjava2.frog.brain.Organ;
|
||||
|
||||
/**
|
||||
* GuaGua create wawa sound
|
||||
* Ear hear sound
|
||||
*/
|
||||
public class FrogWaWaStop extends Organ {// FrogWaWa这个器官的唯一作用就是停止发出哇哇叫声
|
||||
public class FrogHearGuaGuaStop extends Organ {// 这个器官能听到左侧青蛙呱呱叫声停止
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void active(Animal a) {
|
||||
if(this.beActivedByCells(a)){
|
||||
a.wawa = false;
|
||||
public void active(Animal a) {
|
||||
if( !Organ.sound[this.roundX()]){ //这个听力器官能听到的频道只取决于此器官在脑内的x位置
|
||||
activeCells(a, 30);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or authors.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
|
||||
* applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
||||
* OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the License.
|
||||
*/
|
||||
package com.gitee.drinkjava2.frog.organ.frog;
|
||||
|
||||
import com.gitee.drinkjava2.frog.Animal;
|
||||
import com.gitee.drinkjava2.frog.Env;
|
||||
import com.gitee.drinkjava2.frog.Frog;
|
||||
import com.gitee.drinkjava2.frog.brain.Organ;
|
||||
|
||||
/**
|
||||
* Ear hear sound
|
||||
*/
|
||||
public class FrogHearWaWa extends Organ {// 这个器官能听到附近青蛙哇哇叫声
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void active(Animal a) {
|
||||
for (Frog frog : Env.frogs){
|
||||
if(frog.wawa && a.isClosePosition(frog.x, frog.y, frog.crockRadius)){
|
||||
activeCells(a, 30);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -20,7 +20,7 @@ import com.gitee.drinkjava2.frog.brain.Organ;
|
||||
* 这个器官激活,青蛙会跳在空中,躲开地震波的伤害
|
||||
*
|
||||
*/
|
||||
public class FrogJump extends Organ {// FrogJump这个器官的作用就是让青蛙跳在空中
|
||||
public class FrogJump extends Organ {// FrogJump这个器官的作用就是让青蛙跳在空中,地震来了如果跳在空中就不扣分
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
@ -29,7 +29,7 @@ public class FrogJump extends Organ {// FrogJump这个器官的作用就是让
|
||||
a.high = 1; // 跳起来了的青蛙用画小红点表示,见Frog.show()方法
|
||||
}
|
||||
|
||||
if (a.high > 0) // 为了防止青蛙跳在空中不降落(青蛙=鸟?),这里设定跳到空中的青蛙要扣能量,否则一直在空中怎么能做躲地震的试验
|
||||
if (a.high > 0) // 为了防止青蛙跳在空中不降落,这里设定跳到空中要消耗能量,否则没有惩罚青蛙会一直呆在空中(青蛙=鸟?)
|
||||
a.energy -= 100;
|
||||
}
|
||||
|
||||
|
@ -18,16 +18,15 @@ import com.gitee.drinkjava2.frog.objects.EarthQuake;
|
||||
/**
|
||||
* Ear hear sound
|
||||
*/
|
||||
public class FrogSeeEarthquake extends Organ {// 当青蛙位于震心附近时,这个器官能看到震心在活动
|
||||
public class FrogSeeEarthquake extends Organ {// 当青蛙位于左侧,能看到是否地震
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void active(Animal a) {
|
||||
if(((EarthQuake.activate > 0) && a.isClosePosition(Env.ENV_WIDTH / 2, Env.ENV_HEIGHT / 2, EarthQuake.centerRadius))){
|
||||
if( EarthQuake.activate > 0 && a.x<Env.ENV_WIDTH/2 ){
|
||||
activeCells(a, 30);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,10 +23,10 @@ public class FrogSeeEarthquakeStop extends Organ {// // 当青蛙位于震心附
|
||||
|
||||
@Override
|
||||
public void active(Animal a) {
|
||||
if(((EarthQuake.activate ==0) && a.isClosePosition(Env.ENV_WIDTH / 2, Env.ENV_HEIGHT / 2, EarthQuake.centerRadius))){
|
||||
if( EarthQuake.activate <= 0 && a.x<Env.ENV_WIDTH/2 ){
|
||||
activeCells(a, 30);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or authors.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
|
||||
* applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
||||
* OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the License.
|
||||
*/
|
||||
package com.gitee.drinkjava2.frog.organ.frog;
|
||||
|
||||
import com.gitee.drinkjava2.frog.Animal;
|
||||
import com.gitee.drinkjava2.frog.brain.Organ;
|
||||
|
||||
/**
|
||||
* GuaGua create wawa sound
|
||||
*/
|
||||
public class FrogWaWa extends Organ {// FrogWaWa这个器官的唯一作用就是在激活时发出哇哇叫声
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void active(Animal a) {
|
||||
if (this.beActivedByCells(a)) {
|
||||
a.wawa = true;
|
||||
a.energy-=100;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
BIN
result9_earthquake.gif
Normal file
BIN
result9_earthquake.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 162 KiB |
5
捐款记录.md
5
捐款记录.md
@ -23,10 +23,11 @@ coaf
|
||||
Fan
|
||||
TommyLemon
|
||||
严密
|
||||
目前收入总额:462.77元
|
||||
yiuidsha
|
||||
目前收入总额:482.77元
|
||||
|
||||
支出(按时间顺序):
|
||||
无
|
||||
目前支出总额:0元
|
||||
|
||||
目前余额:462.77元
|
||||
目前余额:482.77元
|
||||
|
@ -203,4 +203,8 @@ T:顶视 F:前视 L:左视 R:右视 X:斜视 方向键:剖视 空格:
|
||||
### 2020-06-20 更正SnakeBigEye的bug,并显示为两条线代表蛙的图像(或舌头),便于简化模式别。设定小蛇只能看到青蛙,青蛙只能看到蛇(严格说是蛇的舌头)。可以看到小蛇会追着青蛙,而青蛙会躲开小蛇,当然也有躲不开被吃掉的。除了引入负值连线用蓝色线条来表示外,技术细节上倒没有什么突破,但这个实验有趣的地方在于它证实了就算是完全随机的排列脑细胞,在长期的优胜劣汰后,生命也会进化出捕食和逃避行为。即然可以进化出捕食和逃避行为,而生命进化又会向越来越复杂的方向进化,所以这个原理可以解释为意识的萌芽了。高等生命的意识,本质上也无非就是大自然随机运动产生的一种复杂现象而已。
|
||||
![result8](result8_snake.gif)
|
||||
|
||||
2020-06-26 更新readme.md. 下一步的工作将移回到体全息存贮的模式识别,因为青蛙需要这个模式识别功能来更好地分辨出蛇和食物的区别,而体全息存贮个人感觉有很多潜力可挖,它有两个最大的优点:一是可以小样本学习,二是可以同时处理多维的信息输入输出。
|
||||
2020-06-26 更新readme.md. 下一步的工作将移回到体全息存贮的模式识别,因为青蛙需要这个模式识别功能来更好地分辨出蛇和食物的区别,而体全息存贮个人感觉有很多潜力可挖,它有两个最大的优点:一是可以小样本学习,二是可以同时处理多维的信息输入输出。
|
||||
|
||||
2021-01-23 语言的诞生。好不容易,告别漫长的2020,去年出的题目我自己解出来了,下面是答案,运行根目录或core目录下的run.bat,可能看到类似下面的运行画面:
|
||||
![result9](result9_earthquake.gif)
|
||||
详细解说:这个题目的模拟环境被简化成左右两个区,设定地震发生时(用红框表示)会扣除所有青蛙的能量,但是只有位于左侧的青蛙可以看到地震发生和停止,右区的青蛙不能看到地震发生和停止,但是青蛙有发音器官和听音器官,如果左侧的青蛙发出叫声是可以被右侧的青蛙听到的。看到地震发生、看到地震停止、发出叫声、听到叫声、跳起、落地这6个器官分别对应6种器官并都偶然进化出来(这个无需证明),这个实验的目的是要验证青蛙会不会在环境逼迫下,在这6种器官对应的脑细胞间形成神经关联。结果可以看到,左侧的青蛙看到地震后,跳在空中(用黄色表示),并发出叫声,然后右侧的青蛙听到叫声后也跳在空中。左侧的青蛙通过叫声信号传递了信息给右侧的青蛙,从而让右侧的青蛙避开了它看不见的地震伤害。这是一个成功的群体进化的演示,它证明了即使是随机生成神经细胞连线,也可以进化出生物的发音-听力功能,也就是说进化出初步的语言功能。
|
||||
|
Loading…
Reference in New Issue
Block a user