⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 right.java

📁 一个开源的用java开发的遗传算法的封装好的工程
💻 JAVA
字号:
/*
 * This file is part of JGAP.
 *
 * JGAP offers a dual license model containing the LGPL as well as the MPL.
 *
 * For licencing information please see the file license.txt included with JGAP
 * or have a look at the top of class org.jgap.Chromosome which representatively
 * includes the JGAP license policy applicable for any file delivered with JGAP.
 */
package examples.gp.anttrail;

import org.jgap.*;
import org.jgap.gp.*;
import org.jgap.gp.impl.*;

/**
 * Turn the ant right.
 *
 * @author Klaus Meffert
 * @since 3.01
 */
public class Right
    extends AntCommand implements IMutateable {
  /** String containing the CVS revision. Read out via reflection!*/
  private final static String CVS_REVISION = "$Revision: 1.3 $";

  public Right(final GPConfiguration a_conf)
      throws InvalidConfigurationException {
    super(a_conf);
  }

  public CommandGene applyMutation(int index, double a_percentage)
      throws InvalidConfigurationException {
    Left mutant = new Left(getGPConfiguration());
    return mutant;
  }

  public void execute_void(ProgramChromosome a_chrom, int a_n, Object[] a_args) {
    AntMap map = getMap(a_chrom);
    int orient = map.getOrientation();
    switch (orient) {
      case AntMap.O_DOWN:
        orient = AntMap.O_LEFT;
        break;
      case AntMap.O_LEFT:
        orient = AntMap.O_UP;
        break;
      case AntMap.O_RIGHT:
        orient = AntMap.O_DOWN;
        break;
      case AntMap.O_UP:
        orient = AntMap.O_RIGHT;
        break;
    }
    map.setOrientation(orient);
    map.IncrementMoveCounter();
  }

  public String toString() {
    return "right";
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -