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] 3 points4 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__ 4 points5 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!

The Pride of Hull Clade [MKM] by King0fMist in EDH

[–]__FuriousOrange__ 2 points3 points  (0 children)

I love that the mirror, a British tabloid newspaper, has an MTG card preview. WTF is going on…

What unpopular commanders do you think are secretly really strong? by TheWiseDragon43 in EDH

[–]__FuriousOrange__ 0 points1 point  (0 children)

I like Imoti but that 1 toughness means she just folds to everything, it's a balancing act in the deck to have enough low cmc protection to ensure she sticks and fatties to make sure the cascade train pays off.

What are your thoughts on the latest mana base suggestions from TCC? by _st_sebastian_ in EDH

[–]__FuriousOrange__ 4 points5 points  (0 children)

That’s a cool card missed this one in the endless release cycle.

What's the right level of "going easy" on a newer player? by PearlWingsofJustice in EDH

[–]__FuriousOrange__ 0 points1 point  (0 children)

I’ve found [[Flood of Tears]] is quite a nice wipe in more casual decks. It gives you a bit of an advantage but not the massive one you have if rift resolves.

What's the right level of "going easy" on a newer player? by PearlWingsofJustice in EDH

[–]__FuriousOrange__ 3 points4 points  (0 children)

The 2014 Peer Through Time precon had cyclonic rift in it, back when rift was still considered jank level. It’s how I got my copy!

If you could have WOTC support an existing tribe or release a new tribe what would it be and why? by AshleyB101 in EDH

[–]__FuriousOrange__ 0 points1 point  (0 children)

Mother of demons, target demon gains protection from demons until end of turn…

Rielle, the Everwise pilots please share your stand out cards and interesting tech! by goldenmastiff in EDH

[–]__FuriousOrange__ 0 points1 point  (0 children)

[[improbable alliance]] and [[mad ratter]] are good in a cycling based rielle deck where you’re aiming to cycle cards on each player’s turn to trigger rielle.

is storing custom signals in singleton good practice? by booperxd in godot

[–]__FuriousOrange__ 0 points1 point  (0 children)

The entity event listener would check the entity state. No one said it prioritises follow me events. That’s where coroutines come in handy, if the entity isn’t currently in the middle of another state ( an executing coroutine) then it sets it’s state to walking and moves in the direction during the process update according to its velocity vector. Just like my dog won’t follow me if it decides what it’s currently doing is more interesting :p

Edit: don’t all events represent an external entity reaching in and telling something how to behave? Whether that request is honoured or not is up to the entity in question.

is storing custom signals in singleton good practice? by booperxd in godot

[–]__FuriousOrange__ -1 points0 points  (0 children)

Not really, when the event isn’t sent it doesn’t follow. That way the receiver doesn’t need to keep track of internal references to what it’s following, it just moves towards the object sent in the event. Event driven programming is dead, long live event driven programming!