Thread: [Essentials script] Pokémon TCG mod
View Single Post
  #54    
Old September 28th, 2012, 03:48 AM
Awkward Squirtle
,@,e .ºoO
 
Join Date: Jul 2011
Gender: Male
Please don't make the TCG network-play only before implementing proper network play for the main game :P

A simple AI isn't impossible to code. Make it attach Energy to Pokémon that don't have enough (prioritising the Active Pokémon), use the attack that does the most damage (ideally, program attack effects to influence this, as in poccil's battle AI), and use Trainer cards when appropriate (vague, but there are a ton of effects you'd have to consider individually).
A more advanced AI would consider longer-term effects and what the opponent can do (for example, only using a Potion if it would actually save their Pokémon), and use tactics like attaching extra Energy to an unevolved Pokémon to prepare it for its evolved form. Of course, the latter would also require the AI to know how the components of its deck interact, so it might be a little ambitious.

Hmm... Thinking about the interface a bit more, maybe a horizontal layout could work for the deck edit screen? If the small card images are clear enough, you have more horizontal space to fit cards onto the screen. But then you can't really have much info in the card list.
Horizontal for the deck, vertical for your card library maybe?

Why does not letting the player sell/trade cards that would cause them to have no legal decks extrapolate to not letting them have any illegal decks whatsoever?
It's useful to have incomplete decks. For example, if I'm working on acquiring cards to make a Blastoise deck, I want to be able to make an incomplete Blastoise deck to see what cards I still need to get, rather than having to fill the rest in with pointless cards (I won't be playing the deck until it's complete anyway).
And some random code you might find useful:
Code:
def hasLegalDeckAfterRemoving(card, quantityToRemove)
  quantity = library.quantity(card) - quantityToRemove
  for deck in decks
    if deck.quantity(card) <= quantity
      return true
    end
  end
  return false
end
Brute-forcing Energy costs would certainly work, but as you say, it would be inefficient. If you have m Energy attached, and an attack needs n Energy, you need to check n permutations of m Energy. I don't know of any attacks that have a total cost of more than 5, and realistically I don't think anyone will be attaching more than 10 Energy to a Pokémon. But that still leaves over 30000 ways you could pair them up.
Duplicate attached Energy reduces the actual number of unique permutations, so you can skip those. You can also define attacks to not care about Energy ordering (for example, any attack that only uses one type of Energy and doesn't do anything with the leftover Energy should be correctly catered to with the greedy approach).

Finally, as a side note, Ruby is no less useful than C++ - a language doesn't have to be hyper-efficient to be useful. I know C++, but still use Ruby a lot. Its versatile syntax that lets you do things like the one-line sort/filters above, and not requiring compilation, makes it good when you just want to get stuff done :P
Reply With Quote