stardance has been extended another month! the new deadline is october 31 :)

You are browsing as a guest. Sign up (or log in) to start making projects!

Storm

  • 12 Devlogs
  • 79 Total hours

A rules engine for MTG, the most complicated card game ever made. In case you want to read the full rules (you don’t - it’s over 300 pages of tiny text), here they are: https://magic.wizards.com/en/rules

Ship #1

storm

I made a rules engine for the card game MTG. Its basically a giant state machine. You tell it what the players do and based on that it changes the game state.

My experience

The most challenging thing by far was finding a data model that would allow everything you can do in MTG. And since cards are written in english, there are A LOT of possible actions.

Shiny new things I learned

  • I finallyyy have a proper understanding of generics; before it was just this “magic in angle brackets”
  • Pros & Cons of different data structures while I decided what to use for storing cards
  • Experience in how to manage a project that has > 10 files. Might actually be the most valuable thing I gained from all of this..
  • A somewhat decent understanding of lifetimes in rust
  • Also I finally had a look at metaprogramming with macros (only declarative macros though)

I am proud of this

The thing I am really proud of in here is how you can have these generic components that define behaviour or targets or such an how you can then use them to create cards as pure data through the power of generics and macros. They are literally just a constant in the code.

My experience with AI

Later in the implementation when my data structure was mostly fixed I tried having an AI agent do some of the boring work of hooking things up, but it didn’t work. And by that I mean it was pretty awful. It didn’t understand my design, reinvented the wheel several times, took shortcuts that would work for exactly this one card I asked about and just created wrong behaviour. Maybe this was a me problem, because I provided bad context, but I think I will stick writing code by hand for a while longer.

  • 12 devlogs
  • 79h
  • 18.99x multiplier
  • 1279 Stardust
Try project → See source code →
Open comments for this post

2h 32m 32s logged

#12
Of course there is an extension of one month right as I was going to ship…

Anyway I published it on crates.io, I added some minimal executable example, did the README and added some metadata for publication. And I drew this wonderful new banner. Its a bit whacky, but I like it

0
0
16
Open comments for this post

7h 7m 42s logged

#11 Devlog (AI adventure)
So, since stardance ends soon I have to ship this and I am not sure if I can manage in time. So I had a look at AI coding and how to do it properly, because I tried vibe-coding before and it was abysmal.

And I have to say it was miles ahead of anything else AI has ever done for me, when you use some specialized skills, create a roadmap first, split it into tickets (The AI even created tickets on GitHub for whatever godforsaken reason; It knew this is a solo project), structure your work, … It is also a TON more work.

And it was still lacking. Maybe it was because my student subscription isn’t that powerful, maybe MTG is just too complex or I didn’t explain my messed up design well enough to the agent. Either way I wasted a bunch more time and … yeah, here’s hoping that I will get a working v0.1 alpha in time!

0
0
13
Open comments for this post

7h 8m 26s logged

#10 Devlog

How could I forget git THIS hard??? I didn’t make a single commit in like the last 20 hours. And now everything is so different that I might as well make a new repo. Also the line count in the screenshots is bugged somehow. Its more like +28XX lines. And it took THREE screenshots!!

Anyways, heres an actual update:

Now casting spells is finally complete (kinda) and static abilities work too. They even share some code through common “behaviour”. Thats just some common action that can be executed on the game state. Also with the help of a few todo! macros (Magic for fixing anything, but throws at runtime) the code finally compiles again. For like the second time in the entire development. There is bound to be a million bugs in there….

0
0
11
Open comments for this post

8h 28m 58s logged

#9 Devlog
Casting spells is now almost complete, and my overengineered type system got even more crazy.

We have now:

  • Card, that represent, well… cards
  • StackDefinition, which the targets and some other metadata for Spells
  • Selectors, as there name suggests, select objects
  • Behaviour, a closure that can change the game state, but with a lot of fancy type shenanigans to make sure it is only used with appropriate StackDefinitions.

Below are some highlights from the new types

0
0
8
Open comments for this post

4h 30m 6s logged

#8 Devlog (Sorry; last one is actually #7)
So I finally completed the rewrite my entire project now uses my new overengineered typing. Yay! Finally!! But that also meant that I had to change my library API to use all of those types. What you see below are just the function definitions for that + some minor input validation. And, yes, you could defnitiely make that a lot shorter with macros but it is 1am and I can’t be bothered to go learn how they work.

0
0
11
Open comments for this post

4h 6m 42s logged

#5 Devlog
Of course fixing stuff took longer than I thought (as always), but we are almost there. Only 16 more errors to go!

0
0
36
Open comments for this post

7h 25m 28s logged

#6 Devlog
You know the rewrite I talked about last time? I am STILL doing that. It changed so much more that I had expected. Now I have changed just about every function signature in the entire project. Also there were a million little problems that also needed attention. I think I am close to completing the rewrite though; the core types are all set, I just have to deal with the downstream effects of changing them. That shouldn’t (I hope) take too long

0
0
8
Open comments for this post

3h 24m 2s logged

#5 Devlog
I redesigned my engine (not implemented yet); It makes much more extensive use of generics now and has in general much better type-safety. This eliminates a ton of bounds checks and potential errors, because the compiler can prove at compile-time that the program is valid (or not).

Also kind of crazy that it says 3.5h for designing. I feel like I spent most of my time in the browser explaining my code to ChatGPT to understand it better myself (ChatGPT did little besides saying “Ah, yes, great idea” and explaining my idea back to me)

0
0
4
Open comments for this post

1h 33m 16s logged

#4 Devlog
I have been developing a new model for how cards on the “stack” (a zone for cards). This moves a lot of the verification and testing (“Is the card that is reference by this Id, the card I expect?, Is this card really in the correct zone?, …”) to compile-time and the compiler will simply refuse to compile if its wrong. And I am really proud of it, since this is by far the most advanced thing I have ever done with generics and it is beautiful. All these ifs are just gone

0
0
11
Open comments for this post

1h 4m 18s logged

#3 Devlog
I created a single method in this hour. I wanted to just have method that creates an Iterator over a collection of objects. But if you have different objects that becomes very messy very fast, because the concrete type of the iterator is also different then. Now the method only claims to return something that is an iterator, so it shouldn’t be a problem, right? Well it is, because the compiler doesn’t know at compile time what type will be returned and thus can’t do monomorphization. The solution: Make the types of all of the objects the same through static polymorphism BEFORE you construct the iterator by putting everything into an enum and implementing an access method.

You could of course avoid all of that and just use dynamic polymorphism, but who needs that. Also sorry for posting so little, I will try to post more often.

0
0
7
Open comments for this post

11h 8m 1s logged

#2 Devlog
I reworked how static abilities are applied - now they are (mostly) compliant with MTG comp rules. By far the hardest (and most time-consuming) part was coming up with a design that can actually accommodate all of the requirements the rules have. It’s madness; you can change abilities during resolution, partially apply abilities and the order of application is incredibly complicated. Once I had that figured out the implementation was pretty straightforward. Design is in the image below.

The second big thing is that I started creating a unified iterator interface to access my cards in a structured manner.

0
0
2
Open comments for this post

20h 4m 32s logged

#1 Devlog

So originally I didn’t even plan to put this here, it was just me trying some different ideas. But now that I have spent over 20h and the design isn’t complete trash anymore, I should probably put this here as well. It is still far from complete and actually not that much code for 20h due to a million rewrites. Still, it has a working model for spells, permanents and various effects, so some basic cards can already work. What still needs a lot of work is how to cast a spell, but it is so freaking complicated. Also sorry for no image, but it is a lib and far from runnable, so yeah..

0
0
6

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…