Package model

Examples of model.SpeciesType


                SpeciesZoneType szt = null;

                for (ManipulationTimestepInfo speciesInfo : infos) {
                    if (speciesInfo.getTimestepIdx() == timestep) {
                        //add new species if not existing
                        SpeciesType speciesType = GameServer.getInstance().getSpeciesTypeByNodeID(speciesInfo.getNodeIdx());

                        double biomass = speciesInfo.getBiomass() * Constants.BIOMASS_SCALE;
                        int count = biomass < 1 ? 0 : (int) Math.ceil(biomass / speciesType.getAvgBiomass());

                        if (!mSpecies.containsKey(speciesInfo.getNodeIdx())) {
                            SpeciesTypeEnum group_type = SpeciesTypeEnum.ANIMAL;
                            if (speciesType.getGroupType() == Constants.ORGANISM_TYPE_PLANT) {
                                group_type = SpeciesTypeEnum.PLANT;
                            }

                            szt = new SpeciesZoneType(speciesInfo.getNodeName(), speciesInfo.getNodeIdx(), count, speciesType.getAvgBiomass(), biomass, group_type);
                            szt.setTrophicLevel(speciesType.getTrophicLevel());

                            //HJR
                            //Added these two lines to pass the prey and predator index to web services
                            szt.setlPredatorIndex(speciesType.getPredatorIndex());
                            szt.setlPreyIndex(speciesType.getPreyIndex());
                           
                            if (group_type == SpeciesTypeEnum.ANIMAL) {
                                szt.setParamX(((AnimalType) speciesType).getMetabolism());
                            }

View Full Code Here


        HashMap<Integer, SpeciesZoneType> mUpdateSpecies = new HashMap<Integer, SpeciesZoneType>();

        SpeciesZoneType szt = null;

        for (int node_id : nodeList.keySet()) {
            SpeciesType speciesType = GameServer.getInstance().getSpeciesTypeByNodeID(node_id);
            int count = nodeList.get(node_id);

            //NEW SPECIES
            if (!mSpecies.containsKey(node_id)) {
                SpeciesTypeEnum group_type = SpeciesTypeEnum.ANIMAL;
                if (speciesType.getGroupType() == Constants.ORGANISM_TYPE_PLANT) {
                    group_type = SpeciesTypeEnum.PLANT;
                }

                szt = new SpeciesZoneType(speciesType.getType(), node_id, count, speciesType.getAvgBiomass(), speciesType.getAvgBiomass() * count, group_type);
                szt.setTrophicLevel(speciesType.getTrophicLevel());
                //HJR Added these two lines to pass the prey and predator index to web services
                szt.setlPredatorIndex(speciesType.getPredatorIndex());
                szt.setlPreyIndex(speciesType.getPreyIndex());
               
                if (group_type == SpeciesTypeEnum.ANIMAL) {
                    szt.setParamX(((AnimalType) speciesType).getMetabolism());
                }

View Full Code Here

       

    public SpeciesZoneType createSpecies(int node_id) {
        SpeciesZoneType szt = null;
        SpeciesType speciesType = GameServer.getInstance().getSpeciesTypeByNodeID(node_id);

        SpeciesTypeEnum group_type = SpeciesTypeEnum.ANIMAL;
        if (speciesType.getGroupType() == Constants.ORGANISM_TYPE_PLANT) {
            group_type = SpeciesTypeEnum.PLANT;
        }

        szt = new SpeciesZoneType(speciesType.getSpeciesName(), node_id, 1, speciesType.getAvgBiomass(), speciesType.getAvgBiomass(), group_type);
        szt.setTrophicLevel(speciesType.getTrophicLevel());

        return szt;
    }
View Full Code Here

        totalNodeList = new HashMap<Integer, Integer>();
        totalSpeciesList = new HashMap<Integer, Integer>();

        for (Organism organism : organismList) {
            SpeciesType species = organism.getSpeciesType();

            for (int node_id : species.getNodeList()) {
                Integer count = totalNodeList.get(node_id);

                if (count == null) {
                    totalNodeList.put(node_id, organism.getGroupSize() * species.getNodeAmount(node_id));
                } else {
                    totalNodeList.put(node_id, count + organism.getGroupSize() * species.getNodeAmount(node_id));
                }
            }

            int species_id = organism.getSpeciesTypeID();

View Full Code Here

            List<Integer> speciesList = new ArrayList<Integer>(totalSpeciesList.keySet());
            Collections.shuffle(speciesList);

            for (int species_id : speciesList) {
                SpeciesType species = GameServer.getInstance().getSpecies(species_id);

                int gDiff = 0, rDiff = 0;
                boolean hasGrowth = true, hasReduced = true;

                for (int node_id : species.getNodeList()) {
                    int diff = speciesDifference.get(node_id) / species.getNodeAmount(node_id);

                    // Check Growth
                    if (diff > 0) {
                        gDiff = gDiff == 0 ? diff : Math.min(diff, gDiff);
                    } else {
                        hasGrowth = false;
                    }

                    // Check Reduction
                    if (diff < 0) {
                        rDiff = rDiff == 0 ? diff : Math.max(diff, rDiff);
                    } else {
                        hasReduced = false;
                    }
                }

                if (hasGrowth) {
                    System.out.println("  " + species.getSpeciesName() + " Species[" + species.getID() + "] increased by " + gDiff);

                    for (int node_id : species.getNodeList()) {
                        int amount = gDiff * species.getNodeAmount(node_id);
                        speciesDifference.put(node_id, speciesDifference.get(node_id) - amount);

                        System.out.println("    Node[" + node_id + "] increased by " + amount);
                    }

                    gameEngine.createOrganismsByBirth(species.getID(), zone.getID(), gDiff);
                } else if (hasReduced) {
                    System.out.println("  " + species.getSpeciesName() + " Species[" + species.getID() + "] decreased by " + Math.abs(rDiff));

                    for (int node_id : species.getNodeList()) {
                        int amount = rDiff * species.getNodeAmount(node_id);
                        speciesDifference.put(node_id, speciesDifference.get(node_id) - amount);

                        System.out.println("    Node[" + node_id + "] decreased by " + Math.abs(amount));
                    }

                    gameEngine.removeOrganismsByDeath(species.getID(), zone.getID(), Math.abs(rDiff));
                }
            }

            ZoneDAO.updateBiomass(zone.getID(), zone.getMaxBiomass(), zone.getPrevBiomass(), zone.getTotalBiomass());

View Full Code Here

    public PlantType getPlantType(int plantTypeID) {
        return plantTypes.get(plantTypeID);
    }

    public SpeciesType getSpecies(int species_id) {
        SpeciesType species = null;

        if (plantTypes.containsKey(species_id)) {
            species = plantTypes.get(species_id);
        } else if (animalTypes.containsKey(species_id)) {
            species = animalTypes.get(species_id);
View Full Code Here

        for (int i = 1; i < nameList.length; i++) {
            String name = nameList[i];
            int node_id = Integer.valueOf(name.substring(name.indexOf("[") + 1, name.lastIndexOf("]")));

            SpeciesType species = GameServer.getInstance().getSpeciesTypeByNodeID(node_id);
            nameList[i] = "\"" + species.getSpeciesName() + "\"";
        }

        tempCSV[0] = Arrays.toString(nameList).replaceAll(", ", ",");
        tempCSV[0] = tempCSV[0].substring(1, tempCSV[0].length() - 1) + "\n";
View Full Code Here

        for (int i = 1; i < someList.get(0).length; i++) {
            String name = someList.get(0)[i];
            int node_id = Integer.valueOf(name.substring(name.indexOf("[") + 1, name.lastIndexOf("]")));

            SpeciesType species = GameServer.getInstance().getSpeciesTypeByNodeID(node_id);
            speciesList.add(species);

            someList.get(0)[i] = "\"" + species.getSpeciesName() + "\"";
        }

        for (int i = 1; i < someList.size(); i++) {
            String[] item = someList.get(i);
View Full Code Here

        return organismList;
    }

    public void addOrganism(Organism organism, int count, long gameScaleTime) {
        for (int node_id : organism.getSpeciesType().getNodeList()) {
            SpeciesType species = GameServer.getInstance().getSpeciesTypeByNodeID(node_id);

            if (species != null) {
                int amount = count * species.getNodeAmount(node_id);
                setTotalBiomass((float) (totalBiomass + species.getAvgBiomass() * amount));
            }
        }

        organismTimeAddedList.put(organism.getID(), gameScaleTime);

View Full Code Here

        updateEnvironmentScore();
    }

    public void removeOrganism(Organism organism, int count, long gameScaleTime) {
        for (int node_id : organism.getSpeciesType().getNodeList()) {
            SpeciesType species = GameServer.getInstance().getSpeciesTypeByNodeID(node_id);

            if (species != null) {
                int amount = count * species.getNodeAmount(node_id);
                setTotalBiomass((float) Math.max(0, totalBiomass - species.getAvgBiomass() * amount));
            }
        }

        organism.setGroupSize(organism.getGroupSize() - count);

View Full Code Here

TOP

Related Classes of model.SpeciesType

Copyright © 2018 www.massapicom. 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.