Hello,
Background: I come from a decade+ of Flash & Actionscript experience. I have about 100+ hours into Unity and learning C# so far. I’ve gotten past many hurdles that have allowed me to make good progress on a 2D poker game.
I have converted a Poker hand evaluator from Actionscript 3 to C#, to the extent that the IDE is no longer reporting any errors, and so I’m now starting unit testing of some of the key parts of this evaluator. (Original AS3 is here: GitHub - houen/PokerFace: Actionscript 3 poker hand strength evaluation library and OO wrappers )
I’ve hit a wall fairly fast with some large (but not insanely large) data lists. In AS3 these were untyped Arrays:
flushes: 7937
perm7: 21
primes: 13
products: 4888
unique5: 7937
values: 4888
In C# I defined each one as a public static List typed for int or uint (depending on which one it is). Couple examples (truncated):
public static List<int> primes = new List<int> {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41};
public static List<uint> flushes = new List<uint> {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1599, 0, 0, 0, 0, 0, 0, 0, 1598, 0, 0, 0, 1597, 0, 1596,
8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1595, 0, 0, 0,
0, 0, 0, 0, 1594, 0, 0, 0, 1593, 0, 1592, 1591, 0, 0, 0, 0, 0, 0, ...
So far so good, but I get a very cryptic error when I try to access one of these Lists from my gamecontroller:
InvalidProgramException: Method CactusArrays:.cctor () is too complex.
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for CactusArrays
UnityEngine.Events.InvokableCall.Invoke (System.Object[ ] args)
(CactusArrays is the name of this class). I did many searches and some reading that lead me to believe that thousands-long data definitions of Lists should probably be moved to Start(), but my attempt to do that lead to different errors saying there was no object instance…
Anyways, I’m hitting a wall and have gone in circles a couple times. Does anyone have any advice? Should I be using a different kind of Array substitute, maybe List isn’t meant to be very long? Maybe I should be defining the length first??
I will note that in AS3 there are no issues, no slow-down so that leads me to believe this is not a memory limit issue. But who knows. Different engine, different language, different beast.