Pokémon TCG: Sword and Shield—Brilliant Stars

The PokeM8 project: Building "apprentice with brains" in Python

Status
Not open for further replies.
OMG if I only knew what those codes mean =P, well I guess I just can give u the best of the luck on this project and that's very nice to know that someone is doing something interesting to "improve"apprentice for pokemon.....
 
Thanks a lot! As we have seen there are ppl with programming experience on this forum besides yours truly, so hopefully something cool will emerge. When the first prototype is ready (somewhere in the future) I'll tell you where you can get a copy of Python to install on you computer. Don't worry, it's freeware! But don't expect a Terminator 2 sit down for a game of pokemon.... giving this Frankenstein a proper brain will take time...

------------------

UPDATE: a routine for shuffling the cards are now implemented,
 
Last edited:
That's probably the most obvious way to program this, creating 60 different Card variables to represent a deck. I KNOW that there are more elegant and probably less space consuming and time consuming ways to code this, most of them using different linear algebra algorithms, but I've only programmed basic C++ and Java, and only for a couple of years. Realistically, that's probably the way I'd code it in C++, until I learn some new programming techniques or something.

Great job with that! If you need any help with general ideas, I can try and help wherever I can...
 
having pics of the cards would def. be a nice touch, but it seems that AI is of much higher importance. being able to test against a comp. would be so sweet...i would def. download that :tongue: gl w/ this project man!
 
Yeah, where can I get to program?
Actually I learnt Visual Basic when I was 12 and now I am 14 so I hope I remember some of them...where can I get the program? Yeah...yay. It is SO cool.
 
Thanks for all the input. Gotta rush for school now, but when I get home I'll post links to useful Python sites where you can download free copies.
 
I am a 3rd year Uni student. I have done a paper in AI, and I have a couple of books on it too.
I know how to program in Java and C++. I dont think it would take me long to pick up your lang. I would find it very inlighting to help ya and I know how to plan out programs too. Just finished a 30 page assignment on it :p Just PM if you want my help
 
Overkill said:
I am a 3rd year Uni student. I have done a paper in AI, and I have a couple of books on it too.
I know how to program in Java and C++. I dont think it would take me long to pick up your lang. I would find it very inlighting to help ya and I know how to plan out programs too. Just finished a 30 page assignment on it :p Just PM if you want my help

This is gonna be fun! I had a feeling there were ppl with similar interests out there. So, of course I want your help! The best way to participate at the moment is just to follow me a bit while I build the data structure and make suggestions as you feel. Having a somewhat common understanding of the datatypes and structures will make "taking" about the tasks later a bit easier.
 
Ok, "Card" is going to be a class in the program, and that means I build a "standard scheme" (I lack the perfect word here...) where all possible info on cards can be stored. And later when I read the input-file (containing the deck-lists). Then I make "instances" of such Card-objects and fill in info accordingly, comparing the name with a pre-defined list of cards with all the needed info about them. (This is why Metagross suggested I start with basics, energy and easy trainers, b/c filling out the list of complete info on every card is a huge job...So I will start with a few selected cards, just enough to make a legal deck).

So I need your input on this Card class:

"Cards" must be able to hold this info:

type = 'trainer', 'pokemon' or 'energy'

For pokemon it needs:
  • name
  • stage
  • retreat cost
  • weakness
  • resistance
  • type
  • attack (this must be a list of attacks each holding:)
    name
    cost
    damage
    effect *)
For trainers it needs:
  • name
  • type
  • effect **)
And for energy:
  • name
  • type
  • effect
Questions:

*) Can effect of attacks be categorized or grouped together? A start could be;
- can target any pokemon
- can target several pokemon (spinning tail)
- ignore weakness/resistance
- special conditions
- etc etc (your help is wanted here)

In the beginning I won't let the AI use any complicated attacks, and I'll program for those I need. Also the human player might have to perform his attack "manually", like adjust opponents HP by one self, switch active if attack say so, etc etc,

**) Can effects of trainers be categorized?
- draw cards from deck
- search out card(s)
- manipulate position of pokemon (eg Warp Point, Switch)
- replace attack
- give more HP
- remove weakness
- etc etc.... the list goes on and on... but identifying the basic ones first is a good start. Example:
- I need Mary's Request, Lanette, Warp point etc, but I don't need Sitrus Berry or Solid Rage yet....
 
