Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Organism/Organism.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class Organism {
harm() {
this.damage++;
if (this.damage >= this.maxHealth() || Hyperparams.instaKill) {
this.die();
if(this.die) this.die();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this.die is defined/not null? why does this need to be here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this.die is defined/not null? why does this need to be here?

My mistake, that's from something unrelated.

}
}

Expand All @@ -274,9 +274,11 @@ class Organism {
}

update() {
if(this.lifetime<0) this.lifetime = 0;
if(this.damage<0) this.damage = 0;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For lifetime, I think I'd rather set a min value limit in the html input fields rather than check here. that way it would be obvious to user and not need to be checked every update. this is an issue tho, good catch 👍
idk about damage, why would it ever go below zero?

this.lifetime++;
if (this.lifetime > this.lifespan()) {
this.die();
if(this.die) this.die();
return this.living;
}
if (this.food_collected >= this.foodNeeded()) {
Expand Down