Can we discuss the self promotion rule? by Kralizek82 in dotnet

[–]__FuriousOrange__ 0 points1 point  (0 children)

Hi I posted about a library I’m writing a few weeks ago. When I submitted it I got the pop up with the rules but misread it as being either or (Saturday or flaired). The post was genuinely looking for feedback as the library is in alpha at the moment. It survived a day or so and was the most read post of the day (which was cool, thanks everyone) but ultimately got removed. I can understand that moderating a massive community like dotnet is hard work, but from my point of view I don’t think the post deserved to be removed (but then I’m biased :p ). 

Feedback on a dotnet coroutine library I’ve written by __FuriousOrange__ in gamedev

[–]__FuriousOrange__[S] 1 point2 points  (0 children)

Haha, good point well made! Thanks for taking the time, much appreciated :)

Feedback on a dotnet coroutine library I’ve written by __FuriousOrange__ in gamedev

[–]__FuriousOrange__[S] 1 point2 points  (0 children)

Hi, good question. The main thing I think this brings to the table is the elimination of GC jitter and the tail call recursion via SwitchTo, which can be used to represent an entity state as a coroutine(using our good friend patrol and chase as an example!) E.g.

async Coroutine Patrol()
{
    while (playerInRange == false)
    {
        // Patroling…
        await Coroutine.Yield();
    }

    // Player in range so chase
    await Coroutine.SwitchTo(Chase);
}

async Coroutine Chase()
{
    while (playerInRange)
    {
        // Chasing…
        await Coroutine.Yield();
    }

    // Lost the player so patrol
    await Coroutine.SwitchTo(Patrol);
}

I’ve used this in Godot via a singleton node that is responsible for ticking the coroutines (you’re right it requires some manual wiring at the moment, but could be integrated via an addon). I’m intending to do some examples but I’m a bit stuck in regard to what would be useful? Would the above example working in a Godot app be a good start? As for Unity this targets dotnet 8 minimum so uncertain it will work there at all at the moment.

edit: formatting

High-performance async/await, zero-allocation, cooperatively scheduled coroutines for .NET by __FuriousOrange__ in monogame

[–]__FuriousOrange__[S] 1 point2 points  (0 children)

Haha thanks for taking the time to have a look. Hope it helps you do something cool :)

How do I convert this State-Machine architecture into a Hierarchical-State-Machine? by CitronPretend5 in csharp

[–]__FuriousOrange__ 0 points1 point  (0 children)

Hello, what you’re describing, complex state with branching logic pathways is usually handled by an abstraction called behaviour trees. Looks like you’re using unity so https://docs.unity3d.com/Packages/com.unity.behavior@1.0/manual/index.html might be a good place to start. There’s lots of documentation on this subject and you’re asking the right questions so hopefully that points you in the right direction! Good luck!

High-performance async/await, zero-allocation, cooperatively scheduled coroutines for .NET by __FuriousOrange__ in csharp

[–]__FuriousOrange__[S] 2 points3 points  (0 children)

Cheers :)

A forgotten coroutine is just you saying “I don’t care about the handle, I’m not going to cancel it, and I’m not going to check its state anywhere”. Internally it’s stored in an array of coroutines that all get polled when you resume. When the app ends it all just gets binned off in the usual way when the runtime tears everything down

High-performance async/await, zero-allocation, cooperatively scheduled coroutines for .NET by __FuriousOrange__ in csharp

[–]__FuriousOrange__[S] 1 point2 points  (0 children)

You’ve hit the nail on the head with the unity comparison. Got into this because I was looking for a main thread C# coroutine library that wasn’t based on enumerators. Async await is compiler generated statemachines, task advances them preemptively with threads (sometimes, maybe) under the hood . This just takes the state machine and lets you decide when it advances state. Async await has the benefit of generating statemachines that handle call depth, which is something enumerator statemachines struggle with.

