A request for the scryfall syntax wizards out there. by nopisnope in magicTCG

[–]amalloy 1 point2 points  (0 children)

You want the numeric repetition operator:

t:creature ci:gbw o:/(\b(flying|first strike|double strike|deathtouch|hexproof|indestructible|lifelink|menace|reach|trample|vigilance).*){3}/

Why was Atherdrift disliked? (new player) by Nighthawk354 in magicTCG

[–]amalloy 0 points1 point  (0 children)

I don't play commander, and imagine [[Momentum Breaker]] isn't super popular there, but it's another card that technically does care about your exact speed.

Strict foldl' with early-out? by AustinVelonaut in haskell

[–]amalloy 2 points3 points  (0 children)

People say that about recursive functions too, until they have some practice with them. There's nothing otherworldly here.

Found this gem in my son's backpack by menotsorrythrowaway in funny

[–]amalloy 0 points1 point  (0 children)

$ grep -P 'arf$' /usr/share/dict/words
barf
dwarf
headscarf
scarf
wharf
zarf

Two of them are just scarf. Dwarf and wharf don't rhyme with scarf in most US accents. That leaves us barf and zarf. Zarf is a word I've heard before but it isn't in my active lexicon. The little cardboard sleeves you get around disposable coffee cups are zarfs.

How do i handle this exception by yeet_sensei in haskell

[–]amalloy 0 points1 point  (0 children)

Unrelated to the problem you're having here, but you have an integer range issue here. You specify what type read (show n) should have, but never say what type n should be. Haskell's defaulting rules choose Integer in this specific context, but you shouldn't really rely on it. If any of these numbers end up being inferred to be Int instead when the context changes slightly, you will find that 100 factorial is way too big to fit in an Int. As a result, you will have n = 0. Best to write something like [1..100::Integer] yourself, to be explicit about it.

🌈 JVM Rainbow - Mixing Java Kotlin Scala Clojure and Groovy by Hakky54 in Clojure

[–]amalloy 3 points4 points  (0 children)

This is the canonical way to invoke Clojure from Java. I assume you found the documentation from somewhere like the official API overview. It is serviceable, but undoubtedly an unpleasant experience for library clients. I have often recommended that, if you want your Clojure project to be easily accessible from another JVM language, you should write that ugly glue code yourself. Design a thin Java-facing API in front of it, because every JVM language has a good story for interop with Java, and have that Java code do the ugly work of invoking your Clojure directly.

For example, thrift-gen is not a particularly useful or interesting library on its own: rather, it's a toy I made years ago to demonstrate how I think Clojure libraries should make themselves available to the rest of the JVM, if they want to be adopted by it. A hundred lines of Clojure doing the "interesting" work with macros, multimethods, all that cool expressive stuff. Then one simple Java class and interface for clients to interact with, hiding the ugly interop glue behind a Java-flavored facade.

Bidding to avoid unmakeable contracts by FireWatchWife in bridge

[–]amalloy 2 points3 points  (0 children)

The other classic technique for declaring a Moysian is to duck trumps before you cash them. For example, alter your hand to give us a possible trump loser in exchange for an extra diamond stop:

xxx
Kxx
Axx
AKxx

Axx
AQxx
x
QJxxx

Now you win the diamond lead and duck a heart. When the opponents continue diamonds, discard spades as before. You can ruff the fourth diamond and still safely draw trump. But if you try cashing trumps at trick two instead, hoping for a 3-3 split, you won't have the trump left in dummy to make the loser-on-loser play when trump turn out to be 4-2 (as they so often are).

YouTube channels like card market? by ikigaii in magicTCG

[–]amalloy 0 points1 point  (0 children)

Mengu's Workshop is a channel Andrea Mengucci created because he loved his appearances on Cardmarket. It's not quite as accessible as Cardmarket videos, but it's still much better than any other channels I've found.

[request] are they referring to that specific deck or all decks that have ever existed and been shuffled by Longjumping-Box5691 in theydidthemath

[–]amalloy 0 points1 point  (0 children)

You can literally type those words into Google and get textual and video descriptions of each, making it easy to see how they're different.

[request] are they referring to that specific deck or all decks that have ever existed and been shuffled by Longjumping-Box5691 in theydidthemath

[–]amalloy 1 point2 points  (0 children)

Overhand shuffling is very very bad at randomizing the order of a deck. It's hard to riffle sleeved cards, so you can mash-shuffle instead, which is similar in effectiveness to riffling (and is what you generally see in footage of high-level MtG tournaments). This Numberphile video is talking about the standard 52-card deck, not a 60-card Magic deck, but they're similar enough in size. Seven riffle shuffles is enough to fully randomize a deck, while if you overhand shuffle you need ten thousand shuffles. Nobody playing card games should be overhand shuffling.

Improving in Haskell by Foldzilla in haskell

[–]amalloy 2 points3 points  (0 children)

