identifying all 768 possible ship types
( this thread was prompted by a remark from rmx256 in another topic that he wished there were more than 64 Contribute-Require bits )
I can here you thinking... 768 ships and only 64 flag bits, how's he going do that ?.
The next thing you might think is... oh yeah, use the bits as a counter, then I only need 10 bits for 768 ships.
Nope, that's not going to work either. Because any resource that has a Require bit test capability can only test for the existence of a bit, but cannot test for the absence of a bit. So if one were to try and use 10 Contribute-Require flag bits (CRFs hereafter) as a counter, all ships with an odd number count would then look the same to a resource trying to test for ship number one. And all ships that had an even number count would look like ship number two. And so on and so forth.
Divide and conquer is the basic rule to use. The way to do this is to categorize the ships into groups, classes, types, variants, governments, technology, mass values, crew count or whatever kind of groupings your particular application needs. I'm going to use the Nova scenario as an example to work with, since we're all familiar with it. This example is only concerned with ships that can be piloted by the player. Nova has 288 ships spread out among 60 types, each type having from 1 to 16 variants. The 60 ship types can be further divided into the three game engine mass groups (below 100 tons, from 100 to 199 tons, and 200 tons or greater). But more divisions are needed for this purpose, so governments and ship function can be used to further divide ship types. There are 6 ship producing governments: Federation, Auroran, Polaris, Pirate, Rebel, and civilians. For the sake of this example I'm going to define the ship functions as Carriers, Cruisers, Destroyers, Frigates, Clippers, Corvettes, Heavy-Fighters, Light-Fighters, and Cargo. So to summarize there are...
16 bits for variant
3 bits for mass group
6 bits for producer
9 bits for function
34 bits total
Now if you take each ship in the Nova inventory and classify it according to those 4 categories you'll find that considerably less than 64 bits are needed to identify all 288 ships. In fact this example would theoretically be able to support up to 2592 ships (1636*9 = 2592). If you would like to see a working example of a CRF usage method similar to this, just have a look at my ShipyardUpgrades plug that is in the addons. And no, this is not a ploy to get more people to download my plug. Just a way to convince anyone with doubts that this method of CRF usage has been implemented and actually works. Oh, a word of warning. Using the CRFs to track which ship the player is piloting only works because ship ownership is mutually exclusive. The player can only pilot one ship at a time which prevents any possibility of two different CRF patterns being recorded simultaneously by the game-engine.