Last edited:
Can you have classes within classes, as C++ and Java can? If so, you can define a class called "Card" which has 1 variable, which will be one of 3 classes of cards defined as you put above. One class called "Pokemon", one "Trainer", one "Energy". Also, for the Energy class, you'll probably need 4 variables called "Name", "Type", "Number" (or something similar), and "Effect", each of which will be a particular data type. Probably the easiest way to create the imbedded classes idea is a standard toggle event within the "Card" class, using an X value of 0,1,2 -- each toggling a different class to be "active" within each specific card, and inactivating the other two.

For Attack, that'll probably also have to be another class.

Please tell me if I'm completely off in my definition of classes in the language you're using, I only know what they are in C++ and Java...
 
bullados said:
Can you have classes within classes, as C++ and Java can? If so, you can define a class called "Card" which has 1 variable, which will be one of 3 classes of cards defined as you put above. One class called "Pokemon", one "Trainer", one "Energy". Also, for the Energy class, you'll probably need 4 variables called "Name", "Type", "Number" (or something similar), and "Effect", each of which will be a particular data type. Probably the easiest way to create the imbedded classes idea is a standard toggle event within the "Card" class, using an X value of 0,1,2 -- each toggling a different class to be "active" within each specific card, and inactivating the other two.

For Attack, that'll probably also have to be another class.

Please tell me if I'm completely off in my definition of classes in the language you're using, I only know what they are in C++ and Java...

Python supports subclasses yes, so I can make Card a main class and then the three different types of cards can be subclasses inheriting all the methods etc from Card and overriding as nessecary. However I have them as one class now and have a type variable inside. So when I create instances of "cards" the name of the card is passed along as a parameter, and then inside the card-object the name uniquely steers all the variables into it's proper setting (the object calls a lot of functions which can say something about the card, like weakness, retreat cost etc)

The "effect" bit on attacks, trainers and energy is a tricky bit.... because I have to take a lot of things into consideration at the same time. Like the effects of attacks, effect of powers/bodys etc etc...

When it comes to the deck the player will use I only have to make sure he can control everything manually... and as far as the AI deck goes... all effect I have to think of is the Zapdos_ex poke-power and it's option of discarding for 70 damage. The Voltorb is straight-forward as is the Electrike. The Manectric I use is the Thunder Spear version, so the ability to attack benched pokemon too is something I must take care of, as well as the second attack doing 40 or 40+10xlightning plus the 10 damage to itself. All these effects must be programmed "one at a time", but the effect-variable will tell the AI that there is an effect, and then the AI "brain" can take that effect into consideration, for example by searching for possible KO's... by anticipating how much damage will be dealt to it's active next round etc....
 
I really must congradulate you on this. I remember back in HS I did a re-construct of the Pokemon
battle scenes, with a VERY basic AI using BASIC. It was fun, and I worked on it for a whole year,
learning more than I could have ever imagined. Keep it up my friend!! Who knows, you may be
able to use this for a portfolio thing and get yourself into the gaming world. :thumb:

I wish I could help you now, but my studies have taken me to database and web programming. Most
notably with PHP / MySQL, but also with VB.NET, ASP.NET, JAVA, XML, etc. It's actually interesting
working with OOP with PHP, as PHP really isn't a language written for OOP. =) Currently there
is a new language being born, called SOAP, and I'm trying to get a jump on that language, as many
companies that I'm interviewing with are asking if I have heard / studied any of it yet.

Sorry... I went on a tangent... my apologies. Back on topic...

Seeing the code and all so far... going with parent / child class's will definetly help in re-using code...
also see into using constructor's and destructors. I really wouldn't know how to program AI... but if
I was going to try, I would do something like...
1) Check board... is my active strong enough against what they have out?
2) If not, then do I have something in hand to help retreat?
3) If so... do I have anything to evolve / draw with?
4) Check energy placement... does my active have enough energy to attack?
5) Would my active be worth the energy placement for the attack? (IE -will it be KO'd by the current
opponent active or bench?)

That's just the prelim there off the top of my head... of course I'd add in the check for Poke-Powers, etc.
 
