Pokémon TCG: Sword and Shield—Brilliant Stars

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

Status
Not open for further replies.
Water Pokemon Master said:
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?

Thanks, nice that the name is use-worthy, later on when GUI programming becomes the focus I could really use some help in designing a logo (*hint, hint*, *nudge, nudge*).

The biggest obstacle is to program all the different effects of cards. That's sort of why I chose to start with Zap-turn-dos, because very often you play it straight-forward and hope to mow down your opponents pokemon one at a time and hope that zappy isn't KO'ed and all energy in play are lost... that's when you doomed... But to make the AI really efficient I have to take every cards attack and defence possibility into consideration. Just to take an example, when I face Jumpluff the AI has to play "greedy" on the energies to avoid helping Jumpluff... The AI don't know this automatically, so I have to program a "Jumpluff-routine" into it, to play optimally against this deck... and there are houndereds of examples of where Zapdos, even with it's basically straight-forward attack-plan, may want to fine-tune it's play...

If I succed and the AI works, then, depending on the amount of time I can put into it, I might move on to program for another deck-type...

How long time this will take? I honestly don't know. But by x-mas I have to be able to show the program to my teacher for evaluation, and I would very much like the AI and the User Interface in place by then... Fine tuning the AI is probably a life-long project depending on how much routines I can keep when implementing a new deck...

Status Report:
I'm apporaching 200 lines of code. I work on the data structues for the moment. I have defined what I call "class Card" to hold all card-info, and I am currently working on "class InPlayObjects" to hold one "entity" of cards on the table.. by that I mean for example a pokemon that's evolved and has a trainer and maybe energies attached, that's what I call an "entity" (or InPlayObjects"). I'm soon gonna program the "class CardsInPlay" which is basically an organistation of the active & the bench, This again hold "InPlayObjects" so that I can "talk" to CardInPlay whenever I wanna switch, evolve, attach energy/trainer or discard or return to hand... And THEN after this... the "Play routine" must be programmed to control the flow of the program and present some sorf of menu or overview to the user along with explanation of how to make choices (or operatoe on his pokemon)
 
Last edited:
I'll go back and read through this thread when I have a little more time. I read most of it as it pertains to AI and so forth. Its incredibly hard, even with the most basic deck but it is possible. As a complete shot in the dark I would guess that it would take months to make strong Zap-Turn-Dos AI capable of running the deck smoothly. The AI would have to run almost ignorant of the opponent. You'd have to program it to think of things like R. Admin, Copycat, Desert Ruins, Vileplume ex, etc. It took most great players years to get where they are, its gonna take at least that many man hours to get an AI capable of playing at a high level. Plausable though. I don't even want to think about Zap-Turn-Dos decks that run Manectric and Electrode.

Anyhow, the reason I'm chiming in is just to say that I have experience with Python and made a number of programs (albeit simple ones) in my time. I haven't worked with Python in quite some time so I'll definitely have to dust off the skills if this does come to fruitition. I'll try to stay in the loop but most of my time is dedicated to strategizing right now. I'm probably better suited to write the basics of the AI, analyzing HP, cards remaining in the deck, etc.
 
Maybe there could be three levels of how good the AI could be? simple, intermediate, master.... maybe something on those lines...

one question, how much space are we talking about on the computer to be able to function this program?

But this is definantly an intruiging idea and could be very very beneficial in all our hands.......
 
Last edited:
Thanks for the input TacC and Rokman. I will run thru this thread myself and take a note of everyone with skills that could become useful, and then later on, when/if I see that certain jobs could be distributed to others, I'll write a pm and ask for specific help.

Next steps will be:

