Pokémon TCG: Sword and Shield—Brilliant Stars

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

Status
Not open for further replies.
Welcome aboard, betatesters!! I'm writing down your name, and I will contact you when your service is requested. Which I'm not 100% sure when will be, but a few weeks probably.

Now TacC, to answer you question about Master Ball/Dual Ball. The AI doesn't use Dual Ball, since I'm using a deck with cards in the present Modified format, but I understand your point. Do the AI use non-supporters first, and then supporter-trainers, or can it choose? For the moment I'm using the Supporters first, but there could be situations were I'd want to use Master Ball og Super Scoop Up before using Supporters (because this will affect what card to choose when using Lanettes Net Search, and also what card to discard with TV Reporter). However I have decided for now that those reasons aren't important enough. So for simplicity the check for trainers-sequence goes like this:

Lanettes Net Search (very hard card to program for... it took 200 lines of code)
Marys Request
Prof Cozmo
TV Reporter
Master Ball
Battle Frointier
Warp Point (this is a tricky fellow also... I haven't sunk my teeth in it yet)
Super Scoop Up

----------
After trainer checks it goes on like this:

- Finding out if evolving is possible and optimal
- Find out where to attach energy
- Find out if Legendary Ascent is possible and desired..
- Attack if possible

(then of course inbetween stuff, special condition stuff and then it's over to the Player...)
 
Last edited:
I hate to keep throwing things at you, especially since I know what a pain it can be to write, in logic, things that we take for granted but maybe you can accept this as my way or helping. :)

Personal opinion here but maybe the AI should hang onto cards like Battle Frontier and Warp Point to discard for TVR?

Also, one set of code you could include for Warp Point, and other Trainers really, would be something like this (in Pythonglish):
If AI prizes <= Player prizes then a
a=read bench
if bench=Pidgeot (only Pidgeot or its prevolutions) then play Warp Point


I don't know if you follow but I like that play. Go for the KO on Pidgeot but only if the game is tied or Zap is winning. Perhaps, you'd add another line to check to make sure that a KO on TTar isn't possible cause that would be a bummer to pass on a KO on him and then lose cause TTar KOs Zap for the win. There are a lot of conditions for almost every card so that really puts a damper on things but I'd start with conditions and break things down into groups based on what conditions are satisfied. Ehh, I'm getting ahead of myself but its a thought.

1st condition should be prizes. The AI should check the prize count at the start of every turn and then go into 1 of 3 sets of commands. (Winning, Tied, Losing)
2nd condition should be Zapdos' HP, benched and active. Then go into another set of conditions.
Basically a huge list of "if" "try" "else" until the best possible "decision" is made. The problem with this is that you would almost have to define every possible situation and the AI would do no thinking of its own. I don't expect you to write the Big Blue of Pokemon but perhaps leaving some decisions up to the AI is good? Or you could narrow down the AI's choices and leave it to ranomly choose 1. Just to keep it fresh.

You've probably seen the Tic Tac Toe program and other AI programs. The inherent problem with all of them is that they follow the same set of instructions every game. So while Tic Tac Toe is always a draw when both players make the best possible move, the Python programs that I've seen are always beatable using the same set of moves. I'd hate for you to put all this work into it and then have a standard game that always leads to the same conclusion.

I'm not discrediting anything you've done or will do, cause you gotta start somewhere. I'm just giving you some food for thought for future improvements (probably 2-3 months realistically).
 
Daddiursa said:
Thanks TacC!
I agree on the rating of the Supporters, which is basically how I will be doing it in the program. Except that I won't do it by points, I'll be doing it by sequence,

I swore I wasn't gonna get involved with this - I've simply too many irons in teh fire right now!
But with tha said - let me at least throw a few concepts out atcha.
In robotics AI programming much has been done on the study of insects - specifically cockroaches. If you think about it they do quite a bit with very little in teh way of brains, yet are one of the most successful lifeforms on the planet.
With that said, they have evolved a theory of sublimated behavior. What that means is that sometimes several options come up in which one option/action has to take priority but still leave room for the others. The cockroach may be starving and food is straight ahead but the lights come on (danger?). What does it do? Sublimated behavior then is the resolution of many sometimes conflicting events.
So how is the decision made - as in many things AI there are many - read up and see what is available. I prefer fuzzy logic. The advantage of using fuzzy logic is that it can be "tuned" to a player style - in other words playing a particular card may be an indicator of how aggressive that player is for that style of play.
I would extrapolate the categories of cards to also include the board state. You could have a rating for both sides in areas like strength: how powerful the pokemon on the board are, resources: how much energy is in play, deck remaining, prizes taken.
Now - there are learning algorithms known as genetic algorithmns, simulated annealiing, alpha-beta pruning, etc etc. I might favor SA or GA after every turn to evaluate the succeess of moves after every turn against the board states. This would allow the player style to learn what the best moves may be from a category of moves - the selection of course depending on what you have in your hand.
Now say the best move isn't represented in your hand - what are the odds of getting the best move if you have draw power - it knows what has been played and can calculate the odds of getting what it needs or even wheher it is available. This of course is part of the sublimated behavior - on what hand here is what I have - on the otehr here is what I might get. Choose. The behaviors may be influenced by the current state of the game (how bad off am I - or how good a position am I in) versus tactical advantage (do I want to strengthen my position or weaken his).
The worst part is calculating effects like Blaziken - it needs the setup to work properly and also the play style (discard enegy for search, suck it back up, move energy to attacker, attack).
I would have to say that somehow for the play to be effective there needs to be a play style associated with the decks. This makes sense in that every deck posted here also has a strategy to go along with it.
The strategy involves; optimal setup (what are the pieces that make this thing run), and play sequence - as illustrated by the Blaziken deck. In some cases the pieces necessary for optimal operation can have associated pieces - like you put a Delcatty or Pidgeot in just to search for the rest of teh pieces. So each card could "belong" to a strategy piece. As you draw the card the strategy that uses it (there may be several) would know that it is available so now that strategy could be activated. Of course you need a way to "un-notify" also in the case the card is used or discarded or shuffled back into the deck. So these are also behaviors that can fit into teh sublimation scheme. Thus the hierarchy of behavior could include things like: get setup for optimal play, protect critical resources, gain advantage by attack or denial (maybe remove energy from opponent, kill a basic to minimize future threat). The weight on each of these levels would also determine style of play - we've all seen players that favor suicidal attacks versus defense and vice versa. Each of teh major behaviors can be broken down into sub-behaviors to determine the appropriate behavior for that particular one. Say Setup is the dominant behavior - inside are behaviors for search (ger resources) or protect (your last combuskin is unfortunately in the active position). Which behavior gets activated is dependant on you current hand state (availability of means)or board state.
Hope this gives you something useful to chew on...
 
I have read your posts TacC and ScythKing, much food for thought there. TacC your thoughts on Warp Point makes me wanna change it for Pow! Hand Extension or Pokemon Reversal. Simply because they are good cards, and because learning the AI to perform a Warp Point move is hard... I can picture the PokeM8 calculating that there is a disruptive effect to Warp Pointing the defending pokemon, but not quite being able to figure out what to do on its own side of the field. Reversal or PoW! simplifies this, wouldn't you agree?

About the AI theories, ScythKing. Thanks for bringing in lots of interesting perspectives surrounding how to build the AI. I think my plan for now is right up that cockroach alley. Let me explain:

On whatever issue in the program where there are no "perfect" or "correct" choice to do, then, I will give the AI alternative "routes" to go. For instance, lets say I include Pidgeot and Desert Ruins in the Players deck, then the AI can either play agressivly (to stop a sudden Pidgeot), or passivly, wait for Desert Ruins and then remove it with a BF... To styles, no one is "the truth". So what I'm gonna do is this:

Upon set up I randomly choose a playing style for each of these "issues", and then I store that choice, along with the result of the game. (This can be done automaticly w/o the user knowing it). Now after plenty of beta-testing I can then bring in the results from this file, and let the AI use it by looking at the data in that file, see if an agressive style resulted in more wins than looses... and then it can play accordingly.

That's cockroach thinking isn't it?
 
Last edited:
Sceptilerancher, you are added to my list of potential beta-testers. I will contact this group once there is something to betatest.

Ash_Van_Je, if you look a little further up in this thread you'll se a link to the code at an eariler stage in development, however there's nothing to test until I have programmed a little more.
 
Just to let you know I am working on this project (not just goofing around @ DS prereleases), here's an update:

I'm approaching the latter part of writing the code for what happens on the AIs turn. That means the brain-twisting part of the program... Heres the status:

(- = work needs to be done, + = finished)

- Putting down basics
+ Check/Use Lanettes Net Search
+ Check/Use Mary's Request
+ Check/Use Prof. Cozmo's Discovery
+ Check/Use TV Reporter
+ Check/Use Poké Ball
+ check/Use Battle Frontier
+ Check/Use Legencary Ascent
- Check/Use Super Scoop Up
- Check/Use Legencary Ascent
- check/Use Pokemon Reversal
- Evolve
- Retreat
- Attach energy
- Attack

----------

If you want to look at the documentation for the Python classes and functions in this program, look here.
 
Last edited:
You might think that nothing is happening with this project... Well, think again!!

Here is me getting my (you know what) handed to me by the computer:

http://www.multinett.no/~simonsig/PokeM8/pic5.JPG

But, to my excuse... the Players attack-procedure is not finished, as well as "a few" other thing.

For the moment communications with the computer goes via the command-line and small graphical user interfaces (GUIs) dealing with specific tasks. Gathering all info in one GUI might take too much time, I'd hope to bring in pictures of the actual cards, but I haven't found too much info on how to do it..

So anyone with info on this, your welcome to speak now!
 
So, the AI is working out well enough? I'm waiting to see how it reacts to the eccentricities of a real player, rather than just going through the motions...
 
bullados said:
So, the AI is working out well enough? I'm waiting to see how it reacts to the eccentricities of a real player, rather than just going through the motions...

The AI isn't perfect, but I'll hopefully know what to improve once it is put in use (which can be done once the "Player routine" part of the program is ready, as well as the inbetween rounds checks etc.)

The interesting thing to see will be if the AI is so predictable that the player will be able to exploit that after playing a few rounds with the program...
 
Last edited:
looks like your loosing perty bad in that game...considering you Jirachi has -10 hp left ^^

Does the AI reconize when a pokemon is knocked out/when one draws a prize? Or am i thinking a mile ahead? lol

Also, if needed, I can beta test aswell
 
In between checks aren't made yet, so that's why that Jirachi went beyond 0 HP. What is left to program for is the rest of the players attacks (I have one or two programmed), and in-between checks.

The project is due for delivery pretty soon, and although I am in danger of not completing it as I personally want to, I am very confident in that enough work has been put into the project so that it will be acccepted. Nearly 3.000 lines of code have been written. I honestly didn't think it would take this much time and effort, but I've learned a lot.
 
Last edited:
Hello -

I applaud your noble and lofty goal!

If it helps, understanding how to design a game, and understanding what has already been created and thus can be borrowed from are invaluable ways to define what your going to build. Starting with data structures and classes, etc.. can lock you into paths that are not easily fixed as you progress, so I recommend those discussions take place after it becomes clearer what the overall gameplay looks and feels like.

Here is a link to a book you may find helpful:
http://books.google.com/books?hl=en.../search?hl=en&q=programming+a+poker+card+game

Take care and good luck
 
That's for the tip!

The BIG task in finishing the project in a more professional way, is to get a better user interface. But building a user interface for handling the battle is not as easy as 1-2-3. Just look at the Lackey interface, it's loads of detailed stuff and different kind of menus etc. So building something like that along with an AI engine.... well, I have concentrated on the latter, but of course if I want to get more widespread use of the program I'd have to build a better interface.
 
Hi again :)

Yes, the user interface and playability are key -- you are right on!.

Almost forgot to mention -- there are a lot of card games already out there, such as poker, blackjack, etc.. that are already built and look pretty slick. You may be able to get access to some of these to see what the core code looks like and to see their mechanics; you can then use these as the basis for your pokemon software project. In that way, you can start with a straightforward and solid core program, and then add in all of the special pokemon rules and card effects as "use cases." As new sets are released, upgrades to the datasets and to the use cases become fairly straightforward. Hope it helps :)

Dave
 
In looking for materials that might be helpful to you, I stumbled on a site by Chris Crawford. He made a slot of early and major contributions to gaming software in the 80's and 90's. Here is a link to some of his writings on game design. Hope you find this helpful. Take care.

http://www.erasmatazz.com/Library.html
 
Status
Not open for further replies.
Back
Top