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

📄 isowncolor.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.tictactoe;

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

public class IsOwnColor
    extends CommandGene implements ICloneable {
  /** String containing the CVS revision. Read out via reflection!*/
  private final static String CVS_REVISION = "$Revision: 1.3 $";

  private int m_color;

  private int m_subChildType; // Only needed for cloning!

  public IsOwnColor(final GPConfiguration a_conf, int a_color)
      throws InvalidConfigurationException {
    this(a_conf, a_color, 0, 0);
  }

  public IsOwnColor(final GPConfiguration a_conf, int a_color,
                    int a_subReturnType, int a_subChildType)
      throws InvalidConfigurationException {
    super(a_conf, 1, CommandGene.BooleanClass, a_subReturnType, a_subChildType);
    m_subChildType = a_subChildType;
    m_color = a_color;
  }

  public String toString() {
    return "isOwnColor(&1)";
  }

  public boolean execute_boolean(ProgramChromosome c, int n, Object[] args) {
    check(c);
    int color = c.execute_int(n, 0, args);
    return color == m_color;
  }

  /**
   * @return textual name of this command
   *
   * @author Klaus Meffert
   * @since 3.2
   */
  public String getName() {
    return "If Color";
  }

  public Object clone() {
    try {
      IsOwnColor result = new IsOwnColor(getGPConfiguration(), m_color,
          getSubReturnType(), m_subChildType);
      return result;
    } catch (Throwable t) {
      throw new CloneException(t);
    }
  }

  public Class getChildType(IGPProgram a_ind, int a_chromNum) {
    return CommandGene.IntegerClass;
  }
}

⌨️ 快捷键说明

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