JSFiddle - React, Tailwind, and code Playground

by XarX

HTML

<pre id=painted></pre>

JavaScript

var _painted = 0, $painted = document.getElementById('painted');

var runs = 100000,
archers = 10,
archersMax = 30,
toHit = 4,
toWound = 4,
enemySave = 4,
enemySaveMax = 6,
wounds = 0;

$painted.textContent+= "ToHit    : " + toHit + "+\n";  
$painted.textContent+= "ToWound  : " + toWound + "+\n";  
   

for (save=enemySave;save<=enemySaveMax;save++) {
  $painted.textContent+= "\nEnemySave    : " + save + "+\n\n";  
	wounds = 0;
  for (archer=archers;archer<=archersMax;archer+=10) {
  	$painted.textContent+= "Archers    : " + archer + "\n";
    var wounds = 0;
    for (i=0;i<runs;i++) {
      for (j=0;j<archer;j++) {
        var dice = Math.floor(Math.random()*6+1);
        if (dice >= toHit) {
       		dice = Math.floor(Math.random()*6+1);
          if (dice >= toWound) {
            var dice = Math.floor(Math.random()*6+1);
            if (dice < save) {
              wounds+=1/runs;
            }
        	}
        }
      }
    }
    $painted.textContent+= "Wounds Avg.: " + Math.floor(1000*wounds)/1000 + "\n";  
  }
}