Godot Version
4.2
Question
I’m having issues trying to get the nations in my game to conquer tiles evenly. They conquer all neutral tiles on their borders which is an 8-tile area surrounding the tile. However, they conquer up and right quicker than down and left. I think it might be with how I initiated the objects in the grid (going from up to down in each row and shifting to the right) but I have no clue of what to do. Anyone know how I can fix this?
Here is a video of what I mean
Hello !
Could we see the part of your code that manages the expansion of your nations?
It’s quite difficult to help you with just the video.
Strangely, the left side of your nations’ expansion only seems to be taken into account every other step.
Sure! Sorry for the late response
func checkBorder(x : int, y : int):
if (gridPosition.x - x >= 0 && gridPosition.x - x < array.size() && gridPosition.y + y >= 0 && gridPosition.y + y < array[0].size()):
bordering.append(array[gridPosition.x - x][gridPosition.y + y])
return
func getBorders():
bordering = []
checkBorder(-1,0)
checkBorder(0,-1)
checkBorder(1,0)
checkBorder(0, 1)
checkBorder(1,1)
checkBorder(-1,-1)
checkBorder(-1,1)
checkBorder(1,-1)
func conquerBorders():
if (controller):
for i in bordering:
if (!i.controller && i.passable && !justConquered):
i.setController(controller)
i.justConquered = true
justConquered = false
Let me know if you need more!
Actually, I might need a little more information. 
I have a few theories in mind that are similar to what you mentioned of how you initiated the objects in the grid, but more related to the order in which you process/update your tiles than their initialization.
Can you share us the code where you update the state of the tiles at each time step.
Sure!
The tiles rendering is handled by a tilemap so the actual objects are separate, do you want both the rendering and state code?
Also i’ll have to provide it later since I gtg
The problem I envision would be that you update your tiles in a certain order, I imagine left to right.
If you take a tile controlled by a nation, in the expansion calculation, it will update its neighboring tiles to possibly assign a controller to them. A problem I see is that the tiles further to the right will have their controller assigned THEN they will also be processed in the expansion calculation (by continuing to go through the rest of the tiles in your grid) while the tiles further on the left will be assigned to a controller but will have to wait for a new expansion calculation pass on the entire grid (next logical frame) to be considered in the same way as the tiles on the right.
This is a guess based on the code you shared with us, but I assume you have some control over updating the state of your tiles.
If this is indeed the problem, you might first consider reversing the logic of expansion. For the expansion update, each tile looks at its neighbors and if one of these neighbors is controlled, then it becomes controlled too. This way, all tiles are updated in the same way every logical frame.
Ultimately, I think you should consider managing nations via a class/node, which would store all the squares it controls and possibly its neighboring free squares which will be the only ones you update each frame rather than to check the entire grid.
If I am wrong about the origin of the problem, do not hesitate to correct me and tell me which part of your code handles this or that so that we can investigate further 
1 Like
This is VERY late but thanks!
I’ll try and revise the code and I’ll get back to you if it works.
So I tried implementing the solution to my understanding, here is the result and code
func conquerBorders():
if (!controller):
for i in bordering:
if (i.controller && passable):
setController(i.controller)
break
justConquered = false
As for the nations, they are already a class, but there isn’t an array of the tiles it owns for each nation.