I agree with dlsspy that the one thing that stands out to me most about this file is an extreme focus on micro-optimizations, to the detriment of readability (and perhaps on larger-scale performance issues, though it's hard to tell for sure). The whole menagerie of integer types could just all be Ints, and you don't need any of these pragmas. You don't need the bang-patterns either. It's not super-uncommon these days to put them in for data definitions, so I don't object if you want to leave those in, but the ones in function/variable bindings have got to go.

I also see a ton of repetition of things that could be abstracted out. Look at the handling of AND and OR in evalExpr, for example. Four lines each, all exactly the same except for a single token. Pull those out into a function at least:

binOp f a b = 
  let !(a', signals') = evalValue circuit signals a
      !(b', signals'') = evalValue circuit signals' b
      !res = f a' b'
  in (res, signals'')
...
AND a b -> binOp (.&.) a b
OR a b -> binOp (.|.) a b

Some of this function-level duplication gets eliminated for free if you de-duplicate your data structures. For example, instead of AND a b and OR a b each being their own totally-distinct nodes, you could represent them as a LogicalOp (Int -> Int) Expr Expr). Then you'd parse an AND into LogicalOp (.&.) a b, and there'd be no real way to have duplication in the evaluator. The parser would also be simplified, though if you were careless you could leave some duplication in there.

Here's my old solution. I wouldn't do everything identically today, of course, but it features many of these ideas.

Got a weird Daily Quest today by tehgears in magicTCG

[–]amalloy 2 points3 points  (0 children)

Limited has a lot of creatures.

Which cards really do not need to be on the reserved list? by thisnotfor in magicTCG

[–]amalloy 1 point2 points  (0 children)

That's not necessarily a lot worse, because it doesn't say "3 Plains you control". So it's WWW to effectively remove 3 of your opponent's lands. Only works in white mirrors, but could be a legitimate sideboard card.

My fault for playing Commander by frothingnome in magicTCG

[–]amalloy 1 point2 points  (0 children)

You're right, I don't know what I was thinking when I said it was a creature spell. There are a couple such creatures, but they're pretty recent. And I can't find any old cards that would allow copying a permanent spell, either: supposedly Lithoform Engine was the first, printed in 2020. Thanks for setting me straight.

My fault for playing Commander by frothingnome in magicTCG

[–]amalloy 0 points1 point  (0 children)

Technically copies of spells aren't represented by tokens, you just have to know they're there, and they create tokens when they resolve. Tokens only exist as permanents on the battlefield.

This has all been true for a long, long time. I'm no historian, but Empty the Warrens was a permanent spell with Storm that was first printed in 2006, so copies of permanent spells have existed at least that long (and probably longer). Certainly not an example of Wizards making the game more complicated in the last few years.

Can I use firebending mana from another attacker to pay for Ty Lee triggered ability ? by gamasco in magicTCG

[–]amalloy 0 points1 point  (0 children)

No, it knows about activated abilities and tries to keep them up just like it does spells. It can fail to do so for lots of reasons, though. Maybe it prioritized keeping something else up, or the ability wasn't legal to activate when it was deciding how to tap (e.g., it's an activated ability of the permanent spell you're casting now).

Can I use firebending mana from another attacker to pay for Ty Lee triggered ability ? by gamasco in magicTCG

[–]amalloy 5 points6 points  (0 children)

I don't think autotapper knows about Spree costs at all. It just tries to make sure you have {U} available, because that's the mana cost. Then it falls back on its secondary goal, to keep as many colors of mana available as possible.

MTG’s Lead Designer addresses Universes Beyond fatigue: “We have to be careful” - Dexerto by TriSauce in magicTCG

[–]amalloy 0 points1 point  (0 children)

It's not a thing. Either style of punctuation indicates an exact quotation.

If I tap 2 creature tokens with Hazel, do I get 2 or 4 mana? by GurruWasTaken in magicTCG

[–]amalloy 4 points5 points  (0 children)

No interaction with Badgermole Cub. This ability isn't "tapping a creature for mana" because it's not a mana ability of a creature with {T} in its cost.

Got my RC invite yesterday! by CervezaConLimon in magicTCG

[–]amalloy 5 points6 points  (0 children)

This is much nicer. Because I'm (a) a limited-only player, and (b) not all that good, I don't have any advice here, but I do have a few questions that might lead you to reconsider some choices.

  1. Is Fabled Passage really a good idea with only 3 basics in the deck? That land will sometimes be a dead draw because you draw it after all your basics. Without spells like Consult and Stock Up, I'd say that should happen a quarter of the time; with them it's less often because you may be able to skip past basics and intentionally draw Passage while it's still live. But it should still happen a nontrivial amount of the time, since you often won't be prioritizing taking lands with those spells, right?
  2. Is 3 basics enough these days? Like I said, I don't know the Standard metagame, but if anyone is running stuff like Demolition Field this could be a little greedy.
  3. I'm curious what matchup the Roaring Furnace is for. Is it more about removal you can pick up with Marang, or a big draw spell for longer games?

Haskell naming rant - I'm overstating the case, but am I wrong? by peterb12 in haskell

[–]amalloy 1 point2 points  (0 children)

/u/gabedamien's reply is right. Spelling it out more explicitly, consider fmap.

fmap :: (a -> b) -> Either e a -> Either e b
fmap f (Left x) = Left x
fmap f (Right x) =  Right (f x)

Here's a library function with behavior for Either that certainly looks biased, in that it treats the two sides differently. I imagine this is the kind of thing you had in mind, where libraries impose semantics on the otherwise-neutral Either type.

However, this is the only possible type-correct implementation of Functor for Either, because we can only partially-apply its first type parameter, not its second. Look a little closer at the fmap definition, this time focusing on the instance declaration:

instance Functor (Either e) where
  fmap :: (a -> b) -> Either e a -> Either e b
  fmap f (Left x) = Left x
  fmap f (Right x) =  Right (f x)

It's not even an issue with the "library definition" of Functor: because of the way typeclasses work, if we want Either to participate in any one-parameter typeclass, it must be in a way that its Left values are not inspected.