/*
* Encog(tm) Core v3.4 - Java Version
* http://www.heatonresearch.com/encog/
* https://github.com/encog/encog-java-core
* Copyright 2008-2016 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.ca.universe.basic;
import java.io.Serializable;
import org.encog.ca.CellularAutomataError;
import org.encog.ca.universe.Universe;
import org.encog.ca.universe.UniverseCell;
import org.encog.ca.universe.UniverseCellFactory;
import org.encog.ml.BasicML;
public class BasicUniverse extends BasicML implements Universe, Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
public static final String ELEMENT_COUNT = "elementCount";
private final UniverseCell[][] data;
private final UniverseCellFactory cellFactory;
public BasicUniverse(int height, int width, UniverseCellFactory theCellFactory)
{
this.data = new UniverseCell[height][width];
this.cellFactory = theCellFactory;
for(int row = 0; row10) {
result++;
}
total++;
}
}
return (double)result/(double)total;
}
public int getColumns() {
return this.data[0].length;
}
public int getRows() {
return this.data.length;
}
public void randomize() {
for (int row = 0; row < getRows(); row++) {
for (int col = 0; col < getColumns(); col++) {
for (int i = 0; i < 3; i++) {
this.data[row][col].randomize();
}
}
}
}
public UniverseCell get(int row, int col) {
return this.data[row][col];
}
public boolean isValid(int row, int col) {
if( row<0 || col<0 || row>=getRows() || col>=getColumns()) {
return false;
}
return true;
}
public UniverseCellFactory getCellFactory() {
return cellFactory;
}
@Override
public void updateProperties() {
// TODO Auto-generated method stub
}
@Override
public double calculatePercentInvalid() {
int result = 0;
int total = 0;
for(int row = 0; row1 ) {
result++;
}
total++;
}
}
}
return (double)result/(double)total;
}
}
Ads help maintain this website.