gcoter / magic-the-gathering-python Goto Github PK
View Code? Open in Web Editor NEWA Python implementation of Magic The Gathering with a focus on AI implementation
A Python implementation of Magic The Gathering with a focus on AI implementation
Because these properties (as others) can be modified by other elements (for instance counters).
In the magic_the_gathering
folder, create a file hello_world.py
and implement a for loop printing all numbers from 0 to 10 (except 7). Add a section in README.md
about how to execute hello_world.py
.
Objects are instantiated by blueprints
PermanentObject
--> TokenObject
NonPermanentObject
PermanentObject
instances have an ObjectState
For now, the stack is only used during the MainPhase
. However:
The stack can get used and resolved basically anytime players can get priority, and resolve one element at a time
#24 (comment)
Also, the elements of the stack should be resolved one element at a time and players should pass successively to pass to the next resolution
It looks like the data is saved by reference, that means that for instance the player state at the end of the game is propagated to the previous data items
It is particularly needed when a creature has menace
, like for instance: https://scryfall.com/card/cmr/196/ripscale-predator
Add the ability for a game state to be evaluated from the perspective of each player.
The score could be a function of my creatures, my lands in play, my cards in hand, my life total VS my opponent's.
Additional ideas:
Note: this function cannot use information hidden from said player. This can be as simple as not using the attributes of cards in the opponent's hand for now, latter let's have a players_this_card_has_been_revealed_to
attribute.
When I try to dvc repro
, I get stuck at the collect_data
phase. It looks in some conditions, the game runs infinitely. It is difficult to reproduce because it happens randomly. For instance, 40 games can run without problem and then suddenly the next one turns endlessly. It is probably linked to one of the changes in #65
Combat is a tricky part of Magic, it would be nice to be able to simulate combats with specific cards chosen by us instead of running a entire game each time
CardBlueprint
--> PermanentBlueprint
--> NonPermanentBlueprint
If we want to use ML models for AI, we need to turn the GameState
into vectors
For instance, is_tapped
should be part of this state. The state should be set when we create an object from a given card.
For instance after the DrawPhase
, players can get priority so we should add a phase here
For instance, to create mana from a basic land (or a creature like https://scryfall.com/card/gnt/46/llanowar-elves)
Filtering cards according to criterias is quite common in Magic, it would be nice to have to have classes for that
It depends on:
When running a game, we could create a folder run-{uuid}/
and for each action write a JSON file action-{i}.json
with a structure like this:
{
"game_state": {The full `GameState` *before* the action is executed},
"action": {The `Action` being executed}
}
At the end of the game, one final JSON file results.json
could record the results of the game, something like:
{
"winner_player_index": 1,
...
}
Implement an AI player which just chooses one legal option at random each time it has priority
Set a flag to True when we cast a creature, set it to False at the beginning of the turn for creatures on the battlefield.
For a complete implementation, we should also consider changes of controllers. Also, we should generalize it to all permanent as non-creatures can become creatures.
Because otherwise we can't represent the source player of this action (which matters when training an AI)
A Trigger
has a list of TriggerCondition
and can create TriggerEffect
when the conditions are met. Trigger
and TriggerEffect
are added on the stack.
Either using something like tkinter or as a web app (developped with Vue.js for instance). The GUI should display the game state at any point in the game and allow the current player to pick one action among the possible ones.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.