This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
#Dice funtion. Leave sides flexible for alternate rules analysis. | |
dice<-function(rolls,sided=6){ | |
#Sorted rolls | |
sort(sample(1:sided,rolls, replace=TRUE),decreasing=TRUE) | |
} | |
#Function to choose attacker dice. | |
chooseAttackDice<-function(attackArmies){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var war = function(attackArmies,defenseArmies){ | |
var battle=function(attack,defense){ | |
var a=0; | |
var d=0; | |
//roll attack dice | |
var attackDice= new Array(); | |
for (a=1; a <= attack; a++){ | |
attackDice[a]=Math.floor(Math.random()*6)+1; |