Question about D12 Programming
  • 19 posts
  • Page 1 of 2
Clarke wrote:
Note: For the purpose of this post, I am going to refer to "wild" cards in the Risk board game as "black" cards since that is what we call them on D12.

In the original board game of Risk, there are 2 black cards and 40 "non-black" cards. That is a black card percentage of 4.8%. My question is, what is the black card percentage used in the programming on D12?

I know that since maps have different number of territories, the number will fluctuate a little, but approximately what percentage does D12 just to follow?

(Note: Just counted the cards in Classic Map, and found it is 7.1%)

To all who are wondering why I ask, this is an important thing to know when trying to evaluate odds of your opponent having a set or a black card.

THANKS!!!
Matty wrote:
Now this is a very good question, and I don't know the answer.

So I queried the database, and there are in total 1957 cards, of which 85 are black.
So 85/1957*100% = 4.3%.


For the classic world map there should be 3 black cards though.

Another weird thing, Afrika seems to only have 1 black card.
Maybe I have the wrong table here :S.
"Strength doesn't lie in numbers, strength doesn't lie in wealth. Strength lies in nights of peaceful slumbers." ~Maria
Vexer wrote:
Wow, i finally found the code the determine the card color and it has several flaws. It turns out that there isn't 1 wild per so many territories. It's actually an overly complicated algorithm that ends up creating less wilds per territory as the map size increases. But it doesn't even do that correctly because of a rounding error. Sometimes you end up with only 1 wild and most of the time you have 1 more green card than the other colors.

I'm going to have to rewrite the code. I don't think it should be 1 wild for every 13. My risk set has 2 wilds for the world map which has 42 territories. So I think it should be 1 wild for every 21 territories. But it will need to be rounded properly (using php round() not floor()) like this: Number of wilds = round(number of territories/21). So, for example, Eld World has 41 territories. 41/21 = 1.95, rounded = 2. Caribbean has 26 territories, 26/21 = 1.24, rounded = 1. Africa = 71/21 = 3.38 = 3. World Expanded = 91/21 = 4.33 = 4. I'll also randomize the colors in such a way that if there's an extra card it won't always end up green.

Fixing the code is the easy part. Fixing the maps that are already in use is the hard part.
cbt711 wrote:
So when picking out sets from 5 cards, be sure to do so leaving green as what you need for the three card set in the mean time? :-D
Vexer wrote:
yep. there is a slightly higher probability of getting a green card, but not for long. I'm about half done fixing this.
Vexer wrote:
Ok, I've got the cards fixed.
This is a list of all the current maps.

Map name, number of wilds, number of territories, likelihood of getting a wild.

World Classic , 2 , 42 , 4.76%
Isthmus of Panama , 1 , 28 , 3.57%
USA , 2 , 45 , 4.44%
Africa 1890 , 3 , 71 , 4.23%
Oregon Cities (Advanced) , 2 , 35 , 5.71%
House , 2 , 41 , 4.88%
Saturn , 1 , 30 , 3.33%
Eld World HD , 2 , 41 , 4.88%
Caribbean , 1 , 26 , 3.85%
Great Britain and Ireland , 2 , 39 , 5.13%
DXII Stadium , 3 , 58 , 5.17%
Basketball , 2 , 42 , 4.76%
Caribbean Double , 2 , 46 , 4.35%
Mediterranean States , 3 , 66 , 4.55%
Victron , 3 , 63 , 4.76%
World Expanded , 4 , 91 , 4.40%
South Africa Districts , 2 , 47 , 4.26%
Europe 1814 (HD) Advanced , 3 , 55 , 5.45%
Falkland Islands , 2 , 42 , 4.76%
United States , 2 , 43 , 4.65%
Eastern Asia , 2 , 52 , 3.85%
Tor , 2 , 42 , 4.76%
World Modified , 2 , 43 , 4.65%
Dominican Republic , 2 , 32 , 6.25%
Europe , 2 , 48 , 4.17%
Jungle of Despair , 3 , 60 , 5.00%
Tamriel , 3 , 66 , 4.55%
Westeros , 4 , 94 , 4.26%
Realm of Honored Players , 3 , 59 , 5.08%
San Francisco , 3 , 59 , 5.08%
Central America , 2 , 35 , 5.71%
New York City , 4 , 75 , 5.33%
Korea - Japan , 2 , 52 , 3.85%
Brazil , 2 , 39 , 5.13%
Ancient Realm , 1 , 30 , 3.33%
Clarke wrote:
I hate to ask this Vexer, but I am a math geek and hate leaving ANYTHING unknown if the answer is knowable. So here is the question:

