Skip to content
Browse files

Normalize line endings

  • Loading branch information...
1 parent d2b9f3a commit 31693e39abdcfe6aed8218346da2d03f5aeea189 @jeffheaton jeffheaton committed Dec 31, 2013
Showing with 9,861 additions and 9,838 deletions.
  1. +23 −0 .gitattributes
  2. +14 −14 .project
  3. +5 −5 .settings/org.eclipse.jdt.core.prefs
  4. +38 −38 NOTICE.txt
  5. +11 −11 README.txt
  6. +73 −73 build.xml
  7. +156 −156 pom.xml
  8. +52 −52 src/main/assembly/release.xml
  9. +79 −79 src/main/java/org/encog/examples/clustering/kmeans/SimpleKMeans.java
  10. +55 −55 src/main/java/org/encog/examples/gui/elementary/DisplayPanel.java
  11. +203 −203 src/main/java/org/encog/examples/gui/elementary/ElementaryExample.java
  12. +72 −72 src/main/java/org/encog/examples/gui/generic/GenericBatch.java
  13. +279 −279 src/main/java/org/encog/examples/gui/generic/GenericExample.java
  14. +55 −55 src/main/java/org/encog/examples/gui/generic/GenericPanel.java
  15. +279 −279 src/main/java/org/encog/examples/gui/life/GameOfLife.java
  16. +55 −55 src/main/java/org/encog/examples/gui/life/WorldPanel.java
  17. +172 −172 src/main/java/org/encog/examples/ml/bayesian/BayesianSpam.java
  18. +78 −78 src/main/java/org/encog/examples/ml/bayesian/SimpleBayesian.java
  19. +69 −69 src/main/java/org/encog/examples/ml/bayesian/SimpleK2.java
  20. +88 −88 src/main/java/org/encog/examples/ml/bayesian/words/BayesianSpam.java
  21. +204 −204 src/main/java/org/encog/examples/ml/bayesian/words/BayesianWordAnalyzer.java
  22. +111 −111 src/main/java/org/encog/examples/ml/hmm/HMMSimpleContinuous.java
  23. +98 −98 src/main/java/org/encog/examples/ml/hmm/HMMSimpleDiscrete.java
  24. +82 −82 src/main/java/org/encog/examples/ml/hmm/HMMSimpleKMeans.java
  25. +65 −65 src/main/java/org/encog/examples/ml/prg/Benchmark.java
  26. +201 −201 src/main/java/org/encog/examples/ml/sampling/SimpleSampling.java
  27. +101 −101 src/main/java/org/encog/examples/ml/tsp/City.java
  28. +157 −157 src/main/java/org/encog/examples/ml/tsp/anneal/SolveTSP.java
  29. +133 −133 src/main/java/org/encog/examples/ml/tsp/anneal/TSPSimulatedAnnealing.java
  30. +186 −186 src/main/java/org/encog/examples/ml/tsp/genetic/SolveTSP.java
  31. +66 −66 src/main/java/org/encog/examples/ml/tsp/genetic/TSPScore.java
  32. +171 −171 src/main/java/org/encog/examples/ml/world/QLearningPanel.java
  33. +100 −100 src/main/java/org/encog/examples/ml/world/QLearningPattern.java
  34. +219 −219 src/main/java/org/encog/examples/neural/adaline/AdalineDigits.java
  35. +126 −126 src/main/java/org/encog/examples/neural/analyst/AnalystExample.java
  36. +108 −108 src/main/java/org/encog/examples/neural/art/art1/NeuralART1.java
  37. +184 −184 src/main/java/org/encog/examples/neural/bam/BidirectionalAssociativeMemory.java
  38. +106 −106 src/main/java/org/encog/examples/neural/benchmark/ActivationFunctions.java
  39. +53 −53 src/main/java/org/encog/examples/neural/benchmark/Benchmark.java
  40. +104 −104 src/main/java/org/encog/examples/neural/benchmark/BinaryVsMemory.java
  41. +129 −129 src/main/java/org/encog/examples/neural/benchmark/ElliottBenchmark.java
  42. +77 −77 src/main/java/org/encog/examples/neural/benchmark/ErrorMethod.java
  43. +92 −92 src/main/java/org/encog/examples/neural/benchmark/FahlmanEncoder.java
  44. +135 −135 src/main/java/org/encog/examples/neural/benchmark/FreeformBenchmark.java
  45. +57 −57 src/main/java/org/encog/examples/neural/benchmark/MatrixBenchmark.java
  46. +108 −108 src/main/java/org/encog/examples/neural/benchmark/MultiBench.java
  47. +103 −103 src/main/java/org/encog/examples/neural/benchmark/PSOBenchmark.java
  48. +103 −103 src/main/java/org/encog/examples/neural/benchmark/SimpleBenchmark.java
  49. +91 −91 src/main/java/org/encog/examples/neural/benchmark/TestConverge.java
  50. +73 −73 src/main/java/org/encog/examples/neural/benchmark/ThreadCount.java
  51. +104 −104 src/main/java/org/encog/examples/neural/benchmark/WeightInitialization.java
  52. +185 −185 src/main/java/org/encog/examples/neural/boltzmann/BoltzTSP.java
  53. +401 −401 src/main/java/org/encog/examples/neural/cpn/RocketCPN.java
  54. +197 −197 src/main/java/org/encog/examples/neural/cross/CrossValidateSunspot.java
  55. +75 −75 src/main/java/org/encog/examples/neural/csv/XORCSV.java
  56. +148 −148 src/main/java/org/encog/examples/neural/forest/Evaluate.java
  57. +270 −270 src/main/java/org/encog/examples/neural/forest/ForestConfig.java
  58. +182 −182 src/main/java/org/encog/examples/neural/forest/ForestCover.java
  59. +206 −206 src/main/java/org/encog/examples/neural/forest/GenerateData.java
  60. +72 −72 src/main/java/org/encog/examples/neural/forest/TrainNetwork.java
  61. +73 −73 src/main/java/org/encog/examples/neural/freeform/ConvertToFreeform.java
  62. +111 −111 src/main/java/org/encog/examples/neural/freeform/FreeformCompare.java
  63. +74 −74 src/main/java/org/encog/examples/neural/freeform/FreeformXOR.java
  64. +75 −75 src/main/java/org/encog/examples/neural/freeform/SkipNeuralNetwork.java
  65. +171 −171 src/main/java/org/encog/examples/neural/gui/hopfield/HopfieldPanel.java
  66. +100 −100 src/main/java/org/encog/examples/neural/gui/hopfield/HopfieldPattern.java
  67. +168 −168 src/main/java/org/encog/examples/neural/gui/predict/GraphPanel.java
  68. +111 −111 src/main/java/org/encog/examples/neural/gui/predict/PredictSIN.java
  69. +76 −76 src/main/java/org/encog/examples/neural/gui/som/MapPanel.java
  70. +106 −106 src/main/java/org/encog/examples/neural/gui/som/SomColors.java
  71. +253 −253 src/main/java/org/encog/examples/neural/hopfield/HopfieldAssociate.java
  72. +296 −296 src/main/java/org/encog/examples/neural/image/ImageNeuralNetwork.java
  73. +103 −103 src/main/java/org/encog/examples/neural/lunar/LanderSimulator.java
  74. +98 −98 src/main/java/org/encog/examples/neural/lunar/LunarLander.java
  75. +79 −79 src/main/java/org/encog/examples/neural/lunar/NeuralPilot.java
  76. +48 −48 src/main/java/org/encog/examples/neural/lunar/PilotScore.java
  77. +75 −75 src/main/java/org/encog/examples/neural/neat/XORNEAT.java
  78. +116 −116 src/main/java/org/encog/examples/neural/neat/boxes/BoxTrialCase.java
  79. +121 −121 src/main/java/org/encog/examples/neural/neat/boxes/BoxesScore.java
  80. +72 −72 src/main/java/org/encog/examples/neural/neat/boxes/DisplayBoxes.java
  81. +109 −109 src/main/java/org/encog/examples/neural/neat/boxes/DisplayBoxesPanel.java
  82. +187 −187 src/main/java/org/encog/examples/neural/neat/boxes/TrialEvaluation.java
