Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Thursday, July 26, 2012

Risk Battle Statistics and Simulator

Number of Attackers: Offensive Airfield
Number of Defenders: Defensive Airfield

Offense Rolls:
Defense Rolls:
Offense Wins:
Defense Wins:
Cumulative Offense Wins: 0
Cumulative Defense Wins: 0
Offensive Kill-Death Ratio: NA


I was trying to find an image to put above and then I had the bright idea to code the above simulator. After an embarrassingly long amount of time due to my Javascript inexperience, it is done. An explanation of how battle works in Risk is at the bottom following the *

A long time ago I wrote a post that contained some probability calculations associated with the popular board game Risk. This was long before I knew how to format things nicely on the internet and before I was aware of some other things. That said, I think that I can approach the content and its presentation much better now than I could then so I've redone the post.

The original post was focused on showing that you should always choose to attack and defend with as many units as you can, that the odds work out best for you that way. This means that the offense should always attack with 3 if possible and the defense should always defend with 2.

It turns out that the latest version of the Risk rules (which are the rules used in Risk: Factions, a downloadable title for the PS3 and XBox 360) can have situations which modify your battles. Fulfilling certain objectives can allow a player to attack with up to 4 soldiers or defend with up to 3. Furthermore, the player can obtain an airport which bestow a +1 bonus to that player's highest die roll when attacking or defending for any battle that takes place on or adjacent to the territory which has the airport.

I decided that I wanted to see how these variables affect the probabilities of success and the kill-death ratio for the offense. To quickly explain the data in the chart:
  • Most entries fall under "X Kills" which is the probability that under those circumstance the offense will kill X of the defender's pieces. Remember that if the offense doesn't kill a defender's piece then the defender kills a piece belonging to the offense.
  • KDR stands for Kill-to-Death Ratio and is how many pieces the offense should expect to kill for every piece they expect to lose. For example, in the 3 vs 2 matchup with an airport for the offense, the offense should expect to kill almost 2 of the defender's pieces for each piece they lose. A KDR>1 is good for the offense. A KDR<1 is good for the defense.

Probability of offense winning X rolls and KDR
3 vs 2
2 Kills1 Kill0 KillsKDR
Normal37%34%29%1.17
Off +151%31%18%1.97
Def +124%41%35%0.80
3 vs 3
3 Kills2 Kills1 Kill0 KillsKDR
Normal14%21%26%38%0.58
Off +120%25%31%24%0.88
Def +18%21%27%45%0.44
4 vs 2
2 Kills1 Kill0 KillsKDR
Normal46%33%21%1.67
Off +163%25%12%3.11
Def +130%45%25%1.09
4 vs 3
3 Kills2 Kills1 Kill0 KillsKDR
Normal25%26%25%24%1.03
Off +137%25%24%14%1.61
Def +114%31%27%28%0.78

There's nothing surprising here, but it is very interesting to see how much of an advantage the offense has in the normal situation and how much that advantage changes depending on various conditions. There is another advantage that the offense has that isn't discussed here. The offense gets to choose when and where they attack, which allows the to pick battles that they are fairly certain they can win. Play wisely, everyone.

*In classic Risk the objective is to conquer all the territory on the map. You do this by engaging your enemies in battle. To do this you select up to three units on a territory you control to attack an adjacent territory. The owner of that territory can defend with up to two units (these numbers can be increased under certain conditions)

Each player rolls a die for each unit they are attack/defending with and sorts them from highest to lowest. The compare matching dice and if the offense's roll is higher than the defense's the defense loses a piece. If the defense's is higher or there is a tie, then the offense loses a piece. This repeats until the defender loses all their pieces on the territory or the offense gives up.

Example: The offense attacks with 3 pieces and the defense defends with 2. Their rolls are
  • Offense: 4 6 2
  • Defense: 5 4
Sorted, the offense has 6, 4 and 2 and the defense has 5 and 4. The offense's 6 beats the defense's matching 5 but the defense's 4 beats the offense's matching 4 since the defense wins ties. Both sides lose a piece. The 2 is ignored.

Saturday, March 31, 2012

Thrill Digger


Rupees: 140 Games: 1
Bombs: 6 Rupoors: 6
Safe Remaining: 28 Hazards remaining: 12

The Rules of Thrill Digger

Thrill Digger could be described as "minesweeper with uncertainty." When you click on a cell, instead of displaying a number that tells how many bombs surround that cell, a color is revealed that provides vaguer information about how many hazards surround that cell. The colors are:
  • Green: Zero hazards, is worth 1 rupee
  • Blue: 1-2 hazards, is worth 5 rupees
  • Red: 3-4 hazards, is worth 20 rupees
  • Silver: 5-6 hazards, is worth 100 rupees
  • Gold: 7-8 hazards, is worth 300 rupees
I say hazards because there are bad things other than bombs. Bombs, like in minesweeper will end your current game. There are other hazards called Rupoors which instead of increasing your rupee count will decrease your rupee count by 10.

What are rupees for?

The game is hard, and your chance of winning a particular game is very low. A new game costs you 70 rupees and the real goal is how many games you can play before not being able to pay for a new game. So your real goal is to get as many rupees as possible before hitting a bomb.

Differences between Skyward Sword and this version

In Skyward Sword, after you dug up a spot, the game wouldn't leave a reminder of what you had dug up there. This made the game excruciatingly hard because it's really hard to remember so many things. Furthermore, there was no way to mark a location where you thought a bomb to be located. Lastly, I took Skyward Sword's Expert difficulty and adjusted it down a bit to a level that I find to be much better. Lastly, in my version, your first click will never be a hazard, which is very important in minesweeper-esque games.

To mark cells as dangerous, toggle the "Digging" button and then click the ones that have hazards.

I may come back and update this with more features or a better look. But right now it is without bugs (as far as I know) and fully playable.