Crystal wedges, no extra IDs needed

    Joined
    Jun 19, 2014
    Messages
    1,756
    Reaction score
    162
    • Purchased!
    • Top Forum Contributor
    • Legacy Citizen
    If I understood everything correct, all the blocks are supposed to get more orientation bits. Those orientation bits would in turn store the shapes and colours of blocks. All the shapes and clours would then be in one block id.
    Currently you need the 8 different crytals to craft each colour of glass. You also need the 8 different new rocks to craft each colour of hull.

    If it is what I think it is, and there is no way to store how many of each type you have, you wouldn't have to use the 8 different types of crystal and 8 different types of rocks to craft everything anymore.

    Since I am quite certain that this is the case, I would like to propose that only block shapes would get stored in the orientation bits. That way people would still have to use every type of crystal and rock, but they wouldn't need so much space for their wedges, corners, tetras and pentas.
     
    Joined
    Aug 28, 2013
    Messages
    1,831
    Reaction score
    374
    • Legacy Citizen 2
    • Top Forum Contributor
    • Legacy Citizen
    No, not the colors. There will be 64 orientations, which will be all used up by the shapes. Each type and color of block is still its own ID.

    EDIT: Also guys: ANGLED DOCKING MODULES!! And also angled gravity.
     
    Joined
    Jun 19, 2014
    Messages
    1,756
    Reaction score
    162
    • Purchased!
    • Top Forum Contributor
    • Legacy Citizen
    I'm more interested in angled weapons. It would make for lovely turrets. I might actualy start building them then.
    (Well, no. I'm first going to wait until turrets don't turn that fast anymore.)
     
    Joined
    Aug 28, 2013
    Messages
    1,831
    Reaction score
    374
    • Legacy Citizen 2
    • Top Forum Contributor
    • Legacy Citizen
    ???

    Maybe make them step-on triggered? :)
    What I meant was that you would be able to put gravity block wedges down to define gravity at an angle, so you can walk flat on diagonals. Yeah you would probably want it on a trigger just to be easy. I can imagine making people walk around the inside of a sphere with this and some area triggers.

    P.S. I know someone made a station inspired by the elite series (he had done the docking cylinder and showed how you can walk around it using gravity on a video)
     
    • Like
    Reactions: NeonSturm

    NeonSturm

    StormMaker
    Joined
    Dec 31, 2013
    Messages
    5,110
    Reaction score
    617
    • Wired for Logic
    • Thinking Positive
    • Legacy Citizen 5
    I hope wedge gravity is easy to implement ltmauve. but SE had a good idea on how to do it without wedge-gravity gens (they have a spherical gravity now too)
     

    Lecic

    Convicted Lancake Abuser
    Joined
    Apr 14, 2013
    Messages
    5,115
    Reaction score
    1,229
    • Thinking Positive Gold
    • Purchased!
    • Legacy Citizen 11
    I hope wedge gravity is easy to implement ltmauve. but SE had a good idea on how to do it without wedge-gravity gens (they have a spherical gravity now too)
    SE has a much more complex physics engine, I'm not sure if spherical gravity would even work in this game. I'm pretty sure it only supports gravity in one direction.

    I'm pretty sure how gravity works is that it applies downward/upward force along an axis. The game doesn't have diagonal axis, so you'd probably need to implement a "ghost" entity that would be aligned to the main ship at a diagonal angle, and then connect the player to a gravity field on that entity.

    Or maybe I'm just overcomplicating it and schema could totally implement diagonal gravity normally.
     
    Joined
    Aug 28, 2013
    Messages
    1,831
    Reaction score
    374
    • Legacy Citizen 2
    • Top Forum Contributor
    • Legacy Citizen
    You could apply force on two axes at .7 normal gravity (hey, if this is implemented we might get variable gravity) or three at .6 at the same time, but the problem is you might wind up sliding down blocks because the system can't detect if you're standing on it.
     

    Ithirahad

    Arana'Aethi
    Joined
    Nov 14, 2013
    Messages
    4,150
    Reaction score
    1,330
    • Purchased!
    • Top Forum Contributor
    • Legacy Citizen 8
    SE has a much more complex physics engine, I'm not sure if spherical gravity would even work in this game. I'm pretty sure it only supports gravity in one direction.

    I'm pretty sure how gravity works is that it applies downward/upward force along an axis. The game doesn't have diagonal axis, so you'd probably need to implement a "ghost" entity that would be aligned to the main ship at a diagonal angle, and then connect the player to a gravity field on that entity.

    Or maybe I'm just overcomplicating it and schema could totally implement diagonal gravity normally.
    This game supports whatever Schema's capable of programming in that doesn't fry our computers, Lecic... I'm pretty sure that spherical gravity is entirely within the realm of possibility, if ever we get a setup (e.g. much bigger planets with (say) square segments) that requires it. As for diagonal gravity, that can be done too.
     
    Joined
    Aug 23, 2013
    Messages
    379
    Reaction score
    65
    The first thing I'd look at is having 1 bit to determine if the block is "fully solid" (hull, weapon computer, etc) or not (glass, flowers, wedges, etc). This is important for faster rendering (hidden surface removal - if 2 adjacent blocks are both "fully solid" then both block's adjoining faces can be skipped).

    For the solid blocks, you can have 3 bits for orientation and 1 bit for activation status, leaving 11 bits for solid block IDs. That's 2048 solid blocks.

    For the non-solids, you'd only need an activation bit for rod lights, and it'd make more sense just having different IDs instead (e.g. one ID for "white rod light that's off" and another ID for "white rod light that's on", etc). If you use 6 bits for orientation, you're left with 9 bits for the block ID. That's 512 block IDs.

    That gives a total of 2530 block IDs, plus activation and orientation. However, I've only used 16 bits, and I've "forgotten" HP.

    The thing is, computers like "powers of 2" (especially 80x86, especially for array indexing where there's special support built right into the instruction set). Numbers like 2, 4 and 8 bytes? Lovely. Numbers like 3 bytes? Slow.

    The other thing is cache locality. Cache misses are very expensive and the size of the CPU's caches are limited (especially the fastest L1 and L2 caches). You want to cram as much data you need into every cache line you fetch. When a missile hits a ship and you're calculating how much got damaged, you're primarily accessing the HP values and don't care too much what types of blocks they are (until/unless a block is destroyed); so you don't want cache lines containing "HP data" bloated up with the block IDs. When you're calculating power regen, or which weapon blocks are part of which group, you don't care about the HP at all; and don't want your "block ID data" bloated up with HP values. When you're spawning a ship from blueprint; don't store the HP values in the blueprint at all (and generate them when the ship is loaded) and reduce file size while also avoiding "brand new ship came with damage!" problems.

    Finally; for most CPUs there's also SIMD ("Single Instruction Multiple Data") - e.g. SSE/AVX on 80x86, Neon on ARM, etc. SIMD can and does give a massive performance boost. To get the benefits you have to pack multiple pieces of data together; so that your "single instructions" can operate on the "multiple pieces of data". For something like StarMade (e.g. where a lot of processing involves arrays of block IDs, and where the data could easily be packed suitable for SIMD) it could easily give major performance improvements. SIMD does not work on "3 bytes per piece of data". Modern JVMs do optimise for SIMD, and StarMade is probably missing out on major performance improvements.

    What I'm saying is that HP values should be a completely separate array. This array would be "1 byte per block", where HP ranges from 1 to 256. If HP is 0 then the block was destroyed or didn't exist in the first place.

    Also note that for things like collision detection; you'd use the "1 byte per block" HP array and not the "2 bytes per block" block ID data. This should halve the cache misses (as there's half as much data for the CPU to fetch), and (maybe) get twice the benefits from SIMD.
     
    Last edited:
    Joined
    Aug 28, 2013
    Messages
    1,831
    Reaction score
    374
    • Legacy Citizen 2
    • Top Forum Contributor
    • Legacy Citizen
    What I'm saying is that HP values should be a completely separate array. This array would be "1 byte per block", where HP ranges from 1 to 256. If HP is 0 then the block was destroyed or didn't exist in the first place.
    Yes, but you might as well have it in the same place, since it will add extra bits per block. The point of the suggestion is to compromise.
    The only point of contention was the effect the new armor system would have.
     
    Joined
    Aug 23, 2013
    Messages
    379
    Reaction score
    65
    What I'm saying is that HP values should be a completely separate array. This array would be "1 byte per block", where HP ranges from 1 to 256. If HP is 0 then the block was destroyed or didn't exist in the first place.
    Yes, but you might as well have it in the same place, since it will add extra bits per block.
    If "3-bytes per entry" means you have to use twice as many instructions for array lookups, and makes CPU caches less efficient, and prevents the JVM from optimising for SIMD; are you entirely sure that you want code that's maybe 10 times slower just so you can get a few measly extra bits that the game doesn't need anyway?
     
    Joined
    Aug 28, 2013
    Messages
    1,831
    Reaction score
    374
    • Legacy Citizen 2
    • Top Forum Contributor
    • Legacy Citizen
    If you want to have one bit for HP, one bit for activation, 6 bits for orientation, and have that fit with blockID in two bits, you wind up with only 256 blockID values. In other words, fewer block types than currently exist in-game, even without the blocks that are shaped. It won't work. Any system has trade-offs between speed and size efficiency, and Schema has chosen his balance. Neither of us know what his exact criteria were when he made that decision.
     
    Joined
    Mar 2, 2014
    Messages
    1,293
    Reaction score
    230
    • Thinking Positive
    • Community Content - Bronze 1
    • Legacy Citizen 3
    For the solid blocks, you can have 3 bits for orientation and 1 bit for activation status, leaving 11 bits for solid block IDs. That's 2048 solid blocks.
    3 bits for orientation aren't enough. Corners need 5 bits, wedges 4.

    When a missile hits a ship and you're calculating how much got damaged, you're primarily accessing the HP values and don't care too much what types of blocks they are (until/unless a block is destroyed); so you don't want cache lines containing "HP data" bloated up with the block IDs.
    You forgot about armor which is ID dependant.
     
    Joined
    Aug 23, 2013
    Messages
    379
    Reaction score
    65
    3 bits for orientation aren't enough. Corners need 5 bits, wedges 4.
    I didn't forget. Corners, wedges, etc, were classed as "not fully solid" and have 6 bits for orientation.

    You forgot about armor which is ID dependant.
    You're right. Maybe that separate HP byte could be 6 bits for HP and 2 bits for armour. That'd be enough for HP values from 1 to 63, and 4 armour values (none, hull, standard hull, advanced hull).
     
    Joined
    Aug 28, 2013
    Messages
    1,831
    Reaction score
    374
    • Legacy Citizen 2
    • Top Forum Contributor
    • Legacy Citizen
    Armor is by block type, not block-specific. You don't need bits for it.
    I didn't forget. Corners, wedges, etc, were classed as "not fully solid" and have 6 bits for orientation.
    Also, how would the system tell the difference between a solid an non-solid block? It can't tell what the bits are allocated for. That is why all blocks have the same bit allocation. And reducing the HP means either the damage of weapons has to go down, which is impossible right now, or a new armor system had to be put into place, which I proposed in the original post.
     
    Joined
    Aug 23, 2013
    Messages
    379
    Reaction score
    65
    Armor is by block type, not block-specific. You don't need bits for it.
    For performance (avoiding extra table lookups, etc. when calculating damage) you need bits for armour.

    Also, how would the system tell the difference between a solid an non-solid block? It can't tell what the bits are allocated for.
    To tell the difference between solid and non-solid (for the purpose of rendering) just use the "fully solid or not fully solid" bit.

    To tell the difference between solid and non-solid (for the purpose of collision detection and not rendering) you'd have to check the "fully solid or not fully solid" bit and (only for non-solid blocks) also check the block ID. Of course (to speed that up too) you could say that for "not fully solid" blocks the highest bit of the block ID determines if it is solid for the purpose of collision detection. Then you could do a single test:

    if ( (raw_data & 0xC000) != 0) {
    // This block is solid for the purpose of collision detection
    }​

    And reducing the HP means either the damage of weapons has to go down, which is impossible right now, or a new armor system had to be put into place, which I proposed in the original post.
    Reducing the damage done by weapons is simple - you just multiply by a scaling factor (and could even have a "weapon damage scaling factor" option in the server's config).

    Reducing the number of bits used for HP values doesn't necessarily mean reducing the maximum HP. In fact, you could increase it, like this:

    actual_HP = (raw_HP_byte_value & 0x3F) << 3​

    In this case, HP values would range from 8 to 504. More fun might be to use the highest 6 bits for HP, so you can do:

    actual_HP = raw_HP_byte_value & 0xFC​

    In that case, HP values would range from 4 to 252.

    Of course you're right - if there's going to be a new armour system, then it'd make more sense to add that while making the other changes.
     
    Last edited:
    Joined
    Aug 28, 2013
    Messages
    1,831
    Reaction score
    374
    • Legacy Citizen 2
    • Top Forum Contributor
    • Legacy Citizen
    There are more than four values of armor types right now. Even so you would need a lookup table to have a balanced armor system with only a few bytes. Schema has clearly decided that having things run as fast as possible isn't for the best when it requires more RAM.

    As for reducing weapon damage, the reason I said you can't is because the weapons values were set as low as possible when created because they could be adjusted up if needed.

    Multiplying the HP by a given value won't change that you can't store more information in those bits. If you have a values from 1-64, if you multiply by 8, you can only get multiples of 8. In other words, the HP is effectivly the same, since you can't have a value like 13.

    Using 6 bits for orientation means that with the current blocks plus half-slabs, every combination is used, and means something. In fact, using the division type armor instead of the current type means that all blocks would start with HP of 63, and have different armors in order to have different healths. All the values mean something, and the data is the most efficent. In fact, you might even be able to have different armor values for different shapes, giving the "varible HP for different shapes" thing without needing to have different IDs.