-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All working, some errors still being handled so need fixing
- Loading branch information
1 parent
019831f
commit 0451893
Showing
7 changed files
with
237 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import java.util.ArrayList; | ||
|
||
public class Generation { | ||
|
||
private ArrayList<Creature> creatures; | ||
private double meanScore = -1; | ||
|
||
public Generation(ArrayList<Creature> creatures) { | ||
this.creatures = creatures; | ||
} | ||
|
||
/** | ||
* Get the minimum score | ||
* | ||
* @return The minimum score | ||
*/ | ||
public int getMinScore() { | ||
return creatures.get(creatures.size() - 1).getScore(); | ||
} | ||
|
||
/** | ||
* Get the max store across the creatures | ||
* | ||
* @return The max score | ||
*/ | ||
public int getmaxScore() { | ||
return creatures.get(0).getScore(); | ||
} | ||
|
||
/** | ||
* Lazy implementation for the mean | ||
* | ||
* @return The mean score | ||
*/ | ||
public double getMeanScore() { | ||
if (meanScore == -1) { | ||
int s = 0; | ||
for (Creature c : creatures) { | ||
s += c.getScore(); | ||
} | ||
meanScore = s / creatures.size(); | ||
} | ||
return meanScore; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.