simple melee mechanics should be efficiently simulatable? easily simulated? it's past my bedtime
This commit is contained in:
parent
8892f684e8
commit
ac5aec6cb4
@ -1,7 +0,0 @@
|
||||
import game_logic.runescape.RunescapeRoutines
|
||||
|
||||
fun main() {
|
||||
RunescapeRoutines.fullRunIncense( 0, 0, 0, 1839)
|
||||
// RunescapeRoutines.processInventoryAtFurnace(2500)
|
||||
}
|
||||
|
||||
29
src/main/kotlin/entries/BGSimulation.kt
Normal file
29
src/main/kotlin/entries/BGSimulation.kt
Normal file
@ -0,0 +1,29 @@
|
||||
package entries
|
||||
|
||||
import simulation.*
|
||||
|
||||
fun main(){
|
||||
val start = System.currentTimeMillis()
|
||||
doSimulation()
|
||||
val finish = System.currentTimeMillis()
|
||||
println("Simulation finished in: ${finish-start}ms")
|
||||
}
|
||||
|
||||
fun doSimulation(){
|
||||
val itt = 10_000_000
|
||||
val simulator = Simulator.getInstance<AttackResult>(Runtime.getRuntime().availableProcessors())
|
||||
|
||||
val critAttack = SimpleMeleeAttack(
|
||||
actionRoll = AttackDice("1d20"),
|
||||
damageRoll = Dice.makeDice("1d8"),
|
||||
10
|
||||
)
|
||||
|
||||
|
||||
|
||||
val normalAttackModel = AttackSimulatorModel(itt, critAttack)
|
||||
val normalResults = simulator.doSimulation(normalAttackModel)
|
||||
|
||||
|
||||
AttackResult.printSimulationStatistics(normalResults, "Normal Attack")
|
||||
}
|
||||
8
src/main/kotlin/entries/FurnaceEntry.kt
Normal file
8
src/main/kotlin/entries/FurnaceEntry.kt
Normal file
@ -0,0 +1,8 @@
|
||||
package entries
|
||||
|
||||
import game_logic.runescape.RunescapeRoutines
|
||||
|
||||
|
||||
fun main() {
|
||||
RunescapeRoutines.processInventoryAtFurnace(1839)
|
||||
}
|
||||
12
src/main/kotlin/entries/IncenceEntry.kt
Normal file
12
src/main/kotlin/entries/IncenceEntry.kt
Normal file
@ -0,0 +1,12 @@
|
||||
package entries
|
||||
|
||||
import game_logic.runescape.RunescapeRoutines
|
||||
|
||||
|
||||
fun main() {
|
||||
RunescapeRoutines.fullRunIncense(0, 0, 0, 1839)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,21 @@
|
||||
package simulation
|
||||
|
||||
/**
|
||||
* AttackDice class represents dice used for attack rolls.
|
||||
* If the roll string contains a 'c' modifier, the value after 'c' is used as the crit threshold.
|
||||
* Otherwise, the crit threshold defaults to the max possible roll (number of dice * die size).
|
||||
*
|
||||
*
|
||||
* Example rollStrings:
|
||||
*
|
||||
* "1d20"
|
||||
*
|
||||
* "1d20c18"
|
||||
*
|
||||
* "3d8c15"
|
||||
*
|
||||
* The isCrit() method checks if a roll result meets the crit threshold.
|
||||
*/
|
||||
class AttackDice(
|
||||
override val rollString: String,
|
||||
override val rollType: RollType = RollType.Normal,
|
||||
@ -23,11 +39,21 @@ class AttackDice(
|
||||
val parts = cleanRollString.split('d')
|
||||
nDice = parts[0].toInt()
|
||||
dieSize = parts[1].toInt()
|
||||
critThreshold = dieSize
|
||||
critThreshold = dieSize * nDice
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the given [RollResult] meets or exceeds the critical hit threshold
|
||||
* for these attack dice.
|
||||
*
|
||||
* The critical hit threshold is determined based on the roll string used to construct
|
||||
* this [AttackDice] instance.
|
||||
*
|
||||
* @param result The [RollResult] to check for crit.
|
||||
* @return True if result meets or exceeds the crit threshold.
|
||||
*/
|
||||
fun isCrit(result: RollResult): Boolean {
|
||||
return result.result >= critThreshold
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user