Murphy
Looping a query bad practice? Good alternative?
you could iterate through your list and building a single query up from that and then running that one query. like instead of running multiple queries of and ... you could use a build up a query like and run that.
4 replies
Looping a query bad practice? Good alternative?
Doing a bunch of small queries can be slower than doing a single query where you could extract your needed data from one result. With small, simple queries, the overhead is generally from sending the query to the server and receiving the result rather than the actual processing of the query so it's usually better to combine what you can and send only one query and receive only one result. It's hard to say without more info because it really depends on the query and your design goals.
4 replies
❔ NuGet dependency Hell
no, .net 4.7.2, I added
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="3.1.0.0" newVersion="3.1.32.0" />
</dependentAssembly>
to my app.config and It looked like it it's working now. I've just got a bunch of other similar loading errors I'm slogging through now. there's a bunch of ef dependencies that are like 5.0.0.0 & 7.0.0.0 after I updated from ef 3.1.30 to 3.1.32.
15 replies
❔ combobox with radioButtons
Not easily, without redrawing. This might help- https://www.codeproject.com/Articles/21085/CheckBox-ComboBox-Extending-the-ComboBox-Class-and and instead of using check box controls, use just radio button controls. Since they're in the same container, they should still work as expected.
8 replies
❔ What makes Blazor a SPA?
You don't have to use Blazor as an SPA. In fact, if you try to deal with more specialized authentication and extend the built-in Identity and try to use Blazor for your authentication-related pages, it's not really possible to keep everything in a single Blazor page. When a page with Blazor first loads, it'll do a regular web request and sets up the circuit to the server. That's the only 'actual' web request that happens, which is what makes it an SPA. So some of the function provided by the Identity managers won't work exactly as expected (ie SignInAsyc won't work) until you navigate while setting forceLoad to bypass client-side routing to set up a new circuit.
27 replies
✅ What is the best way to fix StackOverflow when methods are calling each other?
Now that I think about it, you're still going to run into issues since you're still going to be checking so deep into possible moves when you don't have to. When you're eliminating from your set of possible moves that will place a player into check, when you check the opponent's pieces' possible moves to see if they hit the player's king, skip the RemovesCheck() for those moves. It's irrelevant because you don't care if the opponents can actually perform the capture, only that they are threatening the king. It will cause a bunch of branching by essentially walking over every single possible move that could happen for the rest of the game after that one move. You'll very likely still run into stack overflows since the number of possible moves in a game is just so dang big.
20 replies
✅ What is the best way to fix StackOverflow when methods are calling each other?
When you clone the board in RemovesCheck(), you need to remember where the piece was originally before the move and exclude the move that would bring it back to the same place it was the next time you call AllPossiblitiesOfPlayer() inside the Check() method. That's where I'd start
20 replies
✅ What is the best way to fix StackOverflow when methods are calling each other?
It's more of an error in the logic of the algorithm and how youre checking for invalid moves rather than the code itself. You're not 'pruning your game tree' correctly. If you try to run through all possible moves, and only RemoveAt() the moves that fail the RemovesCheck() check, you'll run into an infinite loop. It's just harder to see since the 'loop' is split up with function calls. Consider a board with two kings and a white rook; call it state1. Lets say you try to run through all possible moves of the rook- the first move you validate with RemovesCheck() will attempt to make a new board, call it state2, and Move() the rook and then look for checks with Check() on that new board state. Well, now the Check() method will have to find all possibilities and one of those is going to be the same state you started with - state1. You'll just go back and forth infinitely without a way to remove that already checked move from the move list.
20 replies
✅ What is the best way to fix StackOverflow when methods are calling each other?
Ah, ok. You effectively have an infinite loop since youre trying to find every possible move first before you determine if there are invalid moves. There needs to be a ground case where the cycle of calls stops, but if you enumerate every possible move first, you'll never hit it. Think of one piece just moving back and forth, there are an infinte number of possible moves. You need to stop checking for possible moves once you find an invalid move.
20 replies
✅ What is the best way to fix StackOverflow when methods are calling each other?
It's kind of hard to help optimize just seeing this bit but why do you have to call AllPossibilitiesOfPlayer in Check? That sems like there will be a lot of computation when you only need to confirm that the other player's king is threatened? Seems like you're going to be doing a lot more work than needed. It seems like your approach is to brute force all possibilities and then see if one of those is invalid rather than just checking for invalid-ness in the first place.
20 replies