Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
How can I remove a given element from an array of objects knowing only the contents of said object?

I am making an evolution simulator where food will spawn in the world and cells will go around and eat the food. However, the "eating" mechanic is going wrong, currently the food won't be deleted when eaten, which leads to infinite food supply and exponential growth of the population. Each food object is marked with a 2 on the 2d matrix world, and is also an element in an array called foodVec. The former issue is fixed(checks if a cell is occupying a marked space and unmarks it):

if(matrix[obj.x][obj.y] == 2){
    matrix[obj.x][obj.y] = 0;
}

but I need a reliable way of also removing this value from foodVec so the array doesn't just remark and replace the food particle next frame. How do I remove an object from an array knowing only its contents?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!