Given the following GDScript, finish the NeighborMap keys, such that it appends each…
- User
Given the following GDScript, finish the NeighborMap keys, such that it appends each neighboring vector on the X,Y axis, if the MapGrid contains the grid point as called: @tool extends EditorScript
func Main(Self): #Collect Data var MapGrid = Self.get_meta('Map_Data').duplicate(true) var NeighborMap = Self.get_meta('Neighbor_Map').duplicate(true) var MapSize = Self.get_meta('Map_Size')
code#Build Array var MGKeys = MapGrid.keys() for X in range(0, MapSize): for Y in range(0, MapSize): if Vector3i(X,Y,0) not in MGKeys: MapGrid[Vector3i(X,Y,0)] = 0 #Build Neighbor Map MGKeys = MapGrid.keys() for Key in MapGrid.keys(): if Key not in NeighborMap.keys(): NeighborMap[Key] = [] if Vector3i(Key[0]-1,Key[1],Key[2]) in MGKeys: NeighborMap[Key].append(Vector3i(Key[0]-1,Key[1],Key[2])) if Vector3i(Key[0]+1,Key[1],Key[2]) in MGKeys: NeighborMap[Key].append(Vector3i(Key[0]+1,Key[1],Key[2])) if Vector3i(Key[0],Key[1]-1,Key[2]) in MGKeys: NeighborMap[Key].append(Vector3i(Key[0],Key[1]-1,Key[2]))
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.