Home-Away kit automatic selection: how to deceive the algorithm !

More
4 months 1 week ago - 4 months 1 week ago #144976 by DaniSwos
How to deceive the home-away kit automatic selection algorithm

One annoying aspect of SWOS, if compared to other soccer games or even to the previous plain Sensible Soccer versions, is the algorithm for the selection of the home-away kits.
For a lot of classical matches between top teams where they in reality both wear their classical home kit, the Swos algorithm judges them as too similar instead, and make a mess decision. This is sadly true in particular for italian teams. For instances, the following matches never appears with both home kits:

Juventus-Milan
Milan-Inter
Inter-Juventus
Juventus-Chelsea
Manchester City-Chelsea
Newcastle-Chelsea

and many other examples exist.
I found a successful way to deceive the home-away kit selection algorithm in a flexible way; unfortunately to be feasible it requires some scripts to be automated, otherwise it requires too much time.
The background follows.

The home-away kit selection algorithm uses internally some kind of "adiacency-graph" of the colors; if the two kits have too many adiacent colors, they are judged as too similar and will not appear in the match. 
After many experiments, I could infer the following adiacency graph:

YELLOW - ORANGE
ORANGE - RED
RED - BROWN
BROWN - BLACK
BLACK - BLUE
BLACK - GREEN
GREEN - GREY
BLUE - CYAN
BLUE - GREY
CYAN - GREY

It should be noticed that BLACK and BLUE are "adiacent". This is for instance the reason why many matches listed above are played without both home kits.
Based on this background, the idea to deceive the algorithm works as follows:

- At first, a new "remapping" of colors must be decided, so that colors that should be compatible are not adiacent anymore after the new remapping. 
For example, one possible interersting remapping could be the following (but many other are of course possible):

Desired = WHITE,  Original = YELLOW
Desired = GREY,  Original = RED
Desired = BLACK,  Original = CYAN
Desired = YELLOW,  Original = BROWN
Desired = ORANGE,  Original = BLACK
Desired = RED,  Original = GREEN
Desired = BROWN,  Original = GREY
Desired = BLUE,  Original = WHITE
Desired = GREEN,  Original = BLUE
Desired = CYAN,  Original = ORANGE

The "new" adiacency graph would become the following:

WHITE -- CYAN
CYAN -- GREY
GREY -- YELLOW
ORANGE -- YELLOW
ORANGE -- GREEN
ORANGE -- RED
BROWN -- RED
GREEN -- BLACK
BROWN -- GREEN
BROWN -- BLACK

where BLACK and BLUE are not adiacent anymore!

- All team colors (TEAM.xyz files in DATA folder) must be changed according to the remapping decided at the step above. To do this properly, the following idea could be used: at first, the DATA folder is copied once into let's say the new "DATA_ORIGINAL" folder, so that DATA_ORIGINAL will always contain the teams with the desired original colors; then a script parses all teams from DATA_ORIGINAL, calculates the new remapped colors and overwrite the colors into the TEAM.xyz files of DATA folder. 

- Until know, the effect of the two steps above would be that the teams are just shown in the game with completely different colors! For instance, Milan will appear with grey-orange stripes ("Desired" in place of "Original", see the remapping above), while Juventus will appear with blue-orange stripes!
So, an additional step is needed....

- Now the final magic! Luckily, the executable has a 10-bytes map where associates to a color identifier its color palette. In the original Dos Version SWOS 96/97 it is at offset hex 183B28, and appear as follows (values are hex as well):
| 1 | 2 | 3 | 6 | A|  B | C| D| E| F|
The same byte string should appear somewhere in the Swos2020 executable.
The order of the colors is the following:
GRAY, WHITE, BLACK, ORANGE, RED, BLUE, BROWN, CYAN, GREEN, YELLOW

Now it is sufficient to reorder that "map" exactly according the chosen mapping. After that, the teams will "appear" in the game with the original colors: the funny thing is that algorithm believes that they have the "new" remapped color instead, therefore will apply the adiacency rules to the "new" remapped color and will stop to judge many kits as similar.

- Some kits could be still judged too similar, in particular if for a team the two shirt colors and the shorts colors are all different. This applies for instance for Milan (red-black shirt, white pants). A final trick would be in general to keep the GREY color as "spare", to reconfigure it as another color and to use it when needed; in this case, configure the "original" Milan shorts as grey (DATA_ORIGINAL), and to remap the grey also as WHITE in the 10-bytes map in the executable. 
So the algorithm will believe that the Milan shorts are RED (see "Original" color for GREY" in the remapping), but they will appear as white instead of GREY!
With this trick, all three top-team italian matches among Juventus, Inter and Milan will appear with all home kits!

 
Last edit: 4 months 1 week ago by DaniSwos.

Please Log in or Create an account to join the conversation.

More
4 months 1 week ago #144977 by Playaveli
Nice post, Daniele! Thanks for sharing.

Please Log in or Create an account to join the conversation.

More
4 months 1 week ago #144979 by thd79
Cool! I have this issue all the time playing with Argentina.It seems to think that white and sky blue stripes clash with red and black stripes (AC Milan)!

Please Log in or Create an account to join the conversation.

More
4 months 1 week ago - 4 months 1 week ago #144981 by DaniSwos
Newcastle-Chelsea and Inter-Milan after the remapping
Attachments:
Last edit: 4 months 1 week ago by DaniSwos.

Please Log in or Create an account to join the conversation.

More
4 months 1 week ago - 4 months 1 week ago #144982 by DaniSwos
@thd79: Argentina-Milan clash is strange indeed! I think it is because white of Argentina shirt collides with Milan shorts and black of Milan shirt collides with Argentina shorts!
To avoid the clash, the following trick for example works: remapping as above, GREY used for Milan shorts and GREY remapped as white
Last edit: 4 months 1 week ago by DaniSwos.

Please Log in or Create an account to join the conversation.

More
4 months 1 week ago #144983 by DaniSwos
Argentina-Milan after remapping and "gray as white" trick
Attachments:

Please Log in or Create an account to join the conversation.

More
4 months 4 days ago #145015 by Tor
Very clever

Hopefully have this adjustment included in future releases?

Please Log in or Create an account to join the conversation.

More
4 months 2 days ago #145019 by thd79
Do you know the offset for the Amiga files? It would be great to patch the Amiga roms too :)

Please Log in or Create an account to join the conversation.

More
4 months 2 days ago - 4 months 2 days ago #145020 by DaniSwos
@thd79
For the Amiga, the offset is 1FBEC(hex) of the file SWOS2 **after having being unpacked** (all Amiga files are compressed, as far as I know with ProPack).
You will find the same byte string as in the dos version: 1 2 3 6 A B C D E F (hex)
For the last SWOS2020 version I have, the byte string is at offset 1DDE2B hex.
Please note that for this hack to work (on all Amiga, Dos and Swos2020 versions), not only the byte string above in the executable must be shuffled, but also all kits colors in all team.xyz files; changing only the executable or only the team files has just the effect of seeing scrumbled colors in the matches.

@tor
Thanks! I am afraid this hack is quite difficult to generalize, because for every chosen team a new different remapping may be more suitable than others. This could also depend on which specific matches you want to see with both home kits.
So, offering this as generic feature for the mean user is not that easy.
Last edit: 4 months 2 days ago by DaniSwos.

Please Log in or Create an account to join the conversation.

More
4 months 1 day ago #145025 by Playaveli
We are close to release. Check screenshot.

Please Log in or Create an account to join the conversation.

Time to create page: 0.227 seconds
Powered by Kunena Forum