For every map in which the total territories less the wild cards leaves a number not perfectly divisible by 3, what color are the extra cards. BTW - I assume that if divisible perfectly by 3, there is an even number of red, green, and blue.

Does the programming say "if there is one extra, make it green" and "if there are 2 extra make them green and red"... Just curious. On a small map like Caribbean, which has 25 colored cards and 1 wild card, knowing which color has 9 cards and the other two colors only 8 might help us decide which cards to play...

Anyway, I am sorry if my initial inquiry opened a can of worms and caused you to have to fix this. I was really just trying to better understand the probability of my opponent having a set with 3 cards or not having a set with 4... You get the point.

Thanks!
Vexer wrote:
I changed the code to make the extra 1 or 2 territories random colors instead of always green and red.

I'm glad you asked this because I discovered that in the case where there were 2 extra it could randomly choose the same color card both times. So I manually edited the color of a few cards to balance it out.

Here's a list of the maps that don't have an even number of each card and which color there is 1 more of.

World Classic red
USA red
Africa 1890 green, blue
Saturn red, blue
Caribbean red
Great Britain and Ireland green
DXII Stadium red
Basketball red
Caribbean Double green
Europe 1814 (HD) Advanced green
Falkland Islands green
United States red, blue
Eastern Asia red, blue
Tor blue
World Modified red, blue
Europe red
Realm of Honored Players red, blue
San Francisco red, blue
New York City green, blue
Korea - Japan green, red
Brazil red
Ancient Realm green, blue

HiErebody wrote:
Vexer, maybe I'm missing something, if you made the extra card or two random, why would you manually code those cards in those maps?

I think it's easier for players to understand that in general 1) there's an even number of colors per map, 2) when there isn't a perfecly even number, the computer will randomly select the color with an equal chance for each color (33.3%) each time. This will sometimes result in the same color twice. 

While that doesn't make for an even number of colors, it does make for an even strategy. 

If I'm understanding your post correctly, certain maps have hard-coded extra colors, and we need to refer to (or memorize) this list to take advantage of that. Or be in a disadvantage? 

HiErebody wrote:
wait a minute, am I completely missing how the cards work?? 
Is each card not randomly assigned one of three colors? as in, each territory can only appear once (until turned back in) but that each card received has an equal chance of being 1 of 3 colors? 

How do I not know how this works yet....
Vexer wrote:
The card colors are hard coded and are the same each game. For most maps they work just like a deck of cards meaning you wait until all the cards have been turn in before reshuffling the deck. However, on small maps with too many players you can get the same card twice as if there were 2 decks.

Since the colors are hard coded some maps will have more of one color than another. There is no way around this.
HiErebody wrote:
Thanks for the reply Vexer,

Wouldn't the way around it to just allow the extra 1 or 2 be randomly selected colors (RBG) with equal chances? (Each time the game is started)

Even though there is the problem that 2 of the same colors can be randomly assigned to those maps with 2 extra cards, I would think that gives all players an equal strategy. (As long as this randomization happens each time a new game is started [33% chance each time], and not set for each map)
  -- maybe this is not feasible in the coding?

My only real issues, is I just happened upon this forum post by accident. I now know which maps have an extra color card. It's not a huge advantage, only a slight one, but still a slight one. 
A new person, or people who don't frequent the forum don't have this advantage.
  -- Maybe, alternatively, we can put in each game (maybe on the notes tab) what the extra card colors are? and direct them to this forum post?