-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Casting error from Enchantment to ICharacter. #183
Comments
Can you publish the code that triggers this exception? It will help with discovering where the issue lies. |
So I checked the MASTER ref on your EvoStone fork (https://github.com/lunjohnzhang/EvoStone/tree/a0eb3eb8594fa0d32a49a3c6f99abc056b41eb7d) as is. My worker did a complete run with Evolution as strategy. There weren't any crashes. |
Sorry for the late reply, I was doing something else over the past week. I have opened another branch here that contains the code to reproduce the error. Commit hash: lunjohnzhang/EvoStone@02ac556 To run it, make sure that The code is running one round of 200 games between the deck inside Thank you very much for you help and feel free to ask me any questions regarding this project. |
So we're specifically looking for an error that isn't 100% reproducible. This happens during a serialized run of 200 games. I'm running now. Hopefully I'll get some reproduction this evening. |
Ok, so the casting happens here: https://github.com/HearthSim/SabberStone/blob/master/SabberStoneCore/src/Model/Game.cs#L499 The PlayerTask has been calculated from a different game. It's applied to another game that has forked off and potentially desynced somehow. The target identifier within the gameTask points to a non-character in the forked game. I don't know if this is intended and badly handled or unintentional. Using git blame appoints @rnilva with this commit 6a08c57 |
Hello,
We have implemented a .NETCore Evaluator to iteratively run games. When we try to use the
Game.Process(PlayTask gameTask)
function to process a game, .NET gives us this error after certain iterationsUnhandled Exception: System.AggregateException: One or more errors occurred. (Unable to cast object of type 'SabberStoneCore.Model.Entities.Enchantment' to type 'SabberStoneCore.Model.Entities.ICharacter'.) ---> System.InvalidCastException: Unable to cast object of type 'SabberStoneCore.Model.Entities.Enchantment' to type 'SabberStoneCore.Model.Entities.ICharacter'.
at SabberStoneCore.Model.Game.Process(PlayerTask gameTask) in /Users/yulunzhang/Desktop/Coding/icaros/hearthstone/SabberStone/SabberStoneCore/src/Model/Game.cs:line 486
at DeckEvaluator.Evaluation.GameEvaluator.PlayGame() in /Users/yulunzhang/Desktop/Coding/icaros/hearthstone/EvoStone/DeckEvaluator/src/Evaluation/GameEvaluator.cs:line 165
at DeckEvaluator.Evaluation.GameDispatcher.runGame(Int32 gameId, GameEvaluator ev) in /Users/yulunzhang/Desktop/Coding/icaros/hearthstone/EvoStone/DeckEvaluator/src/Evaluation/GameDispatcher.cs:line 72
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0
1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) --- End of stack trace from previous location where exception was thrown --- at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0
1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)at System.Threading.Tasks.TaskReplicator.Replica
1.ExecuteAction(Boolean& yieldedBeforeCompletion) at System.Threading.Tasks.TaskReplicator.Replica.Execute() --- End of inner exception stack trace --- at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction
1 action, ParallelOptions options, Boolean stopOnFirstFailure)at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action
1 body, Action
2 bodyWithState, Func4 bodyWithLocal, Func
1 localInit, Action1 localFinally) --- End of stack trace from previous location where exception was thrown --- at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException) at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action
1 body, Action2 bodyWithState, Func
4 bodyWithLocal, Func1 localInit, Action
1 localFinally)at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body)
at DeckEvaluator.Evaluation.GameDispatcher.Run() in /Users/yulunzhang/Desktop/Coding/icaros/hearthstone/EvoStone/DeckEvaluator/src/Evaluation/GameDispatcher.cs:line 127
at DeckEvaluator.Program.Main(String[] args) in /Users/yulunzhang/Desktop/Coding/icaros/hearthstone/EvoStone/DeckEvaluator/src/Program.cs:line 119
[1] 78423 abort dotnet bin/DeckEvaluator.dll 1
This error exposes a casting error in Game.cs, but when we look through the source code of SabberStone it doesn't seem to have such a casting on the specified place (line 486 of Game.cs). We will appreciate if you can help us with this.
SabberStone version: 2.1.0 (we pull the code from master and compiled it)
.NETCore version: 2.1
The text was updated successfully, but these errors were encountered: