algorithm - Sorting two-way cell connections with priority -
I have a two-dimensional grid of cells In this simulation, the cells may request to change the position with another chamber. There is also a preference in the request.
The problem is that IM is getting a good way for this structure. If wants to switch with A, and also wants to switch from A to A, they can currently switch and turn into a logic tick (which should be impossible).
The solution may include making sure (A to B) == (B to A) and their entry sorts them from their priority to a list.
Is this the name of the data structure? Anyone understand the problem and can provide some good links to read?
I can not say that I '
Cell - A class or one before, came across an example like this, so I do not know what it will be said, but maybe something like this will ...
<
SwitchRequest - A class / Li>
- An array of switcherworks
First sevived seal - An array of cells
algorithm
for each tick:
Clear switchSquest sort switch List the list, look at the priority (at a minimum) through each switchrequest. (If the request is that the cell is not already in the switched and the target cell is already not in the head seals) {RequestingCell and TargetCell to AlreadySwitchedCells at SwapCellIds (RequestingCell, TargetCell)}}
Note: Here are some options, such as whether you should create a coordinate property of a cell or just store cell AIids in a two-dimensional array, but hopefully it gives you a starting point.
Comments
Post a Comment