Examples of PlantUniverseCell


Examples of com.heatonresearch.aifh.examples.capstone.alife.milestone1.PlantUniverseCell

            }
        }

        for (int row = 0; row < PlantUniverse.UNIVERSE_HEIGHT; row++) {
            for (int col = 0; col < PlantUniverse.UNIVERSE_WIDTH; col++) {
                PlantUniverseCell cell = universe.getCell(row, col);

                // see if we want to change the composition
                if (row < PlantUniverse.GROUND_LINE) {
                    double[] cellVec = universe.getCellInfoVector(row, col);
                    double d1 = dist.calculate(cellVec, 0, genome, 0, PlantUniverse.CELL_VECTOR_LENGTH);
                    double d2 = dist.calculate(cellVec, 0, genome, PlantUniverse.CELL_VECTOR_LENGTH, PlantUniverse.CELL_VECTOR_LENGTH);

                    if (d1 < d2) {
                        cell.setLeafyness(cell.getLeafyness() * PlantUniverse.STEM_TRANSITION);
                    }
                }

                // Evaluate growth into each neighbor cell
                if (universe.canGrow(row, col)) {
                    evaluateNeighbors(universe, row, col, genome, allowRoot, allowSurface);
                }
            }
        }

        // Copy the new composition back to the universe
        for (int row = 0; row < PlantUniverse.UNIVERSE_HEIGHT; row++) {
            for (int col = 0; col < PlantUniverse.UNIVERSE_WIDTH; col++) {
                PlantUniverseCell cell = universe.getCell(row, col);

                if (this.newComposition[row][col]) {
                    if (row >= PlantUniverse.GROUND_LINE) {
                        // Roots are always 100% stem for transfer.
                        cell.setLeafyness(0);
                    } else {
                        cell.setLeafyness(1.0);
                    }
                    cell.setEnergy(1.0);
                    cell.setNourishment(1.0);
                }
            }
        }
    }
View Full Code Here

Examples of com.heatonresearch.aifh.examples.capstone.alife.milestone1.PlantUniverseCell

                } else {
                    // no decay until otherwise calculated
                    decay = 1;
                }

                PlantUniverseCell cell = universe.getCell(row, col);
                cell.setCalculatedSunlight(sunlight[col]);

                // Collect resources for live cells
                if (cell.isAlive()) {
                    // Live cells cause the sunlight to decay (shade)
                    decay *= PlantUniverse.DECAY * cell.getLeafyness();

                    // Set the energy based on sunlight level and composition of the live cell
                    double myEnergy = cell.getCalculatedSunlight() * cell.getLeafyness();
                    double transEnergy = universe.calculateTransferEnergy(row, col) * (1.0 - cell.getLeafyness());
                    double e = Math.max(myEnergy, transEnergy);
                    e = Math.max(PlantUniverse.MIN_LIVING_ENERGY, e);
                    cell.setEnergy(e);
                }

                sunlight[col] *= decay;

            }
View Full Code Here

Examples of com.heatonresearch.aifh.examples.capstone.alife.milestone1.PlantUniverseCell

                } else {
                    // no decay until otherwise calculated
                    decay = 1;
                }

                PlantUniverseCell cell = universe.getCell(row, col);
                cell.setCalculatedWater(waterTable[col]);

                // Collect resources for live cells
                if (cell.isAlive()) {
                    // Live cells cause the water to decay (roots collect)
                    decay *= PlantUniverse.DECAY;

                    // Set the energy based on sunlight level and composition of the live cell
                    double myWater = cell.getCalculatedWater() * cell.getLeafyness();
                    double transWater = universe.calculateTransferNourishment(row, col) * (1.0 - cell.getLeafyness());
                    double n = Math.max(myWater, transWater);
                    n = Math.max(PlantUniverse.MIN_LIVING_ENERGY, n);
                    cell.setNourishment(n);

                    // update the root and surface counts
                    if (row >= PlantUniverse.GROUND_LINE) {
                        rootCount += cell.getNourishment();
                    } else {
                        surfaceCount += cell.getLeafyness();
                    }
                }

                waterTable[col] *= decay;

View Full Code Here

Examples of com.heatonresearch.aifh.examples.capstone.alife.milestone1.PlantUniverseCell

        // Count the amount of green.
        int count = 0;
        double sum = 0;
        for (int row = 0; row < PlantUniverse.UNIVERSE_HEIGHT; row++) {
            for (int col = 0; col < PlantUniverse.UNIVERSE_WIDTH; col++) {
                PlantUniverseCell cell = universe.getCell(row, col);
                if (cell.isAlive()) {
                    if (row >= PlantUniverse.GROUND_LINE) {
                        sum += 0.5;
                    } else {
                        sum += cell.getLeafyness();
                    }
                }
                count++;
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.