- finish with the data structure
- make functions for operations on them (so that the player can be able to see "the table" and can use commands to manipulate every card there, on his hand and in his deck the way a player can do normally.
- then the AI-fun starts and maybe I will just show the algorithm "in plain words" as I program it, so ppl can comment on it... Because this is really the same as trying to put human rationale into a machine understandable language... and I smell quite a few obstacles here...

Nevertheless I hope this could become a functionally program. Either for fun, or to test how your own deck performs against the AI deck. Most likely the AI will never be at the Expert level, but at least I can hope to be somewhere between beginners and intermediate... and if I go beyond that it will be a tremendous bonus...
 
Last edited:
Would you make the server engine like Netbattle? Apprentice is a pain in *** for Network users.
 
Jason said:
Would you make the server engine like Netbattle? Apprentice is a pain in *** for Network users.

For now the program will be one that you can download and use it if you have Python installed. Python is free, so all it takes is a little time to learn how to run a program in it... (which isn't hard at all). I recommend IPython (search for that on Google)

The program will, at least for now, have several limitations. Just to give the AI something to chew on I have to give it a "testdeck" to play against. I cannot, not until very much work is put into the program. Let it loose on ANY deck... The reason for this is that I have to program a routine for every trainercard, every pokebody and every pokepower there is out there, in order to to that. The AI needs this info to do calculations on how to perform, and also the program needs to know, for example, what "Legendary ascent" does, b/c several "moves" are included, and there a hundreds of other "moves" coming from attacks, powers etc... "Moves" = anything that doesn't do a "straight" X damage, or heal X damage, or switch to pokemons positions, and those needs to be programmed in detail.. So at first I'll start with two given decks, one for you and one for the machine... And later - time will show - I can add cards to be "sortiment", so that you can make your own deck.

The first goal is to make something that resembles the old pc game of pokemon tcg (maybe not graphically...), where you played agains Julie, using either a fighting deck (w machoke) or a water deck (w dewgong), Anyone remember this?
 
Hmm.......making a mirror deck(Zappy) for the A1 wouldn't make it any easier, would it? I know nothing about this, just think it is cool that you are doing this.
 
@Daddiursa: I have that game. I got it in one of those TCG boxes, but it is also on the Pokemon 4Ever DVD incase you need to look at its programming (if you can.)
 
Shiloh Phoenix said:
Are you kidding? Imakuni would use his card on himself just to confuse him, that game was misplay-arific.

Well, that misplay was intentional. After all, Imakuni probably plays his card the instant he gets it because he just can't wait. There were plenty of unintentional misplays, like burning a Potion on a Pokemon that will be KO'd next turn regardless and such.

The latest entry into the YGO series, Nightmare Troubadour for the Nintendo DS, still has plenty of misplays: not as gross as the first U.S. released YGO game for the GBC (where the computer would run 3 Raigeki... and use them all at once, one right after the other, even if you had no Monsters in play), I have one quite a few games now because the computer didn't realize "Cannon Soldier, launch field" would give it the win... or the opposite: Cannon Soldier, launch field not for the win, and leave itself wide open.

Good luck with the project. I have not real programming skills, so i can't be much help. Sorry.
 
Metal Master said:
Hmm.......making a mirror deck(Zappy) for the A1 wouldn't make it any easier, would it? I know nothing about this, just think it is cool that you are doing this.

I don't thing I'll program for a morror-match, although this would give me only half the job.. I want to program for another deck that can be a fair challenge to Zapdos, but still not a deck that relies too much on wierd attacks and pokebodies/powers. Maybe a Spinning Tail variant? Programming for Magcargo's Smooth over or Pidgeot's Quick Search isn't too hard, and Spinning Tail T-Tar is pretty straigth forward.

Do you have any better suggestions?
 
Daddiursa said:
I don't thing I'll program for a morror-match, although this would give me only half the job.. I want to program for another deck that can be a fair challenge to Zapdos, but still not a deck that relies too much on wierd attacks and pokebodies/powers. Maybe a Spinning Tail variant? Programming for Magcargo's Smooth over or Pidgeot's Quick Search isn't too hard, and Spinning Tail T-Tar is pretty straigth forward.

Do you have any better suggestions?
All good ideas but I think its best to go with a deck of all basics first just to lay a solid foundation. I would go with something like the Latias & Latios half decks for starters.

To predict damage on the following turn you're going to need the AI to analyze current Energy and possible Energy attachment on the next turn, which would be anywhere from 0 - 4 Energy (or more, depending on the deck but only DragTrode came to mind) and all that just to decide whether or not its appropriate to use a Potion.

EDIT: How is Lengendary Ascent working? I assume you have the AI use it ASAP the first time around but what about the 2nd or 3rd time?
 
Last edited:
Legendary Ascent is the "nut" to crack in the Zapdos AI deck, but the way I have to program it is like this:

For starters I will only include pokemon (in both decks) that have powers that work own their turn, otherwise I would have to make check routines that work "all the time" like is the case with Dark Ampharos and a bunch of other poke-powers.

Ok, so everytime it's the AI's turn:

1) Check if there are any "effects" (wherein lies poke-powers) that can be used.
2) If YES, then the "Legendary Ascent function" (LAF) will check wether or not it can be used (which is NO if it is already in play)
3) if YES, then LAF will check if it's use is nessecary. This can be negative if active pokemons HP is = or > than 110 HP (otherwise the AI will perform LA and move a perfectly unharmed Zapdos out of the way... which I can only think is useful when the AI's bench is empty). It can also be NO if active pokemons attack is enough to KO opponents active, but this means I have to check for every eventuality.. and that's very hard if the player's deck include Electrode ex (maybe identified by a Voltorb on bench).. Cos even if say Manectric can do a KO, it might have too little HP... and the AI might run the risk of having it KO'ed by a "shock comeback"...

