aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/function/BooleanLogic.java
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-03-08 14:48:25 +0000
committerEduardo Pedroni <ep625@york.ac.uk>2014-03-08 14:48:25 +0000
commitd63d3145f0f2abcee1bb88457324f4aaf9b9320e (patch)
treedfb19082adfba8989c4fd95ef286b8c1e7a1f2b1 /src/jcgp/function/BooleanLogic.java
parentef7a850a8f2f81ccaa07f25d9b7ad602e84d88c9 (diff)
Slowly refactoring Parameters to fit the GUI a little better...
Diffstat (limited to 'src/jcgp/function/BooleanLogic.java')
-rw-r--r--src/jcgp/function/BooleanLogic.java178
1 files changed, 0 insertions, 178 deletions
diff --git a/src/jcgp/function/BooleanLogic.java b/src/jcgp/function/BooleanLogic.java
deleted file mode 100644
index 713dcf8..0000000
--- a/src/jcgp/function/BooleanLogic.java
+++ /dev/null
@@ -1,178 +0,0 @@
-package jcgp.function;
-
-import jcgp.Parameters;
-import jcgp.exceptions.InvalidArgumentsException;
-import jcgp.population.Connection;
-
-public class BooleanLogic {
-
- public static class And extends Function {
- private int arity = 2;
-
- @Override
- public Boolean run(Connection... connections) {
- if (connections.length < arity) {
- throw new InvalidArgumentsException("Not enough connections were given.");
- } else {
- Boolean arg1 = ((Boolean) connections[0].getValue());
- Boolean arg2 = ((Boolean) connections[1].getValue());
- Boolean result = arg1 && arg2;
- if (Parameters.getDebug()) {
- System.out.println(arg1 + " AND " + arg2 + " = " + result);
- }
- return result;
- }
- }
-
- @Override
- public int getArity() {
- return arity;
- }
- }
-
- public static class Or extends Function {
- private int arity = 2;
-
- @Override
- public Boolean run(Connection... connections) {
- if (connections.length < arity) {
- throw new InvalidArgumentsException("Not enough connections were given.");
- } else {
- Boolean arg1 = ((Boolean) connections[0].getValue());
- Boolean arg2 = ((Boolean) connections[1].getValue());
- Boolean result = arg1 || arg2;
- if (Parameters.getDebug()) {
- System.out.println(arg1 + " OR " + arg2 + " = " + result);
- }
- return result;
- }
- }
-
- @Override
- public int getArity() {
- return arity;
- }
- }
-
- public static class Not extends Function {
- private int arity = 1;
-
- @Override
- public Boolean run(Connection... connections) {
- if (connections.length < arity) {
- throw new InvalidArgumentsException("Not enough connections were given.");
- } else {
- Boolean arg1 = ((Boolean) connections[0].getValue());
- Boolean result = !arg1;
- if (Parameters.getDebug()) {
- System.out.println("NOT " + arg1 + " = " + result);
- }
- return result;
- }
- }
-
- @Override
- public int getArity() {
- return arity;
- }
- }
-
- public static class Xor extends Function {
- private int arity = 2;
-
- @Override
- public Boolean run(Connection... connections) {
- if (connections.length < arity) {
- throw new InvalidArgumentsException("Not enough connections were given.");
- } else {
- Boolean arg1 = ((Boolean) connections[0].getValue());
- Boolean arg2 = ((Boolean) connections[1].getValue());
- Boolean result = arg1 ^ arg2;
- if (Parameters.getDebug()) {
- System.out.println(arg1 + " XOR " + arg2 + " = " + result);
- }
- return result;
- }
- }
-
- @Override
- public int getArity() {
- return arity;
- }
- }
-
- public static class Nand extends Function {
- private int arity = 2;
-
- @Override
- public Boolean run(Connection... connections) {
- if (connections.length < arity) {
- throw new InvalidArgumentsException("Not enough connections were given.");
- } else {
- Boolean arg1 = ((Boolean) connections[0].getValue());
- Boolean arg2 = ((Boolean) connections[1].getValue());
- Boolean result = arg1 && arg2;
- if (Parameters.getDebug()) {
- System.out.println(arg1 + " NAND " + arg2 + " = " + !result);
- }
- return !result;
- }
- }
-
- @Override
- public int getArity() {
- return arity;
- }
- }
-
- public static class Nor extends Function {
- private int arity = 2;
-
- @Override
- public Boolean run(Connection... connections) {
- if (connections.length < arity) {
- throw new InvalidArgumentsException("Not enough connections were given.");
- } else {
- Boolean arg1 = ((Boolean) connections[0].getValue());
- Boolean arg2 = ((Boolean) connections[1].getValue());
- Boolean result = arg1 || arg2;
- if (Parameters.getDebug()) {
- System.out.println(arg1 + " NOR " + arg2 + " = " + !result);
- }
- return !result;
- }
- }
-
- @Override
- public int getArity() {
- return arity;
- }
- }
-
- public static class Xnor extends Function {
- private int arity = 2;
-
- @Override
- public Boolean run(Connection... connections) {
- if (connections.length < arity) {
- throw new InvalidArgumentsException("Not enough connections were given.");
- } else {
- Boolean arg1 = ((Boolean) connections[0].getValue());
- Boolean arg2 = ((Boolean) connections[1].getValue());
- Boolean result = arg1 ^ arg2;
- if (Parameters.getDebug()) {
- System.out.println(arg1 + " XNOR " + arg2 + " = " + !result);
- }
- return !result;
- }
- }
-
- @Override
- public int getArity() {
- return arity;
- }
- }
-
-
-
-}