Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9050543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:40:38+00:00 2026-06-16T12:40:38+00:00

The question Sorry about the title, could not seem to find a shorter/better description..

  • 0

The question

Sorry about the title, could not seem to find a shorter/better description..

Here’s the situation: I am making a simple game in which there is a big map (simple, but very big in size). There are also a lot of enemies on that map, but the action is exclusively around the main character (in a certain radius, which is a very small percentage of the map).

At each ‘tick’ (or step, or whatever you call it), there is a certain function called on each of those objects to determine their next move. For performance reasons, since I do not care about what happens outside of my scope of view (or at least, the very far away stuff), I’d like not to call that function on very foreign objects.

How can I manage these objects to make sure I always have a list of the nearby objects that is updated when I move around the map?

(I know it is tagged in C++, but any language will do – I’m not looking for code that much – It’s more about the idea)


What I’ve already tried

I’ve tried a few alternatives:

  • Alternative 1: Separate my map in “zones” and store a list of enemies in each zone. The problem with that is what happens when I’m on edges of those zones and (worse) when I’m on a corner (4 different zones around me). Also, it’s harder to make the enemies switch zones if I run from one zone to another (but I had figured out something which could work…)
  • Alternative 2: Scan the whole map and refresh the active enemies list each time I move x distance. That’s a bit better since I don’t have to worry abound bounds like Alternative 1, but I do have to scan the whole map each time.

I was now looking at Alternative 3, which is to mix those two solutions together.

However, I wanted to make sure there is not a more obvious solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T12:40:39+00:00Added an answer on June 16, 2026 at 12:40 pm

    Store your enemies in a k-d tree and do a spatial range search every few iterations. You need, however, a fairly sophisticated implementation which supports entries moving around and re-balancing – sometimes called adaptive k-d tree.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry could not find a better title for my question. Basically what I noticed
Sorry about the title to this question, it's not very clear but wasn't sure
Sorry about the vague question title, but I have these typedefs here: typedef std::list<AnimationKeyframe>
Sorry about the question title, but I couldn't find a more appropriate way to
Sorry about the odd title, I'm not sure how to phrase the question. Basically,
Firstly, sorry about the question title, it may not be very descriptive for my
Sorry about the extremely vague question title (any suggestions for improvements welcome) I have
Sorry about the wording for my question title. I have a basic HTML anchor
Sorry about the stupid question however I can't see/ not good enough to solve
Sorry this is not a very well defined question, I am thinking about an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.