nalka
nalka
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
Kind of workarounded it by restarting the sim with depth -1 when it returns no results
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
Yeah or maybe try storing potential results for depth X and then trying if depth X +1 exists until either depth X + 1 doesn't exist or maxDepth is reached 🤔 Though that sounds like the starting approach that was traversing a whole depth before going to the next one
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
By "WAY more work", do you mean we'd back to the point where I was before asking? aka spamming lists so much that I run out of memory?
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
Don't see how it fixes the actual depth lower than max depth problem given results are still built only when maxDepth is reached 🤔
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
Looks like it's still bugged when actual depth is lower than maxDepth, at that point it returns 0 results
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
looks like adding
if (nextNodeIndex >= nextNodes.Count)
{
goto DEPTH_RETURN;
}
if (nextNodeIndex >= nextNodes.Count)
{
goto DEPTH_RETURN;
}
Before the line it crashes on fixes it, but given I don't have a full understanding of your code yet, not sure if it's enough/doesn't break other stuff
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
On the other hand, cool thing is it can be used with pre-calculated .NextNodes (even if I guess your caching system probably becomes unneeded since the cache is already in the pre-calc) pretty easily since I just have to implement like that
public sealed class TestSimulator : Simulator<Node>
{
protected override IReadOnlyList<Node> GetNextNodes(Node node) => node.NextNodes;
}
public sealed class TestSimulator : Simulator<Node>
{
protected override IReadOnlyList<Node> GetNextNodes(Node node) => node.NextNodes;
}
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
Played around with your impl a little, it crashes when it meets a dead-end (node with no next nodes)
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
You used Stack<T>? Or just improved you previous alg?
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
Yeah that's kind of what I do atm, even if I think I do it pretty bad cause the Stack actually stores the index of the transformed node, the index of the next nodes and the node array representing the current state
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
Not really related but I've tried a Stack<T> based approach to try fixing memory issues by not computing every outcome simultaneously but it's not completely working atm, what do you think?
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
Hmmm yeah
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
Here you'd only compute .NextNodes 11 times
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
Pre-calculation will determine what the possible NextNodes are for 0, 1, 2, 3... up to but 10. Say every node's NextNodes are either the node with +1 or the node with +2 (to keep the same transformations as before) and if that'd make you go above 10, start from 0 (so 10's NextNodes are the nodes that contain 0 and 1)
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
As I said, the integers example is not really good for this because they can go as far as you like but say we're sure we'll never haves node that go above 10 and below 0
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
I don't think so
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
I'm not sure if I understand this, I mean using my initial implementation you don't compute next nodes billion times (well if we use the integer example and keep it unbounded, you have to process every integer so still a lot), if say there are million or even billion possible outcomes but only X possible nodes, you'll just compute next nodes X times. While if your implementation meets (back to the integer example) a 3 two times, it'll compute the 3's next nodes twice right?
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
If I understand correctly, your version computes transformation results on the fly and always applies the same transformations (+1 or +2)?
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
Yeah but on pc I can copy paste on different files and make it easier to browse 😁
241 replies
CC#
Created by nalka on 10/19/2023 in #help
❔ Need help to optimize this simulation
Ok that looks too complicated to look at on phone 😅 Brb when my pc is ready
241 replies