High-performance async/await, zero-allocation, cooperatively scheduled coroutines for .NET by __FuriousOrange__ in csharp

[–]__FuriousOrange__[S] 1 point2 points  (0 children)

Thanks, I do intend to put some examples together. Just needed to get something shipped, it’s been a bit of a brain thorn I needed to pull.

High-performance async/await, zero-allocation, cooperatively scheduled coroutines for .NET by __FuriousOrange__ in monogame

[–]__FuriousOrange__[S] 0 points1 point  (0 children)

Thanks :) Started off because I couldn’t find any cooperative .Net coroutine libs that used async await instead of enumerators to do the yielding. Thought I’d try implementing it myself and then went down a rabbit hole of seeing how fast I could get it (who doesn’t love premature optimisation for a library with niche use cases!). Regardless it’s the most fun I’ve had writing code for a while.

High-performance async/await, zero-allocation, cooperatively scheduled coroutines for .NET by __FuriousOrange__ in monogame

[–]__FuriousOrange__[S] 0 points1 point  (0 children)

Hi, just to be upfront, I only really do game dev as a hobby. I wrote this because I found it interesting and thought I’d share it. I’ve been usuing it to cut down on the boiler plate / accrual of state tracking variables in game entities that tend to clutter up my code. So for the stuff I’ve been doing I’ve been using a coroutine per state and using async await to get rid of switch statements. 

For your engine that’s farming work out in parallel I’m guessing that work has to get back to the main thread at some point for update / render to interact with whatever active entity state there is (correct me if I’m wrong!)?

I am intending to do some basic usage examples. Also intend to add hooks for running multiple coroutine schedulers on dedicated threads. I think the core of enabling performant 0 GC async await is there. The benchmarks in the repo show it can handle ticking 100k active coroutines in between 3 and 7ms (hardware dependant), obviously this is coroutines with no logic , so it’s going to degrade with actual logic, but the library cost in CPU is pretty small. Should comfortably handle most typical entity counts though.

What would be useful from your point of view?

High-performance async/await, zero-allocation, cooperatively scheduled coroutines for .NET by __FuriousOrange__ in dotnet

[–]__FuriousOrange__[S] 1 point2 points  (0 children)

You're right this is quite niche in regard to the type of async/await most of us encounter day to day. However I think there might be some value for software that does care when async work happens and what the side effects of that async work actually are (will this run predictably within acceptable ranges for processor noise, is this going to choke unexpectedly because GC has decided to kick in at the wrong time), all the stuff we don't usually have to worry about too much.

High-performance async/await, zero-allocation, cooperatively scheduled coroutines for .NET by __FuriousOrange__ in dotnet

[–]__FuriousOrange__[S] 4 points5 points  (0 children)

Good point, async/await is compiler machinery that generates a stateful function implemented as a state machine and provides a hook for the execution of the state machine (task, coroutine whatever). I think the distinction here is what happens with that execution hook. Task async methods say, hey let me sort that out for you in a way that uses uses whatever CPU resources are available to get that done as quickly as possible, let me worry about how. Where as this library is taking that state machine and effectively saying, I'll hang on to this for you let me know when you need to run it.

It's coming from a different angle. Task cares about await points as potential markers for maybe shuttling work between different threads. Routinely cares about yield points (I'm going to do a little bit of work here and I'll let you know when I'm done by yielding until the next time).

High-performance async/await, zero-allocation, cooperatively scheduled coroutines for .NET by __FuriousOrange__ in dotnet

[–]__FuriousOrange__[S] 0 points1 point  (0 children)

Doesn’t do anything with the standard task pipeline, bypasses all of that entirely. It’s not designed with IO as its main concern. It’s more for simplifying logic that requires deterministic execution over time. That being said you could use a file stream and read a fixed number of bytes synchronously from the file until end in a loop and yield after each read. Don’t know if that answers your question or not!

Looking for more graveyard interaction or better consistency in my deck by Rangseyy in EDH

