#Change altitude internal format to 24-bit fixed point
103 messages · Page 1 of 1 (latest)
and honestly you could get away with 16 bits, since in-game altitude is only shown rounded to 0.1m. log2(8400*10) is 16.35 - you only need ever so slightly larger than 0.1 packing to make it fit.
that's not how floating points work, you can get a number that large because of an exponent that's a factor of log2 smaller
you only need 10 bits to represent 1024
floating points are split into a mantissa (base value) and an exponent, and for 64 bit floats the standard is 1 sign bit, 11 exponent bits, and 53 mantissa bits
oh
the max value is a result of the exponent maxing out
64 bits, ok that's a lot smaller than i thought lol
so it's max_mantissa * 2 ^ max_exponent
but even then, 24 bits is still a pretty big improvement over that
you cant just change the number format tho
theres a shitload of math done with these numbers and also you have to abide by what the programming language allows
this is talking about network packing, where you can do basically whatever you want
it would be no problem to pack everything into an array of bytes of stride 2/3
you can just take a 24-bit integer (0-16777215) and divide it by 256...?
unless it doesn't work that way, in which case i apologize
i don't claim to be an expert on this stuff
no that's basically what fixed point is, you just take a value with the understanding it represents a smaller actual value
better yet, since 256 is a power of two (wait no really???) you can just bitshift it left by 8
tetrio is coded in JS right?
to expand on this: you don't need 1024 bits of precision to represent numbers of size 2^1024 because floats have gaps that get bigger the higher you go - past ~2^53 or so the gaps become so large that you skip whole integers (this happens to be related to the same number of bits used for the mantissa)
floats are unevenly spread out, one quarter of the possible floating point values are in the range 0..1
(the other three quarters are in -inf..-1, -1..0, and 1..inf)
this does make me wonder
what if i become so good at mech heart that i go so high that i just stop moving
because floating point is supid
you just stop moving, nothing else weird would happen
and you'd also have to be very very high, and attacks would still send and give the boost (until youre much further)
but like
i thought garbage traveled at a fixed speed tho
overall, this is MUCH easier said than done
like, in terms of ingame meters per second
im pretty sure it just uses the normal garbage travel time lol theres no point for it to be anything else
and garbage travel time is irrelevant to what i said (which is about the bonus height you get when sending an attack)
https://float.exposed/ fun site btw, switch it to double for what tetr.io would use
Floating point format explorer – binary representations of common floating point formats.
e.g. 1.0 is halfway through the exponent range: https://float.exposed/0x3ff0000000000000 (2048 possible values, with 2047 reserved for infinity)
javascript uses floats almost exclusively
doubt it's noticeable on a modern cpu with hardware acceleration
you cant just tell it "use a 24 bit fixed point" you have to CODE that 24 bit number USING floats
if there's 32s, use those instead
this is going in the protocol, not the working representation in engine memory
you just convert between the two at the network boundary
this just LITERALLY isnt how it works
let packed = new Uint8Array(3);
let unpacked = a[0] << 16 | a[1] << 8 | a[2];
???
dude thats not worth it at all
AFAIK in js theres number and bigint and both are 64 bits
especially for something sensitive like network bandwidth
are you saying it's horribly unoptimized?
no I'm saying drocelot will do bit packing shenanigans without a second thought if it improves performance
oh ok
it seems the two of you are on semi-opposite sides of this
i do get that this is probably a VERY
suggestion, but I doubt it would take longer than a day to implement, as opposed to some things I have submitted here.
i EXTREMELY doubt it would take under a day to implement and test.. youre basically coding your own number format to send, and the encoding/decoding of it
I mean, it's already a custom binary protocol
I wouldn't expect doing a custom width field to be that hard
it's not like they're going from json or something similarly unoptimizable
and the number format is just three bytes, it's a couple of shifts to encode and decode
there's already examples of this kind of bit packing in the game, nothing as odd as 24 bits but like the radiance header definition looks like a c struct that you absolutely have to manually parse with a DataView or similar
i mean there are a few things that you represent as a 24bit value
like color
represented as a 3 byte hexcode
(four byte in many cases, transparency)
a similar form of this ^ exists in the game already, packing 24 bits into a continuously sent network packet is nothing in terms of complexity compared to potential savings vs a 32 or 64 bit number
even 600 players sending a float 10 times per second is <0.4Mbps
this is FAR below average
and playing on Low makes the leaderboard update only every two seconds anyway
(the LAST available country on the list is 3Mbps)
-# but what if I want to play tetr.io on dial up
Either way, this is kind of a useless discussion at this point. Based on my knowledge of the tetrio dev team, I would expect that a 64->24 bit savings for a message sent hundreds of times per second is absolutely something they would consider doing if the only tradeoff to be considered was implementation complexity.
probably not a priority at this point, but saying dude thats not worth it at all and this just LITERALLY isnt how it works doesn't seem like a reasonable expectation
besides, there's all sorts of insane things you could do to pack it in even tighter if you really wanted to:
- Check what players are actually visible to the client and only send data for them
- Players are generally pretty close together, so if you're sending all of them together anyway you could use delta encoding to cram it in tighter: each player's height is a (e.g.) 10 bit number representing how much higher they are than the previous player in the list. If the height difference exceeds the representable values, a blank entry can be inserted instead as a buffer.
:P
this also requires bookkeeping an order of clients and sending additional bits when reordering is necessary, but theoretically it'd work
but it's much less sane than packing it into 24 bits instead
checking what players are visible only relevant for rendering the boards, altitudes are still visible at all times on the leaderboard
true, but you're only looking at a tiny fraction of the leaderboard at any one time
yeah idk whether or not the lb does culling
for players far away from the current scroll position, you can send updates very infrequently
either way none of anything in this channel is based on actual facts about the implementation so it's similarly fairly useless
seems so, at least on minimal when scrolling very fast
yeah my bad
source?
because uh, you're talking total nonsense
it's an 18bit decimal (written as float here, but its fixed point uint18)
you cant just make an assumption of how the game works and then make a thread about it as if it's true
our encodings pack tightly where needed
this is not how floating points work
i mean max safe integer is only 9007199254740991
whatever i lock thread
Like osk said amadeus uses bit packed structures but I assure you we don't have '1024-bit' values lol I've designed amadeus very well for exactly this kind of stuff!
i guess