View on GitHub

style-codes

Resources for INCOM Style Codes

Style Codes

This page describes in detail the format used to encode a style judgement into a style code.

Requirements

The encoding was designed to produce a representation (alphanumeric word) of a style judgement with the following requirements:

Representation

Style codes follow this format:

aXXbcYZ

where:

The representation is case-insensitive.

The format and the encoding algorithm is chosen with the following considerations:

The Algorithm

A style judgement consists in 7 scores between 0 and 3, a SOG score (between 0 and 3), and a PEN score (between 0 and 20).

SOG and PEN are encoded in the fields Y and Z respectively. If PEN is 10 or larger, then letters are used, with a=1, b=2, …, h=17, i is excluded, j=18, k=19 and l=20. Z is omitted if PEN is zero, and Y is omitted if both SOG and PEN are zero.

The other 7 scores are encoded in the first part of the code, with format aXXbc. The numeric field XX contains the total of assigned points in these categories, so only 6 scores need to be encoded in the fields a, b and c, the seventh being the difference between the total and the sum of the other six. The BAS score is chosen as the one to be encoded in this way.

The fields b and c are optional. When only the a field is used (one-letter format), 26 scores can be encoded. These are used for the 26 most common scores, which are those for which COM, SAPD and DIF are zero and MOV, DIN and GCC have values 0, 1, or 2. These conditions account for 3^3 = 27 combinations, so the combination MOV = DIN = GCC= 3 has also been excluded from the one-letter format.

If SOG or PEN are different from zero (so Y cannot be omitted), and the one-letter format is being used, then b takes the value z to be used as a separator between XX and Y for maximum clarity.

When the fields a and b are used (two-letters format), 23 * 26 = 598 combinations can be represented. This format is used to represent all combinations for which MOV, DIN and GCC have any values (4^3 = 64) and COM, SAPD, and DIF have values 0 or 1 (2^3 = 8), for a total of 64 * 8 = 512 combinations, that fit in the 598 representable combinations.

Then all three fields are used (three-letters format) we can represent 26 * 26 * 23 = 15548 values, enough to represent all combinations of the six categories (4^6 = 4096).

As is apparent from the description above, there are 86 unused combinations in the two-letters format which could, in principle, be used to encode combinations that now require the three-letters format. However, this would cause the encoding algorithm to become more complicated for a relatively little gain.

Here follows a C-like pseudocode detailing the exact encoding used to generate the a, b and c fields. Here, encode26(i) produces the i-th letter of the 26-letter English alphabet, while encode23(i) produces the i-th letter of the English alphabet without i, o and z.

if ((COM == 0 && SAPD == 0 && DIF == 0)
&& (MOV + DIN + GCC < 6)
&& (MOV < 3 && DIN < 3 && GCC < 3)) {
    // One-letter format
    a = encode26((MOV * 3 + DIN) * 3 + GCC);
} else if (SAPD < 2 && COM < 2 && DIF < 2) {
    // Two-letters format
    value = (((((MOV * 4 + DIN) * 4 + GCC) * 2 + COM) * 2 + SAPD) * 2 + DIF);
    a = encode26(value / 23);
    b = encode23(value % 23);
} else {
    // Three-letters format
    value = (((((MOV * 4 + DIN) * 4 + GCC) * 4 + COM) * 4 + SAPD) * 4 + DIF);
    a = encode26(value / (23 * 26));
    remainder = value % (23 * 26);
    b = encode23(remainder / 26);
    c = encode26(remainder % 26);
}