Answer the question
In order to leave comments, you need to log in
How to implement inventory like in tarkov?
Hello, I want to write an inventory in React like in Tarkov, here is a screen: https://imgur.com/a/ElpGjV6
That is, there are slots and things that take up N number of slots. What kind of logic should be in finding the location of a thing?
Answer the question
In order to leave comments, you need to log in
This is a subspecies of the backpack packing algorithm (or cutting algorithm). Because you have a small backpack, you can not bother with all sorts of complexities such as genetic algorithms and approximations, and with each addition of an item, even do a complete enumeration. Naturally, at the beginning, you can check whether there is at all the required number of free cells, and if there is, place it in the nearest free area, and only if there are enough cells, but they are fragmented, do a search. There are many
libraries for this business , tk. their periodically students on labs are asked to write. Look for "knapsack 2d" or "cutting stock 2d".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question