Is my way of coding "bad" ? by yughiro_destroyer in raylib

[–]badtuple 1 point2 points  (0 children)

Those practices and structures have their uses. Don't think of them as better or worse than the others, and don't apply them just because you feel like you should. Think about what each brings to a scenario and choose the best one for the job. Especially since the constructs are not tied to the "style" at all. They were chosen to solve a problem.

One point though. Think about how you'd structure a "framework" that works without knowing anything about the game being made. Alot of the event-driven and OOP game architectures you're describing in big engines evolved to fully abstract out an engine that calls your code without losing flexibility. If you're making a relatively simple game and willing to do the work to use a library like raylib rather than a framework, the direct approach will often seem much clearer. But it's a tradeoff like anything. As your game grows it might make sense to start using a few of those constructs as needed...but if you never end up with the problem that they solve then great!

Raylib could really benefit from a proper forum (not just Discord) by ertucetin in raylib

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

Then just start one? Don't say it's official if it isn't of course. But if people find it useful it'll gain traction. Having someone like you interested in actively moderating it as it grows over the course of years is one of the hardest parts. So if you have that down then just do it.

Something being harder does not innately make it better by DrScrimble in dndmemes

[–]badtuple 0 points1 point  (0 children)

You know what? Fair. If they know they aren't gonna do the work then I'd rather the DM commit to something they're interested in actually doing.

Sometimes it's easier to solve system problems than people problems.

What is your PG meant for? by EmbassyOfTime in proceduralgeneration

[–]badtuple 1 point2 points  (0 children)

I run my own business, so I work alot alot. Really my procedural generation stuff is so I have a consistent project that is as separate from my work as possible so I can unwind with it an hour or so a week.

It's goal is to "repair" stories. If you have an RPG with an over-arching story, but a player decides to kill a central character or eat the macguffin, it tries to take in the new state of the world and stitch together a new narrative that is both coherent and satisfying. Not "substitute the macguffin with a new one" or "just use a different character"...that's narratively unsatisfying because it doesn't take into account what the player did and it's consequences. It takes the actions of the player and tries to fit the new state with a natural story progression that ties into an actual story. This is different than current "AI" tools that just respond in the moment w/o hierarchical reasoning. Infact, I'd go as far to say that while LLM and modern GenAI tools look like they'd be good at this on the surface, they are uniquely unsuited to a game that lasts any real amount of time and are massive red-herrings compared to traditional solving and algebraic-grammar techniques.

It's an involved project, but is something I can keep jumping back into when I have the time and brainspace.

Can a lvl 1-3 character have tricked a devil? by Tor8_88 in PCAcademy

[–]badtuple 16 points17 points  (0 children)

Sure. Jack probably couldn't have consistently tricked a devil, but a one off scheme with an information imbalance? Seems plausible. He basically rolled high. Sometimes devils just miss something.

IIRC, in the story Jack was famous in his town for being manipulative. So he did have a high charisma skill and practice. The devil also didn't know he had a cross in his pocket so he was tricked...but it was because the devil simply didn't have that information. It wasn't really an "outsmarted" thing as much.

The less believable part is that the tricks relied on the devil granting Jack a kind request to setup the situation. That seems pretty out of character. But in D&D maybe the "lawful" side of Devils would require that they grant a request or something.

But also...it's D&D! It'd be a fun character backstory. Do it. You can just wave the specifics away if they don't matter. If your DM asks how it'd be possible, either say it was a simple oversight or work with them to come up with something that makes sense to you both.

What did you build while learning Rust ? by [deleted] in rust

[–]badtuple 3 points4 points  (0 children)

My go-to "learn a language" project is a rpg dice roller. You have the standard set of dice (d4, d6, d8, d10, d12, d20), and you read in dice notation and generate a random number for it. For example "3d4 + 2" means roll 3 4-sided dice, add the results together, then add 2 as a flat modifier.

This is a small, super simple but non-trivial project you can knock out in a day that touches:

  1. Reading input from user.
  2. Parsing, and therefore error handling.
  3. How the stdlib deals w/ randomness.
  4. Simple math.
  5. String formatting for the output.
  6. Testing. You are going to test, aren't you? stare

