Guest User

Untitled

a guest
Feb 26th, 2025
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. fun `King of Tokyo Duel`() {
  2. val iterations = 1000000
  3. val dice = 6
  4. val rolls = 3
  5.  
  6. val map = mutableMapOf<Int, Int>()
  7.  
  8. var i = iterations
  9. while (i != 0) {
  10. var attack = 0
  11. var exclam = 0
  12. var currentRoll = 0
  13. while (currentRoll != rolls) {
  14. val activeDice = dice - attack - exclam
  15. for (i in 1..activeDice) {
  16. val rand = Random.nextInt(1, 7)
  17. if (rand == 1) {
  18. attack++
  19. }
  20. if (rand == 2) {
  21. exclam++
  22. }
  23. }
  24. currentRoll++
  25. }
  26. val damage =
  27. if (exclam == 0) {
  28. attack
  29. } else {
  30. attack * exclam
  31. }
  32. map[damage] = map.getOrDefault(damage, 0) + 1
  33. i--
  34. }
  35.  
  36. val sum = map.map { it.key * it.value }.sum()
  37. val percentagemap = map.mapValues { it.value.toDouble() / iterations }
  38. val average = sum.toDouble() / iterations
  39. }
Advertisement
Add Comment
Please, Sign In to add comment