heutekeinkoenig/hpCalcSim.py

75 lines
1.6 KiB
Python
Raw Normal View History

import random
from pyswip import Prolog as pl
import itertools as it
print("Consulting")
pl.consult("main.pl")
2023-06-05 11:12:18 +02:00
HPog = [1,2,3,5]
APog = [2,3,4,5]
HPmult = 2
APmult = 2
2023-06-05 12:44:57 +02:00
simRes = "AP:HP:HPnew\n"
2023-06-05 11:37:37 +02:00
2023-06-05 12:44:57 +02:00
print(simRes)
for i in range(0,4):
2023-06-05 11:12:18 +02:00
HP = HPog
AP = HPog
match i:
case 0:
2023-06-05 11:37:37 +02:00
caseString = "## Calculating without Multipliers ##"
print(caseString)
simRes += caseString
case 1:
2023-06-05 11:37:37 +02:00
caseString = "\n## Calculating with Attack Multipliers ##"
print(caseString)
simRes += caseString
AP = [point * 2 for point in AP]
case 2:
2023-06-05 11:37:37 +02:00
caseString = "\n## Calculating with Defense Multipliers ##"
print(caseString)
simRes += caseString
HP = [point * 2 for point in HP]
case 3:
2023-06-05 11:37:37 +02:00
caseString = "\n## Calculating with Attack and Defense Multipliers ##"
print(caseString)
simRes += caseString
AP = [point * 2 for point in AP]
HP = [point * 2 for point in HP]
2023-06-05 11:37:37 +02:00
itString = "\n-First Iteration-\n"
print(itString)
simRes += itString
liste = [AP, HP]
combinations = [p for p in it.product(*liste)]
newcombs = []
for comb in combinations:
for soln in pl.query("einheit_alive("+str(comb[0])+","+str(comb[1])+", HPnew)"):
2023-06-05 11:37:37 +02:00
tmpStr = str(comb[0]) + ":" + str(comb[1]) + ":" + str(soln["HPnew"]) + "\n"
print(tmpStr)
simRes += tmpStr
newcombs.append((comb[0], soln["HPnew"]))
2023-06-05 12:46:47 +02:00
itString = "-Second Iteration-\n"
2023-06-05 11:37:37 +02:00
print(itString)
simRes += itString
for comb in newcombs:
for soln in pl.query("einheit_alive("+str(comb[0])+","+str(comb[1])+", HPnew)"):
2023-06-05 11:37:37 +02:00
tmpStr = str(comb[0]) + ":" + str(comb[1]) + ":" + str(soln["HPnew"]) + "\n"
print(tmpStr)
simRes += tmpStr
2023-06-05 12:46:47 +02:00
with open("AttackSimulationResults.txt", "w") as w:
2023-06-05 11:37:37 +02:00
w.write(simRes)