2023-06-05 10:36:36 +02:00
|
|
|
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]
|
2023-06-05 10:36:36 +02:00
|
|
|
|
|
|
|
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)
|
2023-06-05 10:36:36 +02:00
|
|
|
|
|
|
|
for i in range(0,4):
|
2023-06-05 11:12:18 +02:00
|
|
|
HP = HPog
|
|
|
|
AP = HPog
|
2023-06-05 10:36:36 +02:00
|
|
|
match i:
|
|
|
|
case 0:
|
2023-06-05 11:37:37 +02:00
|
|
|
caseString = "## Calculating without Multipliers ##"
|
|
|
|
print(caseString)
|
|
|
|
simRes += caseString
|
2023-06-05 10:36:36 +02:00
|
|
|
|
|
|
|
case 1:
|
2023-06-05 11:37:37 +02:00
|
|
|
caseString = "\n## Calculating with Attack Multipliers ##"
|
|
|
|
print(caseString)
|
|
|
|
simRes += caseString
|
2023-06-05 10:36:36 +02:00
|
|
|
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
|
2023-06-05 10:36:36 +02:00
|
|
|
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
|
2023-06-05 10:36:36 +02:00
|
|
|
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
|
2023-06-05 10:36:36 +02:00
|
|
|
|
|
|
|
liste = [AP, HP]
|
|
|
|
combinations = [p for p in it.product(*liste)]
|
|
|
|
|
2023-06-05 11:30:50 +02:00
|
|
|
newcombs = []
|
|
|
|
|
|
|
|
for comb in combinations:
|
2023-06-05 10:36:36 +02:00
|
|
|
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 11:30:50 +02:00
|
|
|
newcombs.append((comb[0], soln["HPnew"]))
|
2023-06-05 10:36:36 +02:00
|
|
|
|
2023-06-05 11:37:37 +02:00
|
|
|
itString = "\n-Second Iteration-\n"
|
|
|
|
print(itString)
|
|
|
|
simRes += itString
|
2023-06-05 11:30:50 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
with open("res.txt", "w") as w:
|
|
|
|
w.write(simRes)
|