Re: Representing 3d Staircases? (Python)

So I have an entirely different problem now.
My binary search works, as long as the tiles don't overlap each other. For example, it would work correctly on the following arrays:

start = [0, 2]
end = [1, 3]

As you can see, there are no overlapping tiles, and thus the binary search can do it's magic. Consider these arrays, however.

values = [7, 8, 9]
start = [1, 2, 3]
end = [3, 4, 5]

See the issue here? The binary search I came up with only returns the tile type of the entry if the given coordinate is greater or equal to the start and less than or equal to the endpoint. If I was to run my binary search using the value 4, it will return 8 when in fact it should return 9 because 9 is the latest override to the list which covers 4
What I would like is for the array to realize that I'm overriding one of it's values. However, the in operator wouldn't work, seeing as the value I'm overriding could be between two values, like so.

values = [3, 4]
start = [0, 1]
end = [6, 2]

If you try and run a binary search using the value 1, you wouldn't get 4, the expected and correct output. You would get 0 instead, which, though being correct, is not the latest information in regards to the said coordinate.
I thought that my binary search was implemented incorrectly, but googling only brought me code similar to mine. The search also works when the tiles don't overlap, which makes me suspect that the problem is in the tiles being overwritten.
So, I considered how to fix the problem, and the only clean solution I came up with was to run a binary search testing if the said coordinate was already covered every time a new value was added to the list. If it is, I would split the old tile into two pieces and stick the new tile between them. Problem is, that insertion could override another tile, and the split of that tile could override another tile, and the split of that tile could... you get the picture.
I'm asking here just in case I'm missing something obvious. I could certainly deal with the tiles being the way they are right now, but it would be nice if I could take out the problem of overlapping out of the picture. Is there a better way to handle overrides than what I proposed?



-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector

Reply via email to