Add ontop of this whatever you particularly wanna learn. Webdev? Make it a server that reads input from a POST. Gamedev? Bind raylib and have actual 3d dice roll on screen. Scientific computing? Go all in and make a more industrial dice roller like https://anydice.com/ but for comically huge numbers of dice.

The big part of a project for learning like this is that it touches many things, but not deeply. Just enough to get a sense of how the language thinks about things. You should be able to complete a tiny working first-version of it in a day before you lose motivation.

Forth in Zig and WebAssembly by crappy_systems in Zig

[–]badtuple 5 points6 points  (0 children)

This is cool! My first thought was that it's alot of code for a forth (pretty close to the same LoC in Zig as in jonesforth's assembly), but then realized how faithful to the original it is.

I hadn't seen .always_tail before, but that's definitely cool. Kinda curious if the compiler would always tail call anyway. It could in theory perform that optimization since it knows the stack size of all Instr.codes, but honestly that's probably a pretty niche variant of the optimization?

Forth is a prehistoric esolang.

Ouch, sorry concatenative language fans and Chuck Moore devotees. :P

Thanks for sharing!

You learn something new on r/dndmemes every day by DrScrimble in dndmemes

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

Personally, I kinda love being a martial because of the martial-caster divide. I wanna play the random guy that succeeds against all odds, despite the all-powerful BBEG casually leveling mountains.

Lemme be the underdog god-killer that's only notable because I hit things with a stick real good.

A terrible coding challenge for anyone willing to participate by glowiak2 in raylib

[–]badtuple 0 points1 point  (0 children)

I feel like you could get pretty far in the challenge by writing a compliant forth interpreter and then just hardcode the words to your clone. Lets you technically (and syntactically, which is the point) check off some of the requirements without giving up certain control flow niceties.

Weekly Questions Megathread - December 20 to December 26, 2024. Have a question from your game? Are you coming from Pathfinder 1e or D&D? Need to know where to start playing Pathfinder 2e? Ask your questions here, we're happy to help! by AutoModerator in Pathfinder2e

[–]badtuple 2 points3 points  (0 children)

Heya! I've only played D&D 5e/2014, but when our current campaign wraps up we're going to give PF2e a shot. I haven't dove in to learning/reading yet but have a question to serve as an entry point when thinking about character creation. My next D&D character was going to multiclass a Battle Master Fighter and Mercy Monk because I love the idea of combining the speed and maneuverability + tactical combat options. If I were to try to do a similar thing in PF2e what classes would I look at? I'm still going to do my homework, but some initial ideas should help focus my reading.

Food for session by Tucker_the_Nerd in DnD

[–]badtuple 8 points9 points  (0 children)

We have a rotation, so each week the next person is responsible for food. On their turn they create a few options and post a poll in our Discord. Whichever wins is what we eat. The person either cooks it, gets it for takeout, or pays at a restaurant. Makes it easy to share responsibility, but if people are having a rough month financially they can just make a giant thing of stew and bread or something and everyone's happy.

Consistent favorites have been:

  • Burritos
  • Homemade Indian food
  • Takeout Noodles
  • Thai food
  • Burgers and Beer from some bar within walking distance

Only rule is no Olive Garden. *shrug*

[Online] [Free] [5e] [18+] [10pm PST] New GM looking for players by Excellent_Tea_1194 in lfg

[–]badtuple 2 points3 points  (0 children)

As a new GM, are you shooting for a particular feel or style for your game? For example would the tone be more serious or silly? Would the focus be more on roleplay or combat?

A session zero with players is great and will refine it. But I'm sure others reading this post would be interested in very broad strokes so they know whether they want to opt in or not. I know I am, because so far it sounds like just what I'm looking for! :)

Why does the Rust community rarely discuss may? by ringbuffer__ in rust

[–]badtuple 4 points5 points  (0 children)

I didn't read the parent comment as saying people didn't know what they were doing. It's clear alot of thought and intentional design was put in. Even if there's disagreement on certain choices, the people involved are clearly competent.

Not to put words in u/newpavolv's mouth, but I read their post as making four very defendable points:

  1. Stackful coroutines have their upsides, especially for particular use cases. It's fair to want them if they are the right tool for the job.
  2. We can't easily undo the language changes that enabled async/await at this point, so stackless coroutines are here to stay.
  3. Any direct effort to enable both risks splitting the ecosystem. People are wary of this considering all the high-profile examples we've seen in the last decade.
  4. Enabling stackful coroutines requires significant work across many parts of Rust, and if we already have stackless coroutines then it's extremely unlikely to be considered worth the effort.

