-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animal highlights #21
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- If our picked animal is on a certain field but isn't the strongest(shown one), then the field is not highlighted.
It would look much better if regardless of its strength it would always show up.
We can also achieve this by making a selected Animal a priority to show on Map regardless of the fact that there are stronger animals on the same field.
However I believe it to be somewhat of a less desirable approach.
- Another thing that I found out that if you close a simulation window but still have animals stats open simulation still runs in the background.
It should be an easy fix.
…023_projekt into animal-highlights
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few optimizations possible but code looks good.
@@ -37,9 +38,9 @@ public class MapDrawer { | |||
private boolean isAlertShown = false; | |||
private Animal observedAnimal; | |||
Label[] animalStats = new Label[7]; | |||
Label[] simulationStats; | |||
Node[] simulationStats; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On main in CSVWriter I am using the fact that simulationStats are Labels.
I can always cast Nodes to Labels, but I want you to know that we have somewhat of a merge conflict.
for (Animal animal : aliveAnimals) { | ||
if(animal.getGenotype().getGenes().equals(mostCommonGenotype.getGenes())){ | ||
Vector2d position = animal.getPosition(); | ||
printCell(position.x(), position.y(), "#F3B153"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might have not intended it to be so but I believe that the more animals with said Genotype are on one file the more highlighted it is.
It actually is quite a nice feature.
return childrenComparison; | ||
} | ||
|
||
return Math.random() < 0.5 ? -1 : 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using random.nextBoolean() is slightly more readable.
@@ -100,11 +102,14 @@ private void moveAnimals() { | |||
|
|||
private void feedAndReproduceAnimals() { | |||
for (Vector2d position : animalsMap.keySet()) { | |||
List<Animal> currAnimals = animalsMap.get(position); | |||
|
|||
Collections.sort(currAnimals, new AnimalComparator()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need to initialize new AnimalComparator Object every time.
@@ -30,6 +31,7 @@ public Pair<Vector2d, Integer> howToMove(Vector2d oldPosition, MapDirection dire | |||
public Pair<Node, Optional<Animal>> nodeAt(Vector2d position) { | |||
List<Animal> animalsAtThisPosition = animalsMap.get(position); | |||
if (animalsAtThisPosition != null) { | |||
Collections.sort(animalsAtThisPosition, new AnimalComparator()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need to initialize new AnimalComparator Object every time.
@@ -53,6 +51,7 @@ public Pair<Vector2d, Integer> howToMove(Vector2d oldPosition, MapDirection dire | |||
public Pair<Node, Optional<Animal>> nodeAt(Vector2d position) { | |||
List<Animal> animalsAtThisPosition = animalsMap.get(position); | |||
if (animalsAtThisPosition != null) { | |||
Collections.sort(animalsAtThisPosition, new AnimalComparator()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need to initialize new AnimalComparator Object every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we need AnimalComparator for both Globe and Tunnels we can initialize it in AbstractWorldMap.
@@ -25,7 +25,7 @@ | |||
</VBox.margin> | |||
</Label> | |||
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" style="-fx-background-color: #B0DA90;"> | |||
<Button fx:id="saveConfigs" alignment="CENTER" styleClass="config-button-sm" text="Save configurations"> | |||
<Button fx:id="saveConfigs" alignment="CENTER" styleClass="config-button-sm" text="Save configurations " > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text="Save configurations "
text="Save configurations"
No description provided.