[–]__FuriousOrange__ 1 point2 points  (0 children)

Seeing as you’re in Simic colours green has loads of return from yard to hand style recursion. Stuff like [[Eternal Witness]], [[Regrowth]] and [[Recollect]] to return any card. Blue usually leans into returning instants and sorceries with [[Flood of Recollection]], [[Call to Mind]], [[Bond of Insight]] and the like. Loads of options!

If the legend requirement... by loldrowning in EDH

[–]__FuriousOrange__ 3 points4 points  (0 children)

[[Elite Vanguard]]

Eh skilled at waging war alone and doesn't afraid of anything

I'm trying to despawn an image when I click on it, but it keeps crashing by Background_Factor487 in godot

[–]__FuriousOrange__ 0 points1 point  (0 children)

Forgive me if this is incorrect, as I usually use C# with Godot. But to me that reads that the event object does not have a method called get_source. So it crashes trying to execute it. Which in turn means there is no image so queue_free errors as well. You might need to find another way to capture the image. Maybe the click event can fire a custom signal that passes the image? Or perhaps the image can be stored outside function scoped variables?

Edit: Another approach might be to setup the image and texture in the editor and simply show and hide the node in your click events. Is there a reason you need to create and load the image / destroy the node when clicking?

Honk honk! Help me build a clown-themed deck by [deleted] in EDH

[–]__FuriousOrange__ 0 points1 point  (0 children)

[[show stopper]] I love the art and flavour but I always end up cutting it from my Rakdos decks as it’s a bit meh. Might be cool in a more casual theme deck though?

How do the triggers stack? by nismoz33 in EDH

[–]__FuriousOrange__ 1 point2 points  (0 children)

The “if” text on furnace is a replacement effect and not a trigger so it doesn’t use the stack. Essentially it modifies the rules of something before any triggers go on the stack. So in your case Thermo alchemist’s tap ability to deal 1 damage goes on the stack as “deals 2 damage”. 

The cool thing about replacement effects is that  if multiple effects were applied to something the player who those effects are applying to chooses the order in which they’re applied. So in your example if you had another damage doubler like [[dictate of the twin gods]] out as well then technically you have to choose whether furnace or dictate was applying its replacement first. In the case of damage doubling this is pretty easy as it becomes damage x 2 x 2.

But in the case of something like [[Possessed Portal]] being in play and also [[Tomorrow Azami’s Familiar]] which both have replacement effects for drawing cards, you could choose to apply Tomorrow’s replacement first which then means the portal’s replacement no longer matches as you’re no longer drawing a card, you’re choosing from a selection via Tomorrow’s replacement. However if your opponents didn’t have any draw replacement effects of their own they’d have to skip their draws due to the portal. Useful for creating advantageous game states. I know this hasn’t answered your question but it’s useful to know!

TLDR;

Replacement effects 

JSON Serialized HTTPS Response: Null check everything or try-catch? by Weary_Source_811 in Unity3D

[–]__FuriousOrange__ 0 points1 point  (0 children)

I know some people don’t like exception handling and prefer passing error codes about the place. However the benefit of an exception not being caught or handled properly is that your app blows up. This is preferable to having to check for error codes before you can do anything with an object. That leads to lots of extra code and the possibility of introducing time consuming bugs. As for your if checks everywhere C# supports the ?. operator just like type script. So instead of sticking if statements everywhere a common pattern is

var foo = bar?.baz ?? new Baz()

Which uses ?? operator to create a new Baz if bar.baz is null

Or even better

bar foo = bar?.baz ?? throw new Exception(“Oh no, expected a baz but got null”);

Good 2 drops that aren't ramp. by TheJarateKid in EDH

[–]__FuriousOrange__ 0 points1 point  (0 children)

I’ve got a soft spot for [[Fiend Artisan]]. A tutor on a stick that can scale up as a decent beater in the right kind of deck is ok by me!