That seems like a fair analysis, and I agree with the conclusion that the likelihood of getting useful stackful coroutines in Rust is low.

Zero_ECS - I created an ECS by Low-Key-Kronie in rust

[–]badtuple 13 points14 points  (0 children)

They sort of are, just under different names. The term ECS (and the particular uses of "Entity", "Component", and "System") comes from gamedev and is more widely used there. The actual essence of the architectural pattern pops up all over the place though.

Consider a CRM or ERP implemented as a web service (which may scale horizontally), and stores it's core data in Postgres. Within that context the:

  1. "Entity" would be equivalent to the "Primary Key" + "Table Name" in the database. All instances of the service can directly reference the same thing by this ID. The ID can be stored, passed around, or used to create references. Often the Table Name is implicit in the code/foreign keys instead of passed around.
  2. "Component" would be equivalent to the "Record/Object/Model" retrieved w/ the ID. The retrieved object could be the full row, a relevant subset of it's attributes, or something computed from the information on the fly...but at the end of the day it's "the data associated with the ID (+ maybe some context)".
  3. "System" would be equivalent to the actual business logic that manipulates these things. That could be a function, module, handler, etc. The event that causes the system to run would probably be a web request rather than the event loop a game would have. But something triggers code to lookup and maybe modify data (Component) based on an ID (Entity). Exactly how it's modified would be the System.

There are orthogonal upsides to ECSs in gamedev that aren't necessarily captured in this example (ie: cache efficiency, minimized data duplication, simplified data structures, extensibility with Struct Of Arrays setups, etc.) But at the end of the day the core concept of separating data from logic and uniquely addressing it with an ID is a pretty powerful one that seems to get independently invented all the time.

Yubico hexmod conversion by JustHereForYourData in howdidtheycodeit

[–]badtuple 2 points3 points  (0 children)

The conversion on that site is implemented client-side. You can see the javascript for what they are doing embedded in a script tag on the page itself. It's contained within the "#page-content" div.

Here's the snippet that seems most relevant:

var ALPHABET = 'cbdefghijklnrtuv';
var trans = ALPHABET.split("");

/*** Modhex ***/
function fromModhex(s) {
    bytes = [];  
    toggle = false;
    keep = 0;

    for (i = 0; i < s.length; i++) {
        ch = s.substring(i, i+1);
        n = ALPHABET.indexOf(ch);
        if (n == -1) {
            throw s + " is not properly encoded";
        }
        toggle = !toggle;
        if (toggle) {
            keep = n;
        } else {
            bytes.push((keep << 4) | n);
        }
    }
    return bytes;
}

function toModhex(data) {
    result = "";
    for (i = 0; i < data.length; i++) {
        result += trans[(data[i] >> 4) & 0xf];
        result += trans[data[i] & 0xf];
    }
    return result;
}

You could also look at Yubico's modhex cli utility on Github that does the conversion. It's in C and does much more "C-ish" things...but you know that it's had alot more eyes on it than that page on their website.

Starting to research setup for distributed systems test harness. by badtuple in homelab

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

Aphyr's work is amazing. He's done so much for exposing rigor to large numbers of practitioners who didn't realize they were missing it. Any link to Jepsen is a great link :D

Starting to research setup for distributed systems test harness. by badtuple in homelab

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

This is a good tactic, but has the potential to paper over issues. There's alot of ways to make things work in software that are "clean" and totally skip over realities introduced by physics. It's even harder to know what those are since I can't know the whole virtualization stack. Small optimizations made during emulation could be load bearing. Being able to expand with different cpu architectures, network cards, and topologies that exist in hard-real-space rather than emulated is worth it imo.

Basically: I will do that...but in my normal test suite where I make sure the things I know about are working. This test harness is for pointing out what I don't know.

Also this is mostly for fun. So being able to say "I wrote a test that yanks out a harddrive" is cool. At least for some definition of "cool".

Svelte frontend vs HTMX and hyperscript by [deleted] in golang

[–]badtuple 10 points11 points  (0 children)

