Given a string representing the current state of a game of Monopoly at the beginning of a player's turn, compress all the necessary data into the smallest output. Answers will be judged by output size and source size.
Note: There are many regional variations, but all references in this post to property names, etc, are based on this board.
Input:
Input will be given as a single ;
separated string. This string is given to the program in whatever way is customary in your chosen language, whether that's stdin, arguments, etc.
The unformatted input looks like this:
numPlayers (1 to 8)
whose turn (0 to numPlayers-1)
for each player:
bankrupt? (true/false)
money (0 to 2^16-1)
get-out-of-jail-free cards (0 to 2)
position (0 to 39)
jail turns (-1 to 2)
for 28 properties:
owner (-1 to numPlayers-1)
mortgaged? (true/false)
improvement level (0 to 5)
for 16 chance cards in deck:
card index (-1 to 15)
for 16 community chest cards in deck:
card index (-1 to 15)
An example formatted input is this:
3;1;false;1546;0;14;-1;false;7692;1;10;1;true;1;false;1;1;false;0;0;true;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;-1;false;0;0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;3;12;7;4;5;2;13;11;15;6;8;9;10;1;14;-1;
Taken bit by bit:
3;1;
There are 3 players, and it is player 1's turn (zero-indexed, so the second player)
Players
false;1546;0;14;-1;
false;7692;1;10;1;
true;
The first player:
- is not bankrupt
- has $1546 cash on hand
- owns 0 get-out-of-jail-free cards
- is on position 14 (Virginia Ave)
- is not in jail
The second player is in jail, and has been for one turn. I'm not sure why, since he has a GOoJF card, but he's there.
The third player is bankrupt, and more information is neither required nor given.
Properties
1;false;1;
1;false;0;
0;true;0;
-1;false;0;
-1;false;0;
-1;false;0;
...
Properties are listed in order around the board, starting from Mediterranean and ending at Boardwalk. Properties that cannot be owned are not included in this list, so there will be a total of 28. Improvement level 0
means unimproved. Level 1
is one house, up to level 5
for a hotel. A -1
for owner means it is not owned by any player.
According to standard rules, a property that is mortgaged must be owned and must not be improved. A property that is improved must be owned and must not be mortgaged.
In addition, for a property to be improved, a player must own the entire color block. For the purposes of this game, we do not care if properties are being improved "evenly".
Note that these positions are not the same as the player positions given above. For instance, a player on the 5
position would be on Reading Railroad, which is the third property in the list (since Go, Community Chest, and Income Tax cannot be owned). Player positions run from 0
(Go) clockwise to 39
(Boardwalk).
Cards
0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;
3;12;7;4;5;2;13;11;15;6;8;9;10;1;14;-1;
Each of the Chance and Community Chest decks have 16
total cards. The numbers are presented as they appear in the currently shuffled deck. For this example, the first card pulled off the Chance deck will be card 0
, followed by card 1
(whoever shuffled that deck sucks). The first card pulled from Community chest is card 3
, then 12
.
Don't worry about what each card means (the card text), except for card 0
. That is the Get Out of Jail Free card for that deck. If a player owns it, it will be at the end of the list, represented as -1
.
Output:
You must output (to console, stdout, or file) a representation of the game state. This must include all information required to represent the game. For example, you could omit (or abbreviate) unowned properties, since they can neither be improved or mortgaged. The input cannot omit them because it is an unindexed list.
Compression should be done in a way that you can compute worst-case output size. This may disqualify certain compression algorithms (unless you can prove the worst case, and give an example of worst-case input).
Unless your source code is unreasonably verbose, give an explanation of how the game is represented. Answers consisting of nothing but a golfed program and compressed output are discouraged. For example, if you are omitting certain values, explain how it is possible to derive them from the output.
Scoring/Rules:
Scoring is based both on worst-case compression size in bits, and source code size in bytes:
score = (outputBits * 2) + encoderSourceBytes
A complete answer must include:
- Output example
- Encoder source
- Decoder source (not counted against score)
All encoders must be complete programs, and standard loopholes are forbidden. Using built-in or external compression libraries is also forbidden.
The winner is the answer with the lowest score, as defined above.
The second player is in jail, and has been for one turn. I'm not sure why, since he has a GOoJF card, but he's there.
Being in jail is good lategame because you're not paying rent. :) \$\endgroup\$