Finding an algorithm is usually best done with a data structure that makes the algorithm easy.
In this case, your territory.
The territory should be an unordered (O(1) hash) set of borders and elements.
Whenever you add an element to the territory, you iterate over adjacent tiles and see if they should be a border tile; in this case, they are a border ...
If you need to find edges of holes in the middle of your territory too, then your linear in the area of the territory bound is the best we can do. Any tile on the interior could potentially be a hole that we need to count, so we need to look at every tile in the area bounded by the territory's outline at least once to be sure we've found all the holes.
Notice: Whether or not a tile is on the boundary only depends on it and its neighbors.
Because of that:
It is easy to run this query lazily. For instance: You do not need to search for the boundary on the whole map, only on what is visible.
It is easy to run this query in parallel. In fact, I could image some shader code that does this. And if you need it ...
I believe that this is what you were looking for:
keys = pygame.key.get_pressed() # checking pressed keys
if keys[pygame.K_ESCAPE]: # If 'esc' - QUIT GAME
game_exit = True
if keys[pygame.K_RIGHT]: # If 'right' - MOVE RIGHT
The longer you hold the key down, the more it would move
Move your area up one tile, then up-right, then down right, etc..
Afterwards remove the original area.
Merging all six sets should be O(n), sorting O(n.log(n)), set difference O(n).
If the original tiles are stored in some sorted format, the merged set can be sorted in O(n) too.
I don't think there is an algorithm with less than O(n), since you need to ...
A common technique for generating random worlds with large biomes is to use stock noise algorithms like perlin noise or simplex noise. Such algorithms generate noise patterns which generate a kind of "smoothed out randomness". Values don't change abruptly like they do in random white noise (like you are using right now). They change gradually with varying ...
Don't add biomes, instead vary parameters around your world and pick the biome based on that.
For example you set a temperature and rainfall and you can use them to pick a biome; dry and how would be a desert, cold and dry would be taiga, cold and wet would be snow lands etc.
That way you avoid having a snow biome next to a hot desert without a buffer zone....
Databases are supposed to be used for persisting long-lived data, not for ephemeral data. Using a database for storing short-lived chat messages just to delete them seconds later is quite an anti-pattern. It was common in the early years of PHP where databases were pretty much the only way to exchange data between sessions. But more modern web application ...
I'm on my phone and can't provide a super detailed answer, but here goes.
This answer will not cover the physics calculation that you use, only the logic.
It looks like there is trash data in your loop.
When evaluating a body with itself, you do not update the angle and the acceleration, it remeains to what was used with a previous body. Whatever is in ...
I'm not sure if it would work well, as I'm not familiar with pygame, but you could stick the value that you want in your Dog object as a float, and do calculations on this value, then use this value converted to int to update the rect.y variable.
Dog.computation_y += 0.5
Dog.rect.y = math.floor(Dog.computation_y)
You'll be able to control a bit more the ...
pygame.sprite.groupcollide returns a dictionary that always includes the sprites in the first group. Therefore, the if test you have written will always return true.
You should re-write the function to check whether or not there are sprites in the list for every sprite in the dog group.
So you have a "one-button" gameplay and it's not engaging enough? Have you played NFSU? It had a drag race mode, which is basically pressing one button in perfect timing to outrace other competitors.
Why not try to replace turns with cooldowns. Whenever someone's cooldown reaches zero - they can have their turn and try to press the button in perfect time. ...
The KEYDOWN event is fired every time the key is pressed down, so the impulse is applied only then. Instead, you should remember the state of the key and apply force in every iteration of the main loop if the key is pressed down.
See this article for example code: https://www.iforce2d.net/b2dtut/forces
Also to make sure the speed is framerate-independent, ...
First, instead of storing each platform as a member in class, do it like this:
self.platforms=[Platform(200, 550), Platform(600, 550), Platform(1000, 550)]
It's the list of all platforms in the game. By storing them in the list, you'll be able to easily add or remove them.
Do the same for each object that's going to be more than one in the game (coins, ...
As you've pointed out, the other question you linked to is more about how to render a nice graph and numerical change, and not how to decide exactly how or why the number should change. It just states...
You start at time T1. You're going towards time T2. Price at time T1 is P1. P2 is end price.
You generate a random number (probably based on some events, ...
When you use something like self.foo.bar = self from the class bar, you're telling foo which bar it is linked to. Basically,
self.scene = scene
self.scene.manager = self
is used to set reference in both ways, so that from the SceneManager, you can know which scene is managed, and from the scene, you can get access to the scene manager through the ...
The code formatting for your answer has mostly broken down, it would be a lot easier to help you if you fixed it.
What does it mean for turtles to collide? It means that they occupy the same space, so the easiest thing to do is:
if player.position() == player2.position():
however, this doesn't quite work because turtle ...
I just wrote a blog post about how to do this. This uses the first method that @DMGregory mentioned starting with an edge cell and marching around the perimeter. It's in C# instead of Python but should be pretty easy to adapt.