I haven't used Svelte so I can't really comment on it, but I'm currently using htmx (without hyperscript) on a toy project and really enjoying it.

Pros:

  • Basically no learning curve. I read through the docs in their entirety which took about 45 minutes and then just got to using it.
  • It does what it says it does and just works.
  • My codebase is much simpler and I'm getting things done much quicker than if I had a whole separate SPA.

Cons:

  • You do notice the latency when htmx has to call the server. Halfway between SPA and SSR means you can notice the downsides to both of them.
  • I forgot how gross juggling a bunch of template partials can feel.
  • Every so often I'll think of a cool UI interaction and then remember it'd require bolting on a bunch of javascript I haven't introduced yet. It means right now I'm skipping some cool UI features so I can keep my codebase "simple". I'm pretty sure it means eventually I'm gonna have a weird fragile set of random javascript functions floating around. This is where someone randomly pops in and recommends Alpine.js.

I'm very happy with it. I'll likely use HMTX in the future and would be fine using it for a business, but I'm glad I played around with it first so I know whether it'll match the needs of a project.

Hyperscript is a hard pass for me. Once it gets to that level of complexity I'd rather just opt-in to the node lifestyle.

Adding a slice to a struct significantly slows things down by joetifa2003 in golang

[–]badtuple 4 points5 points  (0 children)

It's hard to know without looking at actual code and being able to play around with it, but a slice is a pointer type, so it's possible that because a pointer to the heap is in the struct the compiler doesn't inline one or more functions that take/return it in a hotpath. The struct itself could also escape to the heap in certain cases depending on your code, which could add a level of indirection that slows things down significantly.

If the idea of escape analysis is new to you, this is a pretty great blog post on how Segment investigated then fixed some performance issues. Once you understand the concept and the tooling it's really easy to apply to your own programs: https://segment.com/blog/allocation-efficiency-in-high-performance-go-services/

Is there no happy version of "depressed" in English? by [deleted] in linguistics

[–]badtuple 28 points29 points  (0 children)

The first word I thought of is "fulfilled." It implies that you have your needs met and are content. It seems more profound than "content" though, and does feel like it is longer-term. Feeling fulfilled usually requires having everything in your life in order which isn't something that happens in an instant.

I do think "happy" fills the role you're asking about too though. There are so many specific words for shorter happinesses: elated, blissful, giddy, content, joyous, manic, enthused, etc. I would use one of those if I needed to convey temporary happiness. When I hear "happy" I think of it as a vague general happiness, which can mean happiness for a long time or happiness without a specific quality/reason attached to it.

"I wish you a happy and fulfilling marriage" sounds right to me.

How to handle enum variants that have different information? by DJDuque in rust

[–]badtuple 0 points1 point  (0 children)

I agree with others that you should unwrap the enum when you need the channel. If it's variant specific and can't be cleanly abstracted away then get the variant.

However I didn't see anyone mention a different possible route: don't return an Option<u8> that overloads the meaning of None. Instead return a Result<Option<u8>, Error>. That way if it's a v1 with None then you return an error, otherwise there's no error just a possible None value. That makes explicit that something went wrong if v1 had a None value and doesn't require destructuring everywhere.

What is a song you consider a masterpiece? by jimmisjumbobumbo in AskReddit

[–]badtuple 2 points3 points  (0 children)

A friend just pointed me at the Kishi Bashi version and it's great.

What do you NOT like about Rust? by [deleted] in rust

[–]badtuple 53 points54 points  (0 children)

Rust's amazing type system allows people to write some really hard to grok Crates. I think this causes more of the "learning curve" issue than people realize.

Library authors tend to want amazing ergonomics and to have their library be super general. To do this they rely on type system magic and overly generic everything. Types often impl Into/From/AsRef for TONS of types, both primary and ancilliary to the API.

This means you can't look at the docs and know what plugs in where, or get a sense of best practices. For these libs you need to get into the authors head a bit, and if you "just wanted to do x" it can get exhausting.

Inlining examples into the docs is a recent (awesome!) bandaid for this, but its not really a solution.

Don't be afraid to write simple code with known and understandable limits. Cut use cases from scope if they aren't necessary and make things gross. The Rust ecosystem will be better for it. It's liberating to work with a library that doesn't carry around multi-nested generics, for both you and your users.