snake almost added, will add big eye

master
drinkjava2 5 years ago
parent 830b83165b
commit 4ecfe95db2

@ -143,6 +143,8 @@ public class Application {
radioFrog.setVisible(true);
radioSnake.setVisible(true);
} else {
radioFrog.setSelected(true);
selectFrog =true;
radioFrog.setVisible(false);
radioSnake.setVisible(false);
}

File diff suppressed because it is too large Load Diff

@ -49,6 +49,7 @@ public class Frog {// 这个程序大量用到public变量而不是getter/setter
public long energy = 100000; // 青蛙的能量为0则死掉
public boolean alive = true; // 设为false表示青蛙死掉了将不参与计算和显示以节省时间
public int ateFood = 0; // 青蛙曾吃过的食物总数,下蛋时如果两个青蛙能量相等,可以比数量
public int no; // 青蛙在Env.frogs中的序号从1开始 会在运行期写到当前brick的最低位可利用Env.frogs.get(no-1)快速定位青蛙
static Image frogImg;
static {

@ -50,7 +50,7 @@ public class Organ extends Zone {
}
/** If active in this organ's zone? */
public boolean outputActive(Frog f) { // 如果一个细胞能量>10,且它的输出触突位于这个器官内,则器官被激活
public boolean outputActive(Frog f) { // 如果细胞能量>organActiveEnergy,则细胞能量减少返回true(激活)标志
for (Cell cell : f.cells)
if (cell.energy > organActiveEnergy)
if (this.nearby(cell.output)) {
@ -62,7 +62,7 @@ public class Organ extends Zone {
}
/** If active in this organ's zone? */
public void activeInput(Frog f, float energy) { // 如果一个细胞能量>10,且它的输出触突位于这个器官内,则器官被激活
public void activeInput(Frog f, float energy) { // 如果一个细胞输入触突位于这个器官内,则细胞能量增加激活
for (Cell cell : f.cells)
if (cell.energy < 100)
if (this.nearby(cell.input)) {

@ -61,7 +61,7 @@ public class Zone implements Serializable { // zone 代表脑空间中的一块
public Zone(Zone a, Zone b) {// 用两个Zone来构造新的zone位于两个zone的中间
this.x = (a.x + b.x) / 2;
this.y = (a.y + b.y) / 2;
this.z = (a.z + b.z) / 2 ;
this.z = (a.z + b.z) / 2-10 ;
this.r = (a.r + b.r) / 2;
}

@ -1,28 +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.github.drinkjava2.frog.brain.organ;
import com.github.drinkjava2.frog.Frog;
import com.github.drinkjava2.frog.brain.Organ;
/**
* Move down frog 1 unit if outputs of nerve cells active in this zone
*/
public class MoveDown extends Organ {
private static final long serialVersionUID = 1L;
@Override
public void active(Frog f) {
if (outputActive(f))
f.y++;
}
}

@ -1,27 +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.github.drinkjava2.frog.brain.organ;
import com.github.drinkjava2.frog.Frog;
import com.github.drinkjava2.frog.brain.Organ;
/**
* Move left frog 1 unit if outputs of nerve cells active in this zone
*/
public class MoveLeft extends Organ {
private static final long serialVersionUID = 1L;
@Override
public void active(Frog f) {
if (outputActive(f))
f.x--;
}
}

@ -1,29 +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.github.drinkjava2.frog.brain.organ;
import com.github.drinkjava2.frog.Frog;
import com.github.drinkjava2.frog.brain.Organ;
/**
* Move right frog 1 unit if outputs of nerve cells active in this zone
*/
public class MoveRight extends Organ {
private static final long serialVersionUID = 1L;
@Override
public void active(Frog f) {
if (outputActive(f))
f.x++;
}
}

@ -1,28 +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.github.drinkjava2.frog.brain.organ;
import com.github.drinkjava2.frog.Frog;
import com.github.drinkjava2.frog.brain.Organ;
/**
* Move up frog 1 unit if outputs of nerve cells active in this zone
*/
public class MoveUp extends Organ {
private static final long serialVersionUID = 1L;
@Override
public void active(Frog f) {
if (outputActive(f))
f.y--;
}
}

@ -0,0 +1,79 @@
/*
* 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.github.drinkjava2.frog.brain.organ;
import com.github.drinkjava2.frog.Env;
import com.github.drinkjava2.frog.Frog;
import com.github.drinkjava2.frog.brain.Organ;
import com.github.drinkjava2.frog.objects.Material;
/**
* Move up frog 1 unit if outputs of nerve cells active in this zone
*/
public class Moves {
public static class MoveUp extends Organ {
private static final long serialVersionUID = 1L;
@Override
public void active(Frog f) {
if (outputActive(f)) {
Env.clearMaterial(f.x, f.y, Material.FROG_TAG);
f.y--;
Env.clearMaterial(f.x, f.y, Material.FROG_TAG);
Env.setMaterial(f.x, f.y, f.no);
}
}
}
public static class MoveDown extends Organ {
private static final long serialVersionUID = 1L;
@Override
public void active(Frog f) {
if (outputActive(f)) {
Env.clearMaterial(f.x, f.y, Material.FROG_TAG);
f.y++;
Env.clearMaterial(f.x, f.y, Material.FROG_TAG);
Env.setMaterial(f.x, f.y, f.no);
}
}
}
public static class MoveLeft extends Organ {
private static final long serialVersionUID = 1L;
@Override
public void active(Frog f) {
if (outputActive(f)) {
Env.clearMaterial(f.x, f.y, Material.FROG_TAG);
f.x--;
Env.clearMaterial(f.x, f.y, Material.FROG_TAG);
Env.setMaterial(f.x, f.y, f.no);
}
}
}
public static class MoveRight extends Organ {
private static final long serialVersionUID = 1L;
@Override
public void active(Frog f) {
if (outputActive(f)) {
Env.clearMaterial(f.x, f.y, Material.FROG_TAG);
f.x++;
Env.clearMaterial(f.x, f.y, Material.FROG_TAG);
Env.setMaterial(f.x, f.y, f.no);
}
}
}
}

@ -23,15 +23,9 @@ import com.github.drinkjava2.frog.Application;
import com.github.drinkjava2.frog.Env;
import com.github.drinkjava2.frog.Frog;
import com.github.drinkjava2.frog.brain.organ.Active;
import com.github.drinkjava2.frog.brain.organ.Eyes;
import com.github.drinkjava2.frog.brain.organ.Mouth;
import com.github.drinkjava2.frog.brain.organ.MoveDown;
import com.github.drinkjava2.frog.brain.organ.MoveLeft;
import com.github.drinkjava2.frog.brain.organ.MoveRight;
import com.github.drinkjava2.frog.brain.organ.MoveUp;
import com.github.drinkjava2.frog.brain.organ.Eyes.SeeDown;
import com.github.drinkjava2.frog.brain.organ.Eyes.SeeLeft;
import com.github.drinkjava2.frog.brain.organ.Eyes.SeeRight;
import com.github.drinkjava2.frog.brain.organ.Eyes.SeeUp;
import com.github.drinkjava2.frog.brain.organ.Moves;
import com.github.drinkjava2.frog.util.LocalFileUtils;
/**
@ -110,15 +104,15 @@ public class FrogEggTool {
Egg egg = new Egg();
float r = 40;
egg.organs.add(new Mouth().setXYZRN(0, 0, 0, 0, "Eat")); // Mouth不是感觉或输出器官没有位置和大小
egg.organs.add(new Active().setXYZRN(500, 600, 500, r, "Active")); // 永远激活
egg.organs.add(new MoveUp().setXYZRN(800, 100, 500, r, "Up"));
egg.organs.add(new MoveDown().setXYZRN(800, 400, 500, r, "Down"));
egg.organs.add(new MoveLeft().setXYZRN(700, 250, 500, r, "Left"));
egg.organs.add(new MoveRight().setXYZRN(900, 250, 500, r, "Right"));
egg.organs.add(new SeeUp().setXYZRN(200, 300 + 90, 500, r, "SeeUp"));
egg.organs.add(new SeeDown().setXYZRN(200, 300 - 90, 500, r, "SeeDown"));
egg.organs.add(new SeeLeft().setXYZRN(200 - 90, 300, 500, r, "SeeLeft"));
egg.organs.add(new SeeRight().setXYZRN(200 + 90, 300, 500, r, "SeeRight"));
egg.organs.add(new Active().setXYZRN(500, 600, 500, r, "Active")); // 永远激活
egg.organs.add(new Moves.MoveUp().setXYZRN(800, 100, 500, r, "Up"));
egg.organs.add(new Moves.MoveDown().setXYZRN(800, 400, 500, r, "Down"));
egg.organs.add(new Moves.MoveLeft().setXYZRN(700, 250, 500, r, "Left"));
egg.organs.add(new Moves.MoveRight().setXYZRN(900, 250, 500, r, "Right"));
egg.organs.add(new Eyes.SeeUp().setXYZRN(200, 300 + 90, 500, r, "SeeUp"));
egg.organs.add(new Eyes.SeeDown().setXYZRN(200, 300 - 90, 500, r, "SeeDown"));
egg.organs.add(new Eyes.SeeLeft().setXYZRN(200 - 90, 300, 500, r, "SeeLeft"));
egg.organs.add(new Eyes.SeeRight().setXYZRN(200 + 90, 300, 500, r, "SeeRight"));
Env.frog_eggs.add(egg);
}
System.out.println("Fail to load frog egg file '" + Application.CLASSPATH + "frog_eggs.ser" + "', created "

@ -22,13 +22,10 @@ import java.util.List;
import com.github.drinkjava2.frog.Application;
import com.github.drinkjava2.frog.Env;
import com.github.drinkjava2.frog.brain.organ.Active;
import com.github.drinkjava2.frog.brain.organ.MoveDown;
import com.github.drinkjava2.frog.brain.organ.MoveLeft;
import com.github.drinkjava2.frog.brain.organ.MoveRight;
import com.github.drinkjava2.frog.brain.organ.MoveUp;
import com.github.drinkjava2.frog.snake.Snake;
import com.github.drinkjava2.frog.snake.brain.organ.SnakeEyes;
import com.github.drinkjava2.frog.snake.brain.organ.SnakeMouth;
import com.github.drinkjava2.frog.snake.brain.organ.SnakeMoves;
import com.github.drinkjava2.frog.util.LocalFileUtils;
/**
@ -90,7 +87,7 @@ public class SnakeEggTool {
* snake Egg
*/
@SuppressWarnings("unchecked")
public static void loadSnakeEggs() {
public static void loadSnakeEggs() {
boolean errorfound = false;
try {
FileInputStream eggsFile = new FileInputStream(Application.CLASSPATH + "snake_eggs.ser");
@ -109,10 +106,10 @@ public class SnakeEggTool {
float r = 40;
egg.organs.add(new SnakeMouth().setXYZRN(0, 0, 0, 0, "Eat")); // SnakeMouth不是感觉或输出器官没有位置和大小
egg.organs.add(new Active().setXYZRN(500, 600, 500, 5, "Active")); // 永远激活
egg.organs.add(new MoveUp().setXYZRN(800, 100, 500, r, "Up"));
egg.organs.add(new MoveDown().setXYZRN(800, 400, 500, r, "Down"));
egg.organs.add(new MoveLeft().setXYZRN(700, 250, 500, r, "Left"));
egg.organs.add(new MoveRight().setXYZRN(900, 250, 500, r, "Right"));
egg.organs.add(new SnakeMoves.MoveUp().setXYZRN(800, 100, 500, r, "Up"));
egg.organs.add(new SnakeMoves.MoveDown().setXYZRN(800, 400, 500, r, "Down"));
egg.organs.add(new SnakeMoves.MoveLeft().setXYZRN(700, 250, 500, r, "Left"));
egg.organs.add(new SnakeMoves.MoveRight().setXYZRN(900, 250, 500, r, "Right"));
egg.organs.add(new SnakeEyes.SeeUp().setXYZRN(200, 300 + 90, 500, r, "SeeUp"));
egg.organs.add(new SnakeEyes.SeeDown().setXYZRN(200, 300 - 90, 500, r, "SeeDown"));
egg.organs.add(new SnakeEyes.SeeLeft().setXYZRN(200 - 90, 300, 500, r, "SeeLeft"));

@ -20,53 +20,66 @@ import com.github.drinkjava2.frog.util.RandomUtils;
/**
* Food randomly scatter on Env
* EnvFOOD_CAN_MOVE=true,)
*
* @author Yong Zhu
* @since 1.0
*/
public class Food implements EnvObject {
public static int food_ated = 0;
@Override
public void build() {
food_ated = 0;
if (!Env.FOOD_CAN_MOVE) {
for (int i = 0; i < FOOD_QTY; i++) // 生成食物
bricks[RandomUtils.nextInt(ENV_WIDTH)][RandomUtils.nextInt(ENV_HEIGHT)] = Material.FOOD;
Env.setMaterial(RandomUtils.nextInt(ENV_WIDTH), RandomUtils.nextInt(ENV_HEIGHT), Material.FOOD);
return;
}
for (int i = 0; i < FOOD_QTY / 4; i++) // 生成苍蝇1
bricks[RandomUtils.nextInt(ENV_WIDTH)][RandomUtils.nextInt(ENV_HEIGHT)] = Material.FLY1;
for (int i = 0; i < FOOD_QTY / 4; i++) // 生成苍蝇2
bricks[RandomUtils.nextInt(ENV_WIDTH)][RandomUtils.nextInt(ENV_HEIGHT)] = Material.FLY2;
for (int i = 0; i < FOOD_QTY / 4; i++) // 生成苍蝇3
bricks[RandomUtils.nextInt(ENV_WIDTH)][RandomUtils.nextInt(ENV_HEIGHT)] = Material.FLY3;
for (int i = 0; i < FOOD_QTY / 4; i++) // 生成苍蝇4
bricks[RandomUtils.nextInt(ENV_WIDTH)][RandomUtils.nextInt(ENV_HEIGHT)] = Material.FLY4;
for (int i = 0; i < FOOD_QTY / 4; i++) { // 生成苍蝇1苍蝇是NPC没有智能
int x = RandomUtils.nextInt(ENV_WIDTH);
int y = RandomUtils.nextInt(ENV_HEIGHT);
Env.setMaterial(x, y, Material.FLY1);
}
for (int i = 0; i < FOOD_QTY / 4; i++) { // 生成苍蝇2
int x = RandomUtils.nextInt(ENV_WIDTH);
int y = RandomUtils.nextInt(ENV_HEIGHT);
Env.setMaterial(x, y, Material.FLY2);
}
for (int i = 0; i < FOOD_QTY / 4; i++) { // 生成苍蝇3
int x = RandomUtils.nextInt(ENV_WIDTH);
int y = RandomUtils.nextInt(ENV_HEIGHT);
Env.setMaterial(x, y, Material.FLY3);
}
for (int i = 0; i < FOOD_QTY / 4; i++) { // 生成苍蝇4
int x = RandomUtils.nextInt(ENV_WIDTH);
int y = RandomUtils.nextInt(ENV_HEIGHT);
Env.setMaterial(x, y, Material.FLY4);
}
}
@Override
public void destory() {
for (int i = 0; i < ENV_WIDTH; i++) {// 清除食物
for (int j = 0; j < ENV_HEIGHT; j++)
if (bricks[i][j] >= Material.FOOD && bricks[i][j] <= Material.FLY4)
bricks[i][j] = 0;
Env.clearMaterial(i, j, Material.ANY_FOOD);
}
}
@Override
public void active(int screen) {
if (RandomUtils.percent(96))
if (!Env.FOOD_CAN_MOVE)// 如果食物不能移动
return;
if (RandomUtils.percent(96))// 用机率来调整食物(苍蝇)的速度
return;
for (int i = 1; i < ENV_WIDTH; i++) {// 水平移动FLY
for (int j = 1; j < ENV_HEIGHT; j++) {
if (bricks[i][j] == Material.FLY1) {
bricks[i - 1][j] = Material.FLY1;
bricks[i][j] = 0;
Env.setMaterial(i - 1, j, Material.FLY1);
Env.clearMaterial(i, j, Material.FLY1);
}
if (bricks[i][j] == Material.FLY2) {
bricks[i][j - 1] = Material.FLY2;
bricks[i][j] = 0;
Env.setMaterial(i, j - 1, Material.FLY2);
Env.clearMaterial(i, j, Material.FLY2);
}
}
}
@ -74,23 +87,23 @@ public class Food implements EnvObject {
for (int i = ENV_WIDTH - 2; i > 0; i--) {// 上下移动FLY
for (int j = ENV_HEIGHT - 2; j > 0; j--) {
if (bricks[i][j] == Material.FLY3) {
bricks[i + 1][j] = Material.FLY3;
bricks[i][j] = 0;
Env.setMaterial(i + 1, j, Material.FLY3);
Env.clearMaterial(i, j, Material.FLY3);
}
if (bricks[i][j] == Material.FLY4) {
bricks[i][j + 1] = Material.FLY4;
bricks[i][j] = 0;
Env.setMaterial(i, j + 1, Material.FLY4);
Env.clearMaterial(i, j, Material.FLY4);
}
}
}
for (int i = 0; i < ENV_WIDTH; i++) {
bricks[i][0] = 0;
bricks[i][ENV_HEIGHT - 1] = 0;
Env.clearMaterial(i, 0, Material.ANY_FOOD);
Env.clearMaterial(i, ENV_HEIGHT - 1, Material.ANY_FOOD);
}
for (int i = 0; i < ENV_HEIGHT; i++) {
bricks[0][i] = 0;
bricks[ENV_WIDTH - 1][i] = 0;
Env.clearMaterial(0, i, Material.ANY_FOOD);
Env.clearMaterial(ENV_WIDTH - 1, i, Material.ANY_FOOD);
}
}

@ -15,38 +15,47 @@ import java.awt.Color;
/**
* Material store material types
*
* 0, 15
* 16384Env.frogs.get(no-1)
*
* @author Yong Zhu
* @since 1.0
*/
public class Material {
private static int origin = 1;
private static int next() {// 每次将origin左移1位
public static final int FROG_TAG = 0b11111111111111; // 16383 小于等于16384的位数用来标记青蛙序号可利用Env.frogs.get(no-1)快速定位青蛙
private static int origin = FROG_TAG + 1; // 大于16384用来作为各种材料的标记
private static int nextLeftShift() {// 每次将origin左移1位
origin = origin << 1;
if (origin < 0)
throw new RuntimeException("");
throw new IllegalArgumentException("Material out of maximum range");
return origin;
}
public static final int NO = 0; // nothing
public static final int VISIBLE = next(); // if visible to frog
public static final int SEESAW = next();
public static final int FOOD = next();
public static final int FLY1 = next();// FLY1苍蝇是一种会移动的Food
public static final int FLY2 = next();// FLY2苍蝇是一种会移动的Food
public static final int FLY3 = next();// FLY3苍蝇是一种会移动的Food
public static final int FLY4 = next();// FLY4苍蝇是一种会移动的Food
// public static final int NO = 0; // nothing
public static final int VISIBLE = nextLeftShift(); // if visible to frog
public static final int KILLFROG = next(); // if>=KILLFROG will kill frog
public static final int BRICK = next();// brick will kill frog
public static final int TRAP = next(); // trap will kill frog
public static final int SEESAW = nextLeftShift();
public static final int FOOD = nextLeftShift();
public static final int FLY1 = nextLeftShift();// FLY1苍蝇是一种会移动的Food
public static final int FLY2 = nextLeftShift();// FLY2苍蝇是一种会移动的Food
public static final int FLY3 = nextLeftShift();// FLY3苍蝇是一种会移动的Food
public static final int FLY4 = nextLeftShift();// FLY4苍蝇是一种会移动的Food
public static final int ANY_FOOD = FOOD + FLY1 + FLY2 + FLY3 + FLY4;// ANY_FOOD是几种FOOD的位叠加
public static final int SNAKE = nextLeftShift(); // 蛇的图形
public static final int KILLFROG = nextLeftShift(); // if>=KILLFROG will kill frog
public static final int BRICK = nextLeftShift();// brick will kill frog
public static final int TRAP = nextLeftShift(); // trap will kill frog
public static Color color(int material) {
if (material == TRAP)
if ((material & TRAP) > 0)
return Color.LIGHT_GRAY;
else
return Color.BLACK;
}
}

@ -53,7 +53,7 @@ public class SnakeEyes {
@Override
public void active(Frog f) {
for (int i = 1; i < seeDistance; i++)
if (Env.foundAnyThing(f.x, f.y + i)) {
if (Env.foundFrog(f.x, f.y + i)) {
activeInput(f, 30);
return;
}
@ -66,7 +66,7 @@ public class SnakeEyes {
@Override
public void active(Frog f) {
for (int i = 1; i < seeDistance; i++)
if (Env.foundAnyThing(f.x, f.y - i)) {
if (Env.foundFrog(f.x, f.y - i)) {
activeInput(f, 30);
return;
}
@ -79,7 +79,7 @@ public class SnakeEyes {
@Override
public void active(Frog f) {
for (int i = 1; i < seeDistance; i++)
if (Env.foundAnyThing(f.x - i, f.y)) {
if (Env.foundFrog(f.x - i, f.y)) {
activeInput(f, 30);
return;
}
@ -92,7 +92,7 @@ public class SnakeEyes {
@Override
public void active(Frog f) {
for (int i = 1; i < seeDistance; i++)
if (Env.foundAnyThing(f.x + i, f.y)) {
if (Env.foundFrog(f.x + i, f.y)) {
activeInput(f, 30);
return;
}

@ -0,0 +1,75 @@
/*
* 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.github.drinkjava2.frog.snake.brain.organ;
import com.github.drinkjava2.frog.Env;
import com.github.drinkjava2.frog.Frog;
import com.github.drinkjava2.frog.brain.Organ;
import com.github.drinkjava2.frog.objects.Material;
/**
* Move up frog 1 unit if outputs of nerve cells active in this zone
*/
public class SnakeMoves {
public static class MoveUp extends Organ {
private static final long serialVersionUID = 1L;
@Override
public void active(Frog f) {
if (outputActive(f)) {
Env.clearMaterial(f.x, f.y, Material.SNAKE);
f.y--;
Env.setMaterial(f.x, f.y, Material.SNAKE);
}
}
}
public static class MoveDown extends Organ {
private static final long serialVersionUID = 1L;
@Override
public void active(Frog f) {
if (outputActive(f)) {
Env.clearMaterial(f.x, f.y, Material.SNAKE);
f.y++;
Env.setMaterial(f.x, f.y, Material.SNAKE);
}
}
}
public static class MoveLeft extends Organ {
private static final long serialVersionUID = 1L;
@Override
public void active(Frog f) {
if (outputActive(f)) {
Env.clearMaterial(f.x, f.y, Material.SNAKE);
f.x--;
Env.setMaterial(f.x, f.y, Material.SNAKE);
}
}
}
public static class MoveRight extends Organ {
private static final long serialVersionUID = 1L;
@Override
public void active(Frog f) {
if (outputActive(f)) {
Env.clearMaterial(f.x, f.y, Material.SNAKE);
f.x++;
Env.setMaterial(f.x, f.y, Material.SNAKE);
}
}
}
}

@ -1,6 +1,6 @@
这个项目的捐款将用于项目本身,如发布开发任务等。设这个捐款记录的目的是为了让收支透明化,万一项目做大了,收到码云平台外的捐款也可以在这里记录下来。本记录按时间顺序记录捐款人和当前总额,不记具体数额,这样即体现了不鼓励金额攀比、自愿随意的原则,也能通过历史记录查询出每笔的具体数额。在此衷心地感谢每一位捐款、点赞、及关注这个项目的同学!
捐款(按时间顺序):
捐款(按时间顺序):
wangtao
dotao
LongFer
@ -19,7 +19,6 @@ miazzy
半城言沙
sunne
CV远程移动师
目前收入总额:339.57元
支出(按时间顺序)

Loading…
Cancel
Save