Cardtable seems closer to Lackey than Apprentice. I didn't know of it, so thanks for the info. Although it is free, the "inside" of the program might be protected, so I don't know how much use I have for it, but nice knowing of it nevertheless.
 
I would say sub classes are the best bet,
Super class - card
Name:
Type of card: Trainer, energy, pokemon
Type: (Grass, fire. For trainer just put a type trainer)
Rarity: This could help with picking of cards in the deck
Or we could have like playing value and this would change though the game.

Then the subclasses like you said

Pokemon:
this should also be broken up into 3 classes
Basic, first stage and second stage.

* For each card they should have if they can evo and also how valuably it is to evo this card
* Each basic should have how important they are to have on the bench, and this would change with where you are in the game


Trainers:
This could be broken up into a number of classes
Draw, Heal, Shuffle ect


Energies really only need two types:
Basic and special

I personal think the key to making this work well would be having like a percent rating on each card that tells the computer how valuable the card is at this point in time. This would be worked out what kind of deck you are going up against and the condition of your pokemon ect. So each turn the percent rating would change. But this would be most valuable with searching for cards from the deck
 
Hmmm...very intriguing idea!

However, even for such a simple deck as ZapDOS, an AI would be a challenge. Examples: knowing when to drop the first gym, what to reversal up, when to admin, etcetc.
 
Patriarch said:
Hmmm...very intriguing idea!

However, even for such a simple deck as ZapDOS, an AI would be a challenge. Examples: knowing when to drop the first gym, what to reversal up, when to admin, etcetc.

That is very true, I guess the only way you can do it is from making it learn from each game it plays as such. But for simple AI, you would really just give it a kinda point system for things like reversal and admin and once it has reached the required points it would play the card even if its not the best time to play it, Gym on the other hand would be a different story as it is very important when you play this card :confused:
 
Benlugia said:
there has to be some way that this can work though.
i mean, excuse me if i bring up yu-gi-oh for a moment. take a look at their video games based on the tcg. very little does the computer opponents misplay.
and how can i forget the video game pokemon tcg? there were few misplays there aswell.

Are you kidding? Imakuni would use his card on himself just to confuse him, that game was misplay-arific.
 
I completely agree that the AI even for a simple Zapdos deck isn't just A-B-C, 1-2-3... It's gonna be complicated as hell to solve this optimally. The reason why chess games do so well isn't b/c they have a "perfect brain" programmed, but rather because they have a huge bunch of material to search in. Great chess games are stored inside the program move by move, and the "AI" can just search thru them, compare it to the current game and trace all legal moves and return with the one who resultet in most victories.

However this little program must make it's desicions on no pre-stored material. So I have to come up with a routine to solve this. Basically that means in what order should the AI check for conditions? and what conditions must it compare?.

An rough scetch can be like this (after basics have been laid down, mulligan checks are over etc):

1) Draw (if not first turn)
2) Search for threats (here I might need a point-system where obvious threats, like ready-fired up pokemon with KO potential gets a high score, wheres pokemon that can evolve and possibly get enough energy are on the middle of the scale, and pokemon that cannot KO the AI even when evolving and using special energy etc gets a low amount of "threat points")
3) Search for best AI-attack possibility (the AI would here like to choose Zapdos_ex, but only if there is enough energy in play to use it and if weakness isn't an issue) Special firt turn routines can be design so that the AI always goes for Recharge even if Zapdos ex isn't "reachable", purely to rely on fetching it by topdecking a trainer or the card itself.
4) If 3) didn't imply the use of a supporter trainer, then run thru the trainers at hand and it should be pretty obvious what to choose. the AI can either play stadiums defensive (to counter Desert Ruins) or offensive (lay down BF no matter what...) Mary's request has top priority if Lanette isn't chosen at 3), Scoop up at first can be for damaged "used" Zappys, and later on I can program for even smarter use, Warp Point I dunno... maybe choose an easier trainer there... etc

So, well this was just a vague attempt, but one has to start somewhere.... Feedback is wanted!

Btw I've dubbed the program The PokeM8 for now... Is that a good or a bad name?
 
Seems like you will do fine with your program (the name is fine). I think your biggest obstacle will be programming in every deck strategy in what to do against another deck, but I am sure we all can help you. :) How long do you think it will take to do all of that?
 
Status
Not open for further replies.
Back
Top