Sorry, we could not display the entire diff because it was too big.
View
23 .gitattributes
@@ -0,0 +1,23 @@
+# Auto detect text files and perform LF normalization
+* text=auto
+
+# Custom for Visual Studio
+*.cs diff=csharp
+*.java diff=csharp
+*.sln merge=union
+*.csproj merge=union
+*.vbproj merge=union
+*.fsproj merge=union
+*.dbproj merge=union
+
+# Standard to msysgit
+*.doc diff=astextplain
+*.DOC diff=astextplain
+*.docx diff=astextplain
+*.DOCX diff=astextplain
+*.dot diff=astextplain
+*.DOT diff=astextplain
+*.pdf diff=astextplain
+*.PDF diff=astextplain
+*.rtf diff=astextplain
+*.RTF diff=astextplain
View
28 .project
@@ -1,15 +1,15 @@
-<projectDescription>
- <name>encog-examples</name>
- <comment>Examples for the Encog Machine Learning Framework. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
- <projects>
- <project>encog-core</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
+<projectDescription>
+ <name>encog-examples</name>
+ <comment>Examples for the Encog Machine Learning Framework. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
+ <projects>
+ <project>encog-core</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
</projectDescription>
View
10 .settings/org.eclipse.jdt.core.prefs
@@ -1,5 +1,5 @@
-#Sun Apr 17 14:56:35 CDT 2011
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.source=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
+#Sun Apr 17 14:56:35 CDT 2011
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
View
76 NOTICE.txt
@@ -1,39 +1,39 @@
- Encog 3.2 Machine Learning Framework
- Copyright 2008-2013 Heaton Research, Inc.
-
- This product includes software developed at
- Heaton Research, Inc. (http://www.heatonresearch.com/encog/).
-
-====================================================================
-LibSVM Copyright
-Copyright (c) 2000-2011 Chih-Chung Chang and Chih-Jen Lin
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-1. Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-
-3. Neither name of copyright holders nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Encog 3.2 Machine Learning Framework
+ Copyright 2008-2013 Heaton Research, Inc.
+
+ This product includes software developed at
+ Heaton Research, Inc. (http://www.heatonresearch.com/encog/).
+
+====================================================================
+LibSVM Copyright
+Copyright (c) 2000-2011 Chih-Chung Chang and Chih-Jen Lin
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+3. Neither name of copyright holders nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=======================================================================
View
22 README.txt
@@ -1,12 +1,12 @@
-Encog 3.2
-
-The following links will be helpful getting started with Encog.
-
-Getting Started:
-
-http://www.heatonresearch.com/wiki/Getting_Started
-
-Important Links:
-
-http://www.heatonresearch.com/encog
+Encog 3.2
+
+The following links will be helpful getting started with Encog.
+
+Getting Started:
+
+http://www.heatonresearch.com/wiki/Getting_Started
+
+Important Links:
+
+http://www.heatonresearch.com/encog
http://www.heatonresearch.com/wiki
View
146 build.xml
@@ -1,73 +1,73 @@
-<!--
- Encog Artificial Intelligence Framework v3.0
- Java Version
- http://www.heatonresearch.com/encog/
- http://code.google.com/p/encog-java/
-
- Copyright 2008-2011, Heaton Research Inc., and individual contributors.
- See the copyright.txt in the distribution for a full listing of
- individual contributors.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
--->
-<project name="EncogExamples" default="dist" basedir=".">
- <description>
- Build the Encog examples.
- </description>
- <!-- set global properties for this build -->
- <property name="src" location="src\main\java"/>
- <property name="lib" location="lib"/>
- <property name="build" location="build"/>
- <property name="dist" location="dist"/>
-
- <path id="master-classpath">
- <fileset dir="${lib}">
- <include name="*.jar"/>
- </fileset>
- </path>
-
-
- <target name="init">
- <!-- Create the time stamp -->
- <tstamp/>
- <!-- Create the build directory structure used by compile -->
- <mkdir dir="${build}"/>
- </target>
-
- <target name="compile" depends="init"
- description="compile the source " >
- <!-- Compile the java code from ${src} into ${build} -->
- <javac srcdir="${src}" destdir="${build}">
- <classpath refid="master-classpath"/>
- </javac>
- </target>
-
- <target name="dist" depends="compile"
- description="generate the distribution" >
- <!-- Create the distribution directory -->
- <mkdir dir="${dist}/lib"/>
-
- <!-- Put everything in examples.jar file -->
- <jar jarfile="${lib}/examples.jar" basedir="${build}"/>
- </target>
-
- <target name="clean"
- description="clean up" >
- <!-- Delete the ${build} and ${dist} directory trees -->
- <delete dir="${build}"/>
- <delete dir="${dist}"/>
- </target>
-</project>
+<!--
+ Encog Artificial Intelligence Framework v3.0
+ Java Version
+ http://www.heatonresearch.com/encog/
+ http://code.google.com/p/encog-java/
+
+ Copyright 2008-2011, Heaton Research Inc., and individual contributors.
+ See the copyright.txt in the distribution for a full listing of
+ individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<project name="EncogExamples" default="dist" basedir=".">
+ <description>
+ Build the Encog examples.
+ </description>
+ <!-- set global properties for this build -->
+ <property name="src" location="src\main\java"/>
+ <property name="lib" location="lib"/>
+ <property name="build" location="build"/>
+ <property name="dist" location="dist"/>
+
+ <path id="master-classpath">
+ <fileset dir="${lib}">
+ <include name="*.jar"/>
+ </fileset>
+ </path>
+
+
+ <target name="init">
+ <!-- Create the time stamp -->
+ <tstamp/>
+ <!-- Create the build directory structure used by compile -->
+ <mkdir dir="${build}"/>
+ </target>
+
+ <target name="compile" depends="init"
+ description="compile the source " >
+ <!-- Compile the java code from ${src} into ${build} -->
+ <javac srcdir="${src}" destdir="${build}">
+ <classpath refid="master-classpath"/>
+ </javac>
+ </target>
+
+ <target name="dist" depends="compile"
+ description="generate the distribution" >
+ <!-- Create the distribution directory -->
+ <mkdir dir="${dist}/lib"/>
+
+ <!-- Put everything in examples.jar file -->
+ <jar jarfile="${lib}/examples.jar" basedir="${build}"/>
+ </target>
+
+ <target name="clean"
+ description="clean up" >
+ <!-- Delete the ${build} and ${dist} directory trees -->
+ <delete dir="${build}"/>
+ <delete dir="${dist}"/>
+ </target>
+</project>
View
312 pom.xml
@@ -1,156 +1,156 @@
-<!--
- Encog Artificial Intelligence Framework v3.2
- Java Examples
- http://www.heatonresearch.com/encog/
- http://code.google.com/p/encog-java/
-
- Copyright 2008-2013, Heaton Research Inc., and individual contributors.
- See the copyright.txt in the distribution for a full listing of
- individual contributors.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
--->
-<!-- This POM makes Encog a Maven artifact, accessible from other programs
- using Maven.
-
-Authors of this POM file: iirekm, jheaton
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.encog</groupId>
- <artifactId>encog-examples</artifactId>
- <version>3.2.0-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>Encog Examples</name>
- <description>Examples for the Encog Machine Learning Framework.</description>
- <url>http://www.heatonresearch.com/encog/</url>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
- <scm>
- <connection>scm:svn:http://encog-java.googlecode.com/svn/trunk/encog-examples/</connection>
- <developerConnection>scm:svn:https://encog-java.googlecode.com/svn/trunk/encog-examples/</developerConnection>
- <url>http://code.google.com/p/encog-java/source/browse/</url>
- </scm>
- <developers>
- <developer>
- <id>jeffheatondotcom</id>
- <name>Jeff Heaton</name>
- <email>support@heatonresearch.com</email>
- </developer>
- </developers>
-
- <build>
-
- <plugins>
- <!-- use javac 1.6 -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
-
- <!-- build also source jar - useful for working in Eclipse -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.1.1</version>
- <executions>
- <execution>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <!-- Generate Javadoc, required to push to repo -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.7</version>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.3.1</version>
- </plugin>
-
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2.1</version>
- <configuration>
- <descriptors>
- <descriptor>src/main/assembly/release.xml</descriptor>
- </descriptors>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-gpg-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <id>sign-artifacts</id>
- <phase>verify</phase>
- <goals>
- <goal>sign</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.encog</groupId>
- <artifactId>encog-core</artifactId>
- <version>3.2.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-</project>
+<!--
+ Encog Artificial Intelligence Framework v3.2
+ Java Examples
+ http://www.heatonresearch.com/encog/
+ http://code.google.com/p/encog-java/
+
+ Copyright 2008-2013, Heaton Research Inc., and individual contributors.
+ See the copyright.txt in the distribution for a full listing of
+ individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<!-- This POM makes Encog a Maven artifact, accessible from other programs
+ using Maven.
+
+Authors of this POM file: iirekm, jheaton
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.encog</groupId>
+ <artifactId>encog-examples</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Encog Examples</name>
+ <description>Examples for the Encog Machine Learning Framework.</description>
+ <url>http://www.heatonresearch.com/encog/</url>
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <scm>
+ <connection>scm:svn:http://encog-java.googlecode.com/svn/trunk/encog-examples/</connection>
+ <developerConnection>scm:svn:https://encog-java.googlecode.com/svn/trunk/encog-examples/</developerConnection>
+ <url>http://code.google.com/p/encog-java/source/browse/</url>
+ </scm>
+ <developers>
+ <developer>
+ <id>jeffheatondotcom</id>
+ <name>Jeff Heaton</name>
+ <email>support@heatonresearch.com</email>
+ </developer>
+ </developers>
+
+ <build>
+
+ <plugins>
+ <!-- use javac 1.6 -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+
+ <!-- build also source jar - useful for working in Eclipse -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Generate Javadoc, required to push to repo -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.7</version>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.3.1</version>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2.1</version>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/release.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>sign-artifacts</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>sign</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.encog</groupId>
+ <artifactId>encog-core</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
View
104 src/main/assembly/release.xml
@@ -1,52 +1,52 @@
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>release</id>
- <formats>
- <format>zip</format>
-
- </formats>
- <fileSets>
- <fileSet>
- <directory>${project.basedir}</directory>
- <outputDirectory>/</outputDirectory>
- <useDefaultExcludes>true</useDefaultExcludes>
- <includes>
- <include>.settings/**</include>
- <include>src/**</include>
- <include>.classpath</include>
- <include>.project</include>
- <include>LICENSE.txt</include>
- <include>README.txt</include>
- <include>NOTICE.txt</include>
- <include>pom.xml</include>
- <include>build.xml</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>${project.build.directory}</directory>
- <outputDirectory>/</outputDirectory>
- <includes>
- <include>apidocs/**</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>${project.build.directory}</directory>
- <outputDirectory>/lib</outputDirectory>
- <includes>
- <include>*-jar-with-dependencies*</include>
- </includes>
- </fileSet>
- </fileSets>
-
- <dependencySets>
- <dependencySet>
- <outputDirectory>/lib</outputDirectory>
- <useProjectArtifact>true</useProjectArtifact>
- <unpack>false</unpack>
- <scope>runtime</scope>
- </dependencySet>
- </dependencySets>
-
-
-</assembly>
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>release</id>
+ <formats>
+ <format>zip</format>
+
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>${project.basedir}</directory>
+ <outputDirectory>/</outputDirectory>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ <includes>
+ <include>.settings/**</include>
+ <include>src/**</include>
+ <include>.classpath</include>
+ <include>.project</include>
+ <include>LICENSE.txt</include>
+ <include>README.txt</include>
+ <include>NOTICE.txt</include>
+ <include>pom.xml</include>
+ <include>build.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.build.directory}</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>apidocs/**</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.build.directory}</directory>
+ <outputDirectory>/lib</outputDirectory>
+ <includes>
+ <include>*-jar-with-dependencies*</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>/lib</outputDirectory>
+ <useProjectArtifact>true</useProjectArtifact>
+ <unpack>false</unpack>
+ <scope>runtime</scope>
+ </dependencySet>
+ </dependencySets>
+
+
+</assembly>
View
158 src/main/java/org/encog/examples/clustering/kmeans/SimpleKMeans.java
@@ -1,79 +1,79 @@
-/*
- * Encog(tm) Java Examples v3.2
- * http://www.heatonresearch.com/encog/
- * https://github.com/encog/encog-java-examples
- *
- * Copyright 2008-2013 Heaton Research, Inc.
- *
- * 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.
- *
- * For more information on Heaton Research copyrights, licenses
- * and trademarks visit:
- * http://www.heatonresearch.com/copyright
- */
-package org.encog.examples.clustering.kmeans;
-
-import java.util.Arrays;
-
-import org.encog.ml.MLCluster;
-import org.encog.ml.data.MLDataPair;
-import org.encog.ml.data.MLDataSet;
-import org.encog.ml.data.basic.BasicMLData;
-import org.encog.ml.data.basic.BasicMLDataPair;
-import org.encog.ml.data.basic.BasicMLDataSet;
-import org.encog.ml.kmeans.KMeansClustering;
-
-/**
- * This example performs a simple KMeans cluster. The numbers are clustered
- * into two groups.
- */
-public class SimpleKMeans {
-
- /**
- * The data to be clustered.
- */
- public static final double[][] DATA = { { 28, 15, 22 }, { 16, 15, 32 },
- { 32, 20, 44 }, { 1, 2, 3 }, { 3, 2, 1 } };
-
- /**
- * The main method.
- * @param args Arguments are not used.
- */
- public static void main(final String args[]) {
-
- final BasicMLDataSet set = new BasicMLDataSet();
-
- for (final double[] element : SimpleKMeans.DATA) {
- set.add(new BasicMLData(element));
- }
-
- final KMeansClustering kmeans = new KMeansClustering(2, set);
-
- kmeans.iteration(100);
- //System.out.println("Final WCSS: " + kmeans.getWCSS());
-
- // Display the cluster
- int i = 1;
- for (final MLCluster cluster : kmeans.getClusters()) {
- System.out.println("*** Cluster " + (i++) + " ***");
- final MLDataSet ds = cluster.createDataSet();
- final MLDataPair pair = BasicMLDataPair.createPair(
- ds.getInputSize(), ds.getIdealSize());
- for (int j = 0; j < ds.getRecordCount(); j++) {
- ds.getRecord(j, pair);
- System.out.println(Arrays.toString(pair.getInputArray()));
-
- }
- }
- }
-}
+/*
+ * Encog(tm) Java Examples v3.2
+ * http://www.heatonresearch.com/encog/
+ * https://github.com/encog/encog-java-examples
+ *
+ * Copyright 2008-2013 Heaton Research, Inc.
+ *
+ * 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.
+ *
+ * For more information on Heaton Research copyrights, licenses
+ * and trademarks visit:
+ * http://www.heatonresearch.com/copyright
+ */
+package org.encog.examples.clustering.kmeans;
+
+import java.util.Arrays;
+
+import org.encog.ml.MLCluster;
+import org.encog.ml.data.MLDataPair;
+import org.encog.ml.data.MLDataSet;
+import org.encog.ml.data.basic.BasicMLData;
+import org.encog.ml.data.basic.BasicMLDataPair;
+import org.encog.ml.data.basic.BasicMLDataSet;
+import org.encog.ml.kmeans.KMeansClustering;
+
+/**
+ * This example performs a simple KMeans cluster. The numbers are clustered
+ * into two groups.
+ */
+public class SimpleKMeans {
+
+ /**
+ * The data to be clustered.
+ */
+ public static final double[][] DATA = { { 28, 15, 22 }, { 16, 15, 32 },
+ { 32, 20, 44 }, { 1, 2, 3 }, { 3, 2, 1 } };
+
+ /**
+ * The main method.
+ * @param args Arguments are not used.
+ */
+ public static void main(final String args[]) {
+
+ final BasicMLDataSet set = new BasicMLDataSet();
+
+ for (final double[] element : SimpleKMeans.DATA) {
+ set.add(new BasicMLData(element));
+ }
+
+ final KMeansClustering kmeans = new KMeansClustering(2, set);
+
+ kmeans.iteration(100);
+ //System.out.println("Final WCSS: " + kmeans.getWCSS());
+
+ // Display the cluster
+ int i = 1;
+ for (final MLCluster cluster : kmeans.getClusters()) {
+ System.out.println("*** Cluster " + (i++) + " ***");
+ final MLDataSet ds = cluster.createDataSet();
+ final MLDataPair pair = BasicMLDataPair.createPair(
+ ds.getInputSize(), ds.getIdealSize());
+ for (int j = 0; j < ds.getRecordCount(); j++) {
+ ds.getRecord(j, pair);
+ System.out.println(Arrays.toString(pair.getInputArray()));
+
+ }
+ }
+ }
+}
View
110 src/main/java/org/encog/examples/gui/elementary/DisplayPanel.java
@@ -1,55 +1,55 @@
-/*
- * Encog(tm) Java Examples v3.2
- * http://www.heatonresearch.com/encog/
- * https://github.com/encog/encog-java-examples
- *
- * Copyright 2008-2013 Heaton Research, Inc.
- *
- * 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.
- *
- * For more information on Heaton Research copyrights, licenses
- * and trademarks visit:
- * http://www.heatonresearch.com/copyright
- */
-package org.encog.examples.gui.elementary;
-
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Image;
-
-import javax.swing.JPanel;
-
-public class DisplayPanel extends JPanel {
- private Image currentImage;
-
- public Image getCurrentImage() {
- return currentImage;
- }
-
- public void setCurrentImage(Image currentImage) {
- this.currentImage = currentImage;
- setPreferredSize(new Dimension(this.currentImage.getWidth(null), this.currentImage.getHeight(null)));
- repaint();
- }
-
- public void paint(Graphics g)
- {
- super.paint(g);
- if( this.currentImage!=null ) {
- g.drawImage(this.currentImage, 0, 0, null);
- }
- }
-
-
-
-}
+/*
+ * Encog(tm) Java Examples v3.2
+ * http://www.heatonresearch.com/encog/
+ * https://github.com/encog/encog-java-examples
+ *
+ * Copyright 2008-2013 Heaton Research, Inc.
+ *
+ * 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.
+ *
+ * For more information on Heaton Research copyrights, licenses
+ * and trademarks visit:
+ * http://www.heatonresearch.com/copyright
+ */
+package org.encog.examples.gui.elementary;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Image;
+
+import javax.swing.JPanel;
+
+public class DisplayPanel extends JPanel {
+ private Image currentImage;
+
+ public Image getCurrentImage() {
+ return currentImage;
+ }
+
+ public void setCurrentImage(Image currentImage) {
+ this.currentImage = currentImage;
+ setPreferredSize(new Dimension(this.currentImage.getWidth(null), this.currentImage.getHeight(null)));
+ repaint();
+ }
+
+ public void paint(Graphics g)
+ {
+ super.paint(g);
+ if( this.currentImage!=null ) {
+ g.drawImage(this.currentImage, 0, 0, null);
+ }
+ }
+
+
+
+}
View
406 src/main/java/org/encog/examples/gui/elementary/ElementaryExample.java
@@ -1,203 +1,203 @@
-/*
- * Encog(tm) Java Examples v3.2
- * http://www.heatonresearch.com/encog/
- * https://github.com/encog/encog-java-examples
- *
- * Copyright 2008-2013 Heaton Research, Inc.
- *
- * 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.
- *
- * For more information on Heaton Research copyrights, licenses
- * and trademarks visit:
- * http://www.heatonresearch.com/copyright
- */
-package org.encog.examples.gui.elementary;
-import java.awt.BorderLayout;
-import java.awt.Container;
-import java.awt.FlowLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-
-import org.encog.ca.program.CAProgram;
-import org.encog.ca.program.conway.ConwayProgram;
-import org.encog.ca.program.elementary.ElementaryCA;
-import org.encog.ca.runner.BasicCARunner;
-import org.encog.ca.runner.CARunner;
-import org.encog.ca.universe.Universe;
-import org.encog.ca.universe.UniverseListener;
-import org.encog.ca.universe.basic.BasicCellFactory;
-import org.encog.ca.universe.basic.BasicUniverse;
-import org.encog.ca.visualize.CAVisualizer;
-import org.encog.ca.visualize.basic.BasicCAVisualizer;
-
-public class ElementaryExample extends JFrame implements ActionListener, WindowListener, UniverseListener, ItemListener {
-
- private JTextField ruleText;
- private JTextField sizeText;
- private JButton generateButton;
- private JComboBox zoomCombo;
-
- private JLabel status;
- private CARunner worldRunner;
- private CAVisualizer visualizer;
- private DisplayPanel worldArea;
- private JScrollPane scroll;
- private int zoom = 1;
-
- public ElementaryExample() {
- setSize(500, 500);
- setTitle("Elementary CA");
-
- Container c = getContentPane();
- c.setLayout(new BorderLayout());
- JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
- c.add(buttonPanel, BorderLayout.NORTH);
- c.add(this.status=new JLabel(), BorderLayout.SOUTH);
- buttonPanel.add(new JLabel("Rule:"));
- buttonPanel.add(this.ruleText = new JTextField("110"));
- buttonPanel.add(new JLabel("Size:"));
- buttonPanel.add(this.sizeText = new JTextField("500"));
- buttonPanel.add(generateButton = new JButton("Generate"));
-
- this.worldArea = new DisplayPanel();
- this.scroll = new JScrollPane(this.worldArea);
- c.add(this.scroll, BorderLayout.CENTER);
- generateButton.addActionListener(this);
-
- String[] test = { "1x", "2x", "3x", "5x", "10x" };
- this.zoomCombo = new JComboBox(test);
- buttonPanel.add(new JLabel("Zoom:"));
- buttonPanel.add(zoomCombo);
- zoomCombo.addItemListener(this);
- this.addWindowListener(this);
- }
-
- public void performIteration() {
- this.worldRunner.iteration();
- }
-
- public void performGenerate() {
-
- int rule = Integer.parseInt(ruleText.getText());
- int size = Integer.parseInt(sizeText.getText());
-
- Universe universe = new BasicUniverse((int)(size*1.5),(int)(size*2.5),new BasicCellFactory(1,1));
- CAProgram physics = new ElementaryCA(universe,rule);
-
-
- this.worldRunner = new BasicCARunner(
- universe,
- physics);
-
- for(int i=0;i<size;i++)
- {
- physics.iteration();
- }
-
- this.visualizer = new BasicCAVisualizer(universe);
- this.visualizer.setZoom(this.zoom);
- this.worldArea.setCurrentImage(this.visualizer.visualize());
- }
-
- @Override
- public void actionPerformed(ActionEvent ev) {
- if (ev.getSource() == generateButton) {
- performGenerate();
- }
- }
-
- @Override
- public void windowActivated(WindowEvent arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void windowClosed(WindowEvent arg0) {
-
-
- }
-
- @Override
- public void windowClosing(WindowEvent arg0) {
- //this.worldRunner.stop();
- System.exit(0);
-
- }
-
- @Override
- public void windowDeactivated(WindowEvent arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void windowDeiconified(WindowEvent arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void windowIconified(WindowEvent arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void windowOpened(WindowEvent arg0) {
- //performReset();
- }
-
- @Override
- public void iterationComplete() {
- this.worldArea.setCurrentImage(this.visualizer.visualize());
- String str = this.worldRunner.toString();
- this.status.setText(str);
- repaint();
- }
-
- public static void main(String[] args) {
- try {
- JFrame f = new ElementaryExample();
- f.setVisible(true);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
-
- }
-
- @Override
- public void itemStateChanged(ItemEvent ev) {
- if( ev.getItemSelectable()==this.zoomCombo ) {
- if( ev.getStateChange()==ItemEvent.SELECTED ) {
- String str = ev.getItem().toString();
- zoom = Integer.parseInt(str.substring(0, str.length()-1));
- this.visualizer.setZoom(zoom);
- this.performGenerate();
- }
- }
- }
-}
+/*
+ * Encog(tm) Java Examples v3.2
+ * http://www.heatonresearch.com/encog/
+ * https://github.com/encog/encog-java-examples
+ *
+ * Copyright 2008-2013 Heaton Research, Inc.
+ *
+ * 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.
+ *
+ * For more information on Heaton Research copyrights, licenses
+ * and trademarks visit:
+ * http://www.heatonresearch.com/copyright
+ */
+package org.encog.examples.gui.elementary;
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.encog.ca.program.CAProgram;
+import org.encog.ca.program.conway.ConwayProgram;
+import org.encog.ca.program.elementary.ElementaryCA;
+import org.encog.ca.runner.BasicCARunner;
+import org.encog.ca.runner.CARunner;
+import org.encog.ca.universe.Universe;
+import org.encog.ca.universe.UniverseListener;
+import org.encog.ca.universe.basic.BasicCellFactory;
+import org.encog.ca.universe.basic.BasicUniverse;
+import org.encog.ca.visualize.CAVisualizer;
+import org.encog.ca.visualize.basic.BasicCAVisualizer;
+
+public class ElementaryExample extends JFrame implements ActionListener, WindowListener, UniverseListener, ItemListener {
+
+ private JTextField ruleText;
+ private JTextField sizeText;
+ private JButton generateButton;
+ private JComboBox zoomCombo;
+
+ private JLabel status;
+ private CARunner worldRunner;
+ private CAVisualizer visualizer;
+ private DisplayPanel worldArea;
+ private JScrollPane scroll;
+ private int zoom = 1;
+
+ public ElementaryExample() {
+ setSize(500, 500);
+ setTitle("Elementary CA");
+
+ Container c = getContentPane();
+ c.setLayout(new BorderLayout());
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
+ c.add(buttonPanel, BorderLayout.NORTH);
+ c.add(this.status=new JLabel(), BorderLayout.SOUTH);
+ buttonPanel.add(new JLabel("Rule:"));
+ buttonPanel.add(this.ruleText = new JTextField("110"));
+ buttonPanel.add(new JLabel("Size:"));
+ buttonPanel.add(this.sizeText = new JTextField("500"));
+ buttonPanel.add(generateButton = new JButton("Generate"));
+
+ this.worldArea = new DisplayPanel();
+ this.scroll = new JScrollPane(this.worldArea);
+ c.add(this.scroll, BorderLayout.CENTER);
+ generateButton.addActionListener(this);
+
+ String[] test = { "1x", "2x", "3x", "5x", "10x" };
+ this.zoomCombo = new JComboBox(test);
+ buttonPanel.add(new JLabel("Zoom:"));
+ buttonPanel.add(zoomCombo);
+ zoomCombo.addItemListener(this);
+ this.addWindowListener(this);
+ }
+
+ public void performIteration() {
+ this.worldRunner.iteration();
+ }
+
+ public void performGenerate() {
+
+ int rule = Integer.parseInt(ruleText.getText());
+ int size = Integer.parseInt(sizeText.getText());
+
+ Universe universe = new BasicUniverse((int)(size*1.5),(int)(size*2.5),new BasicCellFactory(1,1));
+ CAProgram physics = new ElementaryCA(universe,rule);
+
+
+ this.worldRunner = new BasicCARunner(
+ universe,
+ physics);
+
+ for(int i=0;i<size;i++)
+ {
+ physics.iteration();
+ }
+
+ this.visualizer = new BasicCAVisualizer(universe);
+ this.visualizer.setZoom(this.zoom);
+ this.worldArea.setCurrentImage(this.visualizer.visualize());
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent ev) {
+ if (ev.getSource() == generateButton) {
+ performGenerate();
+ }
+ }
+
+ @Override
+ public void windowActivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowClosed(WindowEvent arg0) {
+
+
+ }
+
+ @Override
+ public void windowClosing(WindowEvent arg0) {
+ //this.worldRunner.stop();
+ System.exit(0);
+
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowDeiconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowIconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowOpened(WindowEvent arg0) {
+ //performReset();
+ }
+
+ @Override
+ public void iterationComplete() {
+ this.worldArea.setCurrentImage(this.visualizer.visualize());
+ String str = this.worldRunner.toString();
+ this.status.setText(str);
+ repaint();
+ }
+
+ public static void main(String[] args) {
+ try {
+ JFrame f = new ElementaryExample();
+ f.setVisible(true);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ }
+
+ @Override
+ public void itemStateChanged(ItemEvent ev) {
+ if( ev.getItemSelectable()==this.zoomCombo ) {
+ if( ev.getStateChange()==ItemEvent.SELECTED ) {
+ String str = ev.getItem().toString();
+ zoom = Integer.parseInt(str.substring(0, str.length()-1));
+ this.visualizer.setZoom(zoom);
+ this.performGenerate();
+ }
+ }
+ }
+}
View
144 src/main/java/org/encog/examples/gui/generic/GenericBatch.java
@@ -1,72 +1,72 @@
-/*
- * Encog(tm) Java Examples v3.2
- * http://www.heatonresearch.com/encog/
- * https://github.com/encog/encog-java-examples
- *
- * Copyright 2008-2013 Heaton Research, Inc.
- *
- * 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.
- *
- * For more information on Heaton Research copyrights, licenses
- * and trademarks visit:
- * http://www.heatonresearch.com/copyright
- */
-package org.encog.examples.gui.generic;
-
-import java.io.File;
-
-import org.encog.ca.program.CAProgram;
-import org.encog.ca.program.generic.GenericCA;
-import org.encog.ca.program.generic.GenericIO;
-import org.encog.ca.runner.BasicCARunner;
-import org.encog.ca.runner.CARunner;
-import org.encog.ca.universe.Universe;
-import org.encog.ca.universe.basic.BasicCellFactory;
-import org.encog.ca.universe.basic.BasicUniverse;
-
-public class GenericBatch {
-
- public static void main(String[] args) {
- Universe universe = new BasicUniverse(500,500,new BasicCellFactory(3,-1,1));
- universe.randomize();
- CAProgram physics = new GenericCA(universe,5);
- physics.randomize();
-
- CARunner runner = new BasicCARunner(
- universe,
- physics);
-
- //this.visualizer = new BasicCAVisualizer(theUniverse);
- //this.worldArea.setCurrentImage(this.visualizer.visualize());
-
- int t = 0;
-
- for (;;) {
- universe.randomize();
- physics.randomize();
- String status = "fail";
- int iterations = runner.runToConverge(100,0.1);
- if( iterations>=100 && runner.getScore()>0.0 ) {
- save(runner,t);
- status = "save";
- }
- System.out.println("Try: " + t + " , Iterations: " + iterations + ", Score: " + runner.getScore() + ", Status:" + status);
- t++;
- }
- }
-
- private static void save(CARunner runner, int t) {
- File f = new File("d:\\test\\world-"+t+".bin");
- GenericIO.save(runner, f);
- }
-}
+/*
+ * Encog(tm) Java Examples v3.2
+ * http://www.heatonresearch.com/encog/
+ * https://github.com/encog/encog-java-examples
+ *
+ * Copyright 2008-2013 Heaton Research, Inc.
+ *
+ * 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.
+ *
+ * For more information on Heaton Research copyrights, licenses
+ * and trademarks visit:
+ * http://www.heatonresearch.com/copyright
+ */
+package org.encog.examples.gui.generic;
+
+import java.io.File;
+
+import org.encog.ca.program.CAProgram;
+import org.encog.ca.program.generic.GenericCA;
+import org.encog.ca.program.generic.GenericIO;
+import org.encog.ca.runner.BasicCARunner;
+import org.encog.ca.runner.CARunner;
+import org.encog.ca.universe.Universe;
+import org.encog.ca.universe.basic.BasicCellFactory;
+import org.encog.ca.universe.basic.BasicUniverse;
+
+public class GenericBatch {
+
+ public static void main(String[] args) {
+ Universe universe = new BasicUniverse(500,500,new BasicCellFactory(3,-1,1));
+ universe.randomize();
+ CAProgram physics = new GenericCA(universe,5);
+ physics.randomize();
+
+ CARunner runner = new BasicCARunner(
+ universe,
+ physics);
+
+ //this.visualizer = new BasicCAVisualizer(theUniverse);
+ //this.worldArea.setCurrentImage(this.visualizer.visualize());
+
+ int t = 0;
+
+ for (;;) {
+ universe.randomize();
+ physics.randomize();
+ String status = "fail";
+ int iterations = runner.runToConverge(100,0.1);
+ if( iterations>=100 && runner.getScore()>0.0 ) {
+ save(runner,t);
+ status = "save";
+ }
+ System.out.println("Try: " + t + " , Iterations: " + iterations + ", Score: " + runner.getScore() + ", Status:" + status);
+ t++;
+ }
+ }
+
+ private static void save(CARunner runner, int t) {
+ File f = new File("d:\\test\\world-"+t+".bin");
+ GenericIO.save(runner, f);
+ }
+}
View
558 src/main/java/org/encog/examples/gui/generic/GenericExample.java
@@ -1,279 +1,279 @@
-/*
- * Encog(tm) Java Examples v3.2
- * http://www.heatonresearch.com/encog/
- * https://github.com/encog/encog-java-examples
- *
- * Copyright 2008-2013 Heaton Research, Inc.
- *
- * 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.
- *
- * For more information on Heaton Research copyrights, licenses
- * and trademarks visit:
- * http://www.heatonresearch.com/copyright
- */
-package org.encog.examples.gui.generic;
-import java.awt.BorderLayout;
-import java.awt.Container;
-import java.awt.FlowLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.io.File;
-
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-
-import org.encog.ca.program.CAProgram;
-import org.encog.ca.program.generic.GenericCA;
-import org.encog.ca.program.generic.GenericIO;
-import org.encog.ca.runner.BasicCARunner;
-import org.encog.ca.runner.CARunner;
-import org.encog.ca.universe.Universe;
-import org.encog.ca.universe.UniverseListener;
-import org.encog.ca.universe.basic.BasicCellFactory;
-import org.encog.ca.universe.basic.BasicUniverse;
-import org.encog.ca.visualize.CAVisualizer;
-import org.encog.ca.visualize.basic.BasicCAVisualizer;
-import org.encog.persist.EncogDirectoryPersistence;
-
-public class GenericExample extends JFrame implements ActionListener, WindowListener, UniverseListener, ItemListener {
-
- private JButton iterationButton;
- private JButton startButton;
- private JButton stopButton;
- private JButton resetButton;
- private JButton loadButton;
- private JButton saveButton;
- private JComboBox zoomCombo;
-
- private JLabel status;
- private CARunner worldRunner;
- private CAVisualizer visualizer;
- private GenericPanel worldArea;
- private JScrollPane scroll;
-
- public GenericExample() {
- setSize(500, 500);
- setTitle("Generic Game of Life");
-
- Container c = getContentPane();
- c.setLayout(new BorderLayout());
- JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
- c.add(buttonPanel, BorderLayout.NORTH);
- c.add(this.status=new JLabel(), BorderLayout.SOUTH);
- buttonPanel.add(iterationButton = new JButton("Iteration"));
- buttonPanel.add(startButton = new JButton("Start"));
- buttonPanel.add(stopButton = new JButton("Stop"));
- buttonPanel.add(resetButton = new JButton("Reset"));
- buttonPanel.add(loadButton = new JButton("Load"));
- buttonPanel.add(saveButton = new JButton("Save"));
-
- this.worldArea = new GenericPanel();
- this.scroll = new JScrollPane(this.worldArea);
- c.add(this.scroll, BorderLayout.CENTER);
- iterationButton.addActionListener(this);
- startButton.addActionListener(this);
- stopButton.addActionListener(this);
- resetButton.addActionListener(this);
- loadButton.addActionListener(this);
- saveButton.addActionListener(this);
-
- String[] test = { "1x", "2x", "3x", "5x", "10x" };
- this.zoomCombo = new JComboBox(test);
- buttonPanel.add(new JLabel("Zoom:"));
- buttonPanel.add(zoomCombo);
- zoomCombo.addItemListener(this);
- this.addWindowListener(this);
-
- this.stopButton.setEnabled(false);
-
- Universe universe = new BasicUniverse(500,500,new BasicCellFactory(3,-1,1));
- CAProgram physics = new GenericCA(universe,5);
-
- this.worldRunner = new BasicCARunner(
- universe,
- physics);
- this.worldRunner.addListener(this);
- this.visualizer = new BasicCAVisualizer(universe);
- this.worldArea.setCurrentImage(this.visualizer.visualize());
-
- performReset();
- }
-
- public void performIteration() {
- this.worldRunner.iteration();
- }
-
- public void performStart() {
- this.iterationButton.setEnabled(false);
- this.stopButton.setEnabled(true);
- this.startButton.setEnabled(false);
- this.loadButton.setEnabled(false);
- this.saveButton.setEnabled(false);
- this.worldRunner.start();
- }
-
- public void performStop() {
- this.iterationButton.setEnabled(true);
- this.stopButton.setEnabled(false);
- this.startButton.setEnabled(true);
- this.loadButton.setEnabled(true);
- this.saveButton.setEnabled(true);
- this.worldRunner.stop();
- }
-
- public void performReset() {
- boolean shouldRestart = false;
-
- if( this.worldRunner!=null && this.worldRunner.isRunning() ) {
- shouldRestart = true;
- performStop();
- }
-
- this.worldRunner.reset();
-
- if( shouldRestart ) {
- performStart();
- }
- }
-
-
- public void performLoad() {
- final JFileChooser fc = new JFileChooser();
- int rc = fc.showOpenDialog(this);
- if( rc == JFileChooser.APPROVE_OPTION ) {
- File f = fc.getSelectedFile();
- GenericIO.load(f, this.worldRunner);
- this.visualizer = new BasicCAVisualizer(this.worldRunner.getUniverse());
- this.worldArea.setCurrentImage(this.visualizer.visualize());
- }
- }
-
- public void performSave() {
- final JFileChooser fc = new JFileChooser();
- int rc = fc.showSaveDialog(this);
- if( rc == JFileChooser.APPROVE_OPTION ) {
- File f = fc.getSelectedFile();
- GenericIO.save(this.worldRunner, f);
- }
- }
-
- @Override
- public void actionPerformed(ActionEvent ev) {
- if (ev.getSource() == iterationButton) {
- performIteration();
- } else if (ev.getSource() == startButton) {
- performStart();
- } else if (ev.getSource() == stopButton) {
- performStop();
- } else if (ev.getSource() == resetButton) {
- performReset();
- } else if (ev.getSource() == saveButton) {
- performSave();
- } else if (ev.getSource() == loadButton) {
- performLoad();
- }
-
- }
-
- @Override
- public void windowActivated(WindowEvent arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void windowClosed(WindowEvent arg0) {
-
-
- }
-
- @Override
- public void windowClosing(WindowEvent arg0) {
- this.worldRunner.stop();
- System.exit(0);
-
- }
-
- @Override
- public void windowDeactivated(WindowEvent arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void windowDeiconified(WindowEvent arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void windowIconified(WindowEvent arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void windowOpened(WindowEvent arg0) {
- performReset();
- }
-
- @Override
- public void iterationComplete() {
- this.worldArea.setCurrentImage(this.visualizer.visualize());
- String str = this.worldRunner.toString();
- this.status.setText(str);
- repaint();
- }
-
- public static void main(String[] args) {
- try {
- JFrame f = new GenericExample();
- f.setVisible(true);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
-
- }
-
- @Override
- public void itemStateChanged(ItemEvent ev) {
- if( ev.getItemSelectable()==this.zoomCombo ) {
- if( ev.getStateChange()==ItemEvent.SELECTED ) {
- boolean shouldRestart = false;
-
- if( this.worldRunner!=null && this.worldRunner.isRunning() ) {
- shouldRestart = true;
- performStop();
- }
-
- String str = ev.getItem().toString();
- int zoom = Integer.parseInt(str.substring(0, str.length()-1));
- this.visualizer.setZoom(zoom);
-
- if( shouldRestart ) {
- performStart();
- }
- }
- }
- }
-}
+/*
+ * Encog(tm) Java Examples v3.2
+ * http://www.heatonresearch.com/encog/
+ * https://github.com/encog/encog-java-examples
+ *
+ * Copyright 2008-2013 Heaton Research, Inc.
+ *
+ * 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.
+ *
+ * For more information on Heaton Research copyrights, licenses
+ * and trademarks visit:
+ * http://www.heatonresearch.com/copyright
+ */
+package org.encog.examples.gui.generic;
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import java.io.File;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+
+import org.encog.ca.program.CAProgram;
+import org.encog.ca.program.generic.GenericCA;
+import org.encog.ca.program.generic.GenericIO;
+import org.encog.ca.runner.BasicCARunner;
+import org.encog.ca.runner.CARunner;
+import org.encog.ca.universe.Universe;
+import org.encog.ca.universe.UniverseListener;
+import org.encog.ca.universe.basic.BasicCellFactory;
+import org.encog.ca.universe.basic.BasicUniverse;
+import org.encog.ca.visualize.CAVisualizer;
+import org.encog.ca.visualize.basic.BasicCAVisualizer;
+import org.encog.persist.EncogDirectoryPersistence;
+
+public class GenericExample extends JFrame implements ActionListener, WindowListener, UniverseListener, ItemListener {
+
+ private JButton iterationButton;
+ private JButton startButton;
+ private JButton stopButton;
+ private JButton resetButton;
+ private JButton loadButton;
+ private JButton saveButton;
+ private JComboBox zoomCombo;
+
+ private JLabel status;
+ private CARunner worldRunner;
+ private CAVisualizer visualizer;
+ private GenericPanel worldArea;
+ private JScrollPane scroll;
+
+ public GenericExample() {
+ setSize(500, 500);
+ setTitle("Generic Game of Life");
+
+ Container c = getContentPane();
+ c.setLayout(new BorderLayout());
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
+ c.add(buttonPanel, BorderLayout.NORTH);
+ c.add(this.status=new JLabel(), BorderLayout.SOUTH);
+ buttonPanel.add(iterationButton = new JButton("Iteration"));
+ buttonPanel.add(startButton = new JButton("Start"));
+ buttonPanel.add(stopButton = new JButton("Stop"));
+ buttonPanel.add(resetButton = new JButton("Reset"));
+ buttonPanel.add(loadButton = new JButton("Load"));
+ buttonPanel.add(saveButton = new JButton("Save"));
+
+ this.worldArea = new GenericPanel();
+ this.scroll = new JScrollPane(this.worldArea);
+ c.add(this.scroll, BorderLayout.CENTER);
+ iterationButton.addActionListener(this);
+ startButton.addActionListener(this);
+ stopButton.addActionListener(this);
+ resetButton.addActionListener(this);
+ loadButton.addActionListener(this);
+ saveButton.addActionListener(this);
+
+ String[] test = { "1x", "2x", "3x", "5x", "10x" };
+ this.zoomCombo = new JComboBox(test);
+ buttonPanel.add(new JLabel("Zoom:"));
+ buttonPanel.add(zoomCombo);
+ zoomCombo.addItemListener(this);
+ this.addWindowListener(this);
+
+ this.stopButton.setEnabled(false);
+
+ Universe universe = new BasicUniverse(500,500,new BasicCellFactory(3,-1,1));
+ CAProgram physics = new GenericCA(universe,5);
+
+ this.worldRunner = new BasicCARunner(
+ universe,
+ physics);
+ this.worldRunner.addListener(this);
+ this.visualizer = new BasicCAVisualizer(universe);
+ this.worldArea.setCurrentImage(this.visualizer.visualize());
+
+ performReset();
+ }
+
+ public void performIteration() {
+ this.worldRunner.iteration();
+ }
+
+ public void performStart() {
+ this.iterationButton.setEnabled(false);
+ this.stopButton.setEnabled(true);
+ this.startButton.setEnabled(false);
+ this.loadButton.setEnabled(false);
+ this.saveButton.setEnabled(false);
+ this.worldRunner.start();
+ }
+
+ public void performStop() {
+ this.iterationButton.setEnabled(true);
+ this.stopButton.setEnabled(false);
+ this.startButton.setEnabled(true);
+ this.loadButton.setEnabled(true);
+ this.saveButton.setEnabled(true);
+ this.worldRunner.stop();
+ }
+
+ public void performReset() {
+ boolean shouldRestart = false;
+
+ if( this.worldRunner!=null && this.worldRunner.isRunning() ) {
+ shouldRestart = true;
+ performStop();
+ }
+
+ this.worldRunner.reset();
+
+ if( shouldRestart ) {
+ performStart();
+ }
+ }
+
+
+ public void performLoad() {
+ final JFileChooser fc = new JFileChooser();
+ int rc = fc.showOpenDialog(this);
+ if( rc == JFileChooser.APPROVE_OPTION ) {
+ File f = fc.getSelectedFile();
+ GenericIO.load(f, this.worldRunner);
+ this.visualizer = new BasicCAVisualizer(this.worldRunner.getUniverse());
+ this.worldArea.setCurrentImage(this.visualizer.visualize());
+ }
+ }
+
+ public void performSave() {
+ final JFileChooser fc = new JFileChooser();
+ int rc = fc.showSaveDialog(this);
+ if( rc == JFileChooser.APPROVE_OPTION ) {
+ File f = fc.getSelectedFile();
+ GenericIO.save(this.worldRunner, f);
+ }
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent ev) {
+ if (ev.getSource() == iterationButton) {
+ performIteration();
+ } else if (ev.getSource() == startButton) {
+ performStart();
+ } else if (ev.getSource() == stopButton) {
+ performStop();
+ } else if (ev.getSource() == resetButton) {
+ performReset();
+ } else if (ev.getSource() == saveButton) {
+ performSave();
+ } else if (ev.getSource() == loadButton) {
+ performLoad();
+ }
+
+ }
+
+ @Override
+ public void windowActivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowClosed(WindowEvent arg0) {
+
+
+ }
+
+ @Override
+ public void windowClosing(WindowEvent arg0) {
+ this.worldRunner.stop();
+ System.exit(0);
+
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowDeiconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowIconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowOpened(WindowEvent arg0) {
+ performReset();
+ }
+
+ @Override
+ public void iterationComplete() {
+ this.worldArea.setCurrentImage(this.visualizer.visualize());
+ String str = this.worldRunner.toString();
+ this.status.setText(str);
+ repaint();
+ }
+
+ public static void main(String[] args) {
+ try {
+ JFrame f = new GenericExample();
+ f.setVisible(true);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ }
+
+ @Override
+ public void itemStateChanged(ItemEvent ev) {
+ if( ev.getItemSelectable()==this.zoomCombo ) {
+ if( ev.getStateChange()==ItemEvent.SELECTED ) {
+ boolean shouldRestart = false;
+
+ if( this.worldRunner!=null && this.worldRunner.isRunning() ) {
+ shouldRestart = true;
+ performStop();
+ }
+
+ String str = ev.getItem().toString();
+ int zoom = Integer.parseInt(str.substring(0, str.length()-1));
+ this.visualizer.setZoom(zoom);
+
+ if( shouldRestart ) {
+ performStart();
+ }
+ }
+ }
+ }
+}
View
110 src/main/java/org/encog/examples/gui/generic/GenericPanel.java
@@ -1,55 +1,55 @@
-/*
- * Encog(tm) Java Examples v3.2
- * http://www.heatonresearch.com/encog/
- * https://github.com/encog/encog-java-examples
- *
- * Copyright 2008-2013 Heaton Research, Inc.
- *
- * 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.
- *
- * For more information on Heaton Research copyrights, licenses
- * and trademarks visit:
- * http://www.heatonresearch.com/copyright
- */
-package org.encog.examples.gui.generic;
-
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Image;
-
-import javax.swing.JPanel;
-
-public class GenericPanel extends JPanel {
- private Image currentImage;
-
- public Image getCurrentImage() {
- return currentImage;
- }
-
- public void setCurrentImage(Image currentImage) {
- this.currentImage = currentImage;
- setPreferredSize(new Dimension(this.currentImage.getWidth(null), this.currentImage.getHeight(null)));
- repaint();
- }
-
- public void paint(Graphics g)
- {
- super.paint(g);
- if( this.currentImage!=null ) {
- g.drawImage(this.currentImage, 0, 0, null);
- }
- }
-
-
-
-}
+/*
+ * Encog(tm) Java Examples v3.2
+ * http://www.heatonresearch.com/encog/
+ * https://github.com/encog/encog-java-examples
+ *
+ * Copyright 2008-2013 Heaton Research, Inc.
+ *
+ * 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.
+ *
+ * For more information on Heaton Research copyrights, licenses
+ * and trademarks visit:
+ * http://www.heatonresearch.com/copyright
+ */
+package org.encog.examples.gui.generic;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Image;
+
+import javax.swing.JPanel;
+
+public class GenericPanel extends JPanel {
+ private Image currentImage;
+
+ public Image getCurrentImage() {
+ return currentImage;
+ }
+
+ public void setCurrentImage(Image currentImage) {
+ this.currentImage = currentImage;
+ setPreferredSize(new Dimension(this.currentImage.getWidth(null), this.currentImage.getHeight(null)));
+ repaint();
+ }
+
+ public void paint(Graphics g)
+ {
+ super.paint(g);
+ if( this.currentImage!=null ) {
+ g.drawImage(this.currentImage, 0, 0, null);
+ }
+ }
+
+
+
+}
View
558 src/main/java/org/encog/examples/gui/life/GameOfLife.java
@@ -1,279 +1,279 @@
-/*
- * Encog(tm) Java Examples v3.2
- * http://www.heatonresearch.com/encog/
- * https://github.com/encog/encog-java-examples
- *
- * Copyright 2008-2013 Heaton Research, Inc.
- *
- * 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.
- *
- * For more information on Heaton Research copyrights, licenses
- * and trademarks visit:
- * http://www.heatonresearch.com/copyright
- */
-package org.encog.examples.gui.life;
-import java.awt.BorderLayout;
-import java.awt.Container;
-import java.awt.FlowLayout;
-import java.awt.event.ActionEvent</