So LA is hard, but I will start with the most obvious things, and add checks to it later, to tweak it's perfomance..
 
Last edited:
I think most people are happy to see a deck tester program in development. Personally, i think he first version available should have a simple interface, sort of like apprentice as opposed to the gb game or the lackey program, just to have a simple deck tester program out quickly to satisfy pokegym members.
 
Hi!

I would like to get your feedback on the shuffling routine I have built into the program, this is a typical sequence of what the AI deck looks like after shuffling:

In [27]: run PokeM8.py
Manectric
Lanettes_Net_Search
Battle_Frontier
Lightning_Energy
Voltorb
Master_Ball
Lightning_Energy
Lightning_Energy
Lightning_Energy
Prof_Cozmo
Lightning_Energy
Zapdos_ex
Electrike
Lightning_Energy
TV_Reporter
Marys_Request
Lanettes_Net_Search
Lightning_Energy
Lightning_Energy
Voltorb
Lightning_Energy
Lightning_Energy
Marys_Request
Lightning_Energy
Lightning_Energy
TV_Reporter
Manectric
Zapdos_ex
Manectric
Battle_Frontier
Master_Ball
Lightning_Energy
Master_Ball
Lightning_Energy
Lanettes_Net_Search
Electrike
Voltorb
Lightning_Energy
Zapdos_ex
Lanettes_Net_Search
Voltorb
Warp_Point
Marys_Request
Marys_Request
Prof_Cozmo
TV_Reporter
Electrike
Prof_Cozmo
Prof_Cozmo
Lightning_Energy
Lightning_Energy
Battle_Frontier
Master_Ball
Electrike
Warp_Point
Battle_Frontier
Zapdos_ex
Lightning_Energy
Manectric
TV_Reporter

In [28]:


As you can see some cards are stacked together, like 2 Cozmos and 2 Marys + the energies. Now the energies I can understand, because there are 18 of them and they are bound to come a few in a row once in a while...

Now the routine is built using Pythons built-in random-function. I have a counter (starting at 60) and then the machine picks a random number between 1 and 60, and adds it to the "shuffledDeck" list. Then the counter is incremented (I think that's the word) and a new random number is selected, and at the end all the cards from the deck-list are copied over to the shuffled list in a random fashion.

Now can anybody tell be 1) is the list above "random" enough? and 2) What can I do to improve this if it's not satisfactory?
 
Last edited:
I see some hops in there.

For example...

Master_Ball
Lightning_Energy
Master_Ball

Or

Manectric
Zapdos_ex
Manectric

Same card only one apart. Don't know how to fix it though. Other than that, looks pretty good.
 
daddiursa, I am almost positive that is how the already made Appr shuffles... but I think its a good system
 
It looks good to me Daddiursa. With 60 cards in a deck, you're bound to get a few that stick together. You may have 3 Cozmos within 5 cards, but worse things have happened to me.

Keep up the good work!
 
An interesting thing about python and perl is that they built in odbc.

Personally, if I was going to tackle this project, I'd first create an sql data base for the cards (which others have already done), then use a single linked list for the players cards. no real need to make obj's for the deck, discard, bench, and so forth. each obj in the linked list could have a var designating which card to referance from the database. it's current status, and location. working with a single object will make life much easier. save on memory, and increase speed. plus, the side effect of using something like sql for the cards, is that when a new set comes up, it'd be easy to update the program, or to fix erratta.

as far as the AI goes,
I would break down the basic options available to a player and give each item a dynamic point system based off need and usage. placing energy for instance, need on each card gives a numerical priority using an incrementing system, (if energy(current) < energy(needed) val++, if energy(available) == (lightning) val++ and so on, whomever comes up with the highest number, gets the energy needed. at a 0, no energy gets played. decks could then be constructed with a side script of initial value tweaks which would influence what gets priority.

just my few cents,
-CattDreams
 
Thanks a lot for the input. Cattdreams I'm creating a Python module with classes of all objects in the program - the obvious ones: hands, deck, prize etc, and then the "constructed" ones, like CardInPlay which can take care of the whole "table" meaning that it stores card-objects and keep track of which ones are evolved and from what basic, with or without rare candy, when that card was played, are there energies or trainers attached etc..

My database is just two .txt files with the deck-list. The module only holds the info needed for the exact cards I'm using, that's enough for now. But later incorporating SQL is better indeed, we'll see where this goes...

It's nice to get feedback on the shuffling, I'm keeping an eye on it and maybe talk to some fellow students taking statistic courses.
 
Last edited:
Status
Not open for further replies.
Back
Top