GameContext getDeckCombinations combinations error
AlexEltonPym opened this issue · 1 comments
AlexEltonPym commented
Calling simulate is triggering NumberIsTooLargeException: must have n >= k for binomial coefficient (n, k), got k = 2, n = 0
Reproduction steps:
From python virtual env run some simulation:
from tqdm import tqdm
from spellsource.context import Context
from spellsource.utils import simulate
TOKEN_DRUID = 'AAECAZICBPcD9fwCm8sCmdMCDZjSAuQI5gWe0gL9Ao7QAkDX7wLb0wJfoM0C4vgCh84CAA=='
DEATHRATTLE_HUNTER = 'AAECAR8Klwic4gLTxQKA8wKggAOG0wLL7ALGwgK26gL4CArh4wKNAZzNAqvCAt4FufgC2MIC3dICi+EC8vECAA=='
decks = [TOKEN_DRUID, DEATHRATTLE_HUNTER]
behaviours = ['GameStateValueBehaviour', 'GameStateValueBehaviour']
with Context() as context:
simulation_results = list(tqdm(simulate(context=context, decks=decks, number=10, behaviours=behaviours)))
Console error:
Traceback (most recent call last):
File "aepSimulate.py", line 23, in <module>
simulation_results = list(tqdm(simulate(context=context, decks=decks, number=10, behaviours=behaviours)))
File "/Users/aep/phd/code/hearthsim/Spellsource/.venv/lib/python3.8/site-packages/spellsource/utils.py", line 112, in simulate
generator.job_id = PythonBridge.simulate(generator, decks_java, number, behaviours_java, mirrors, reduce)
File "/Users/aep/phd/code/hearthsim/Spellsource/.venv/lib/python3.8/site-packages/py4j/java_gateway.py", line 1285, in __call__
return_value = get_return_value(
File "/Users/aep/phd/code/hearthsim/Spellsource/.venv/lib/python3.8/site-packages/py4j/protocol.py", line 326, in get_return_value
raise Py4JJavaError(
py4j.protocol.Py4JJavaError: An error occurred while calling z:com.hiddenswitch.spellsource.net.applications.PythonBridge.simulate.
: org.apache.commons.math3.exception.NumberIsTooLargeException: must have n >= k for binomial coefficient (n, k), got k = 2, n = 0
at org.apache.commons.math3.util.CombinatoricsUtils.checkBinomial(CombinatoricsUtils.java:455)
at org.apache.commons.math3.util.Combinations.<init>(Combinations.java:106)
at org.apache.commons.math3.util.Combinations.<init>(Combinations.java:76)
at net.demilich.metastone.game.GameContext.getDeckCombinations(GameContext.java:1763)
at com.hiddenswitch.spellsource.util.Simulation.getCombinations(Simulation.java:89)
at com.hiddenswitch.spellsource.net.applications.PythonBridge.simulate(PythonBridge.java:70)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
at py4j.Gateway.invoke(Gateway.java:282)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:238)
at java.base/java.lang.Thread.run(Thread.java:832)
Platform: Mac 10.15.4,
java -version
openjdk 14.0.1 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+14)
OpenJDK 64-Bit Server VM (build 14.0.1+14, mixed mode, sharing)
doctorpangloss commented
Message me on Discord for the solution! We are active 10am-6pm PST every weekday + Saturday. https://discord.gg/HmbESh2