It is currently 16 Apr 2024, 12:48
   
Text Size

Mad Wizard

An original game by ubeefx

Moderators: ubeefx, CCGHQ Admins

Re: Magarena 2012

Postby ubeefx » 31 Oct 2012, 20:42

That's right. I referred to the trunk in my previous posts, not the download section.

Anyway, I guess I can also make a Halloween :twisted: release so I did.
Two Magarena releases on the same day. Madness. :o

I use a new versioning system, namely the number of cards supported. Currently this is 2510 cards.

Main change is the rule text patterns, which provide an elegant way to support many many cards.
Not only now but also in the future. Unless the Wizards somehow decide to rephrase all their cards. #-o

I noticed Melvin is also up to something with a MTG rule text grammar, we will see where that effort goes.

Enjoy. :D
User avatar
ubeefx
DEVELOPER
 
Posts: 748
Joined: 23 Nov 2010, 19:16
Has thanked: 34 times
Been thanked: 249 times

Re: Magarena 2012

Postby Huggybaby » 31 Oct 2012, 21:57

ubeefx wrote:I use a new versioning system, namely the number of cards supported. Currently this is 2510 cards.
Well, I have seen cases (with other software) where a newer version supports less cards, so if that happens your version number will decrease rather than increase.

When I start a duel now and the deck list viewer pops up, that is a nice UI change.

I'm sure melvin's parser will lead to good things. Too bad every app ends up using its own, when we have a sort of 3rd party one that already exists. I guess it's similar to the case where it's easier to tear down an existing house and start fresh than rebuild something already there.
User avatar
Huggybaby
Administrator
 
Posts: 3205
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 696 times
Been thanked: 594 times

Re: Magarena 2012

Postby melvin » 01 Nov 2012, 05:28

@ubeefx: The rules text matching is a great idea. I was headed in that direction as well, but I realized that using regular expressions can only go so far before it gets quite hard to read/maintain so I tried to find something better and that's when I stumbled upon Parsing Expression Grammar. Surprisingly powerful, yet simple and readable.

@Huggybaby: Which is the 3rd party parser you are referring to?
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

Re: Magarena 2012

Postby ubeefx » 01 Nov 2012, 09:57

Well, I have seen cases (with other software) where a newer version supports less cards, so if that happens your version number will decrease rather than increase.
Now there is a very good reason for this not to happen. :)

There is still potential for more patterns or improving existing ones, it all boils down to work.
But 25 % (2344) of the total card pool (9200) supported by patterns is already a nice place to be.
Less than 7 % (166) of the cards still requires specific code. Together this is 2510 cards.
There are currently 56 patterns matching 2880 lines of rule text.
Mind, parsing is only one side of the story. You still need to compile it into somewhat optimal code for AI.
User avatar
ubeefx
DEVELOPER
 
Posts: 748
Joined: 23 Nov 2010, 19:16
Has thanked: 34 times
Been thanked: 249 times

Re: Magarena 2012

Postby Huggybaby » 01 Nov 2012, 16:27

melvin wrote:@Huggybaby: Which is the 3rd party parser you are referring to?
It's here: viewtopic.php?p=44680#p44680. It outputs XML, CSV, C++, Java, PHP, JSON, and SQLite.
User avatar
Huggybaby
Administrator
 
Posts: 3205
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 696 times
Been thanked: 594 times

Re: Magarena 2012

Postby Huggybaby » 01 Nov 2012, 16:37

ubeefx wrote:
Well, I have seen cases (with other software) where a newer version supports less cards, so if that happens your version number will decrease rather than increase.
Now there is a very good reason for this not to happen. :)

There is still potential for more patterns or improving existing ones, it all boils down to work.
But 25 % (2344) of the total card pool (9200) supported by patterns is already a nice place to be.
Less than 7 % (166) of the cards still requires specific code. Together this is 2510 cards.
There are currently 56 patterns matching 2880 lines of rule text.
Mind, parsing is only one side of the story. You still need to compile it into somewhat optimal code for AI.
Have you looked at Wagic or Incantus or any of the others that are able to implement cards using very simple syntax? How does your new method compare?

My dream is that a modular foundation begins to emerge. I hope that one day a programmer could use a parser from one place, the rules engine from another, the AI from another, the network code from another, etc. Then instead of starting from scratch one could focus on the things that really make a program unique (from a user's perspective anyway) like the UI, quest modes and unlocks, challenges, etc.

And there's still my long term goal of having one app play another.
User avatar
Huggybaby
Administrator
 
Posts: 3205
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 696 times
Been thanked: 594 times

Re: Magarena 2012

Postby ubeefx » 01 Nov 2012, 20:14

Have you looked at Wagic or Incantus or any of the others that are able to implement cards using very simple syntax? How does your new method compare?
I did look to Wagic, Incantus, Mage and Forge, but it is a long while ago.
I did that however after I made Magarena open source.

Let's take Bladewing the Risen which I mentioned in a previous post as example.
I hope the authors of the mentioned projects do not mind this comparison.
This has nothing to do with what is better, because whatever lets people enjoy the cards is a good formula.

First how did Magarena implement this card previously?
There would be a card properties file and Java class containing code for the activated and triggered abilities.
Unfortunately the card is not yet available in Magarena 1.31, but here is for instance the properties file for Rorix Bladewing, which is fully scriptable without Java code :

Code: Select all
name=Rorix Bladewing
url=http://magiccards.info/pch/en/65.html
image=http://magiccards.info/scans/en/pch/65.jpg
value=4.460
rarity=R
type=Legendary,Creature
subtype=Dragon
cost={3}{R}{R}{R}
pt=6/5
ability=flying,haste
timing=fmain
Mage would just have a Bladewing the Risen class, with all the code written in Java, also the properties.

I also could not find the card in Incantus, but it works similar to Magarena.
A part of the card code are properties and the other part would be Python script code for the abilities. This is for instance Shivan Dragon :

Code: Select all
name = 'Shivan Dragon'
cost = '4RR'
types = Creature
subtypes = Dragon
power = 5
toughness = 5
text = ['Flying', '{R}: ~ gets +1/+0 until end of turn.']

#################################

abilities.add(flying())

@activated(txt=text[1])
def ability():
    def effects(controller, source):
        cost = yield ManaCost('R')
        target = yield NoTarget()
        until_end_of_turn(source.augment_power_toughness(1, 0))
        yield
    return effects
abilities.add(ability)

--------------- Shivan Dragon
Wagic and Forge both have a full custom scripting approach.

This snippet comes from the latest Wagic release :
Code: Select all
[card]
name=Bladewing the Risen
abilities=flying
auto=may moveTo(myBattlefield) target(dragon[-instant;-sorcery]|mygraveyard)
auto={B}{R}:lord(dragon) 1/1
text=Flying -- When Bladewing the Risen enters the battlefield, you may return target Dragon permanent card from your graveyard to the battlefield. -- {B}{R}: Dragon creatures get +1/+1 until end of turn.
mana={3}{B}{B}{R}{R}
type=Legendary Creature
subtype=Zombie Dragon
power=4
toughness=4
[/card]
And this snippet comes from the latest Forge release :
Code: Select all
Name:Bladewing the Risen
ManaCost:3 B B R R
Types:Legendary Creature Zombie Dragon
Text:no text
PT:4/4
K:Flying
A:AB$ PumpAll | Cost$ B R | ValidCards$ Creature.Dragon | NumAtt$ +1 | NumDef$ +1 | SpellDescription$ Dragon creatures get +1/+1 until end of turn.
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigReturn | OptionalDecider$ You | TriggerDescription$ When CARDNAME enters the battlefield, you may return target Dragon permanent card from your graveyard to the battlefield.
SVar:TrigReturn:AB$ChangeZone | Cost$ 0 | Origin$ Graveyard | Destination$ Battlefield | ValidTgts$ Permanent.Dragon+YouOwn | TgtPrompt$ Choose target Dragon permanent in your graveyard.
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/bladewing_the_risen.jpg
SetInfo:SCG|Rare|http://magiccards.info/scans/en/sc/136.jpg
SetInfo:COM|Rare|http://magiccards.info/scans/en/cmd/185.jpg
Oracle:Flying\nWhen Bladewing the Risen enters the battlefield, you may return target Dragon permanent card from your graveyard to the battlefield.\n{B}{R}: Dragon creatures get +1/+1 until end of turn.
End
And last but not least, how does the code look in Magarena 2012. Wait, is it even code? :wink:

Code: Select all
Legendary Creature — Zombie Dragon 4/4, 3BBRR (7)

Flying

When Bladewing the Risen enters the battlefield, you may return target Dragon permanent card from your graveyard to the battlefield.

{B}{R}: Dragon creatures get +1/+1 until end of turn.
I hope this makes clear what I try to do and why I find it a unique approach.
This post certainly took a while to write, it looks like a blog article. :)

Even if people write stuff from scratch, they can get inspiration from the other projects and have a much higher chance of success.
User avatar
ubeefx
DEVELOPER
 
Posts: 748
Joined: 23 Nov 2010, 19:16
Has thanked: 34 times
Been thanked: 249 times

Re: Magarena 2012

Postby melvin » 02 Nov 2012, 08:51

Huggybaby wrote:
melvin wrote:@Huggybaby: Which is the 3rd party parser you are referring to?
It's here: viewtopic.php?p=44680#p44680. It outputs XML, CSV, C++, Java, PHP, JSON, and SQLite.
I'm aware of this resource, but it doesn't quite do what we need. The parser that ubeefx built and the one I'm working on takes a line of rules text and generate the behavior of the card automatically. It is not about getting the data, it is about taking the data and automatically translating that to a working card in the game.

The related projects are:
Gleemin - http://www.goblinopera.com/mathemagics/?p=167 and
Demystify - https://github.com/Zannick/demystify
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

Re: Magarena 2012

Postby jeffwadsworth » 02 Nov 2012, 13:41

@ubeefx
You mentioned that some cards required specific code. Apparently their text could not be translated correctly? Any examples? Melvin, perhaps you ran across something similar.
jeffwadsworth
Super Tester Elite
 
Posts: 1171
Joined: 20 Oct 2010, 04:47
Location: USA
Has thanked: 287 times
Been thanked: 69 times

Re: Magarena 2012

Postby melvin » 02 Nov 2012, 15:48

@ubeefx: Great post comparing the different card implementation strategies. I couldn't agree more that the best card script is the rules text itself.

@jeffwadsworth: Unfortunately way too often, every file in https://code.google.com/p/magarena/sour ... agic/card/ is card specific code for a card in Magarena 1.x. One of the more interesting cards is Aven Mimeomancer, which has a ton of additional rules clarifications on Gather. This shows that it is hard to understand even for human players.
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

Re: Magarena 2012

Postby ubeefx » 03 Nov 2012, 19:25

I couldn't agree more that the best card script is the rules text itself.
Indeed. Rules text is actually much closer to a script than people might think because the way it is written is very formal and thus suitable for pattern matching or parsing grammars.

You mentioned that some cards required specific code. Apparently their text could not be translated correctly? Any examples?
When I started with the rule text patterns, there were 555 supported cards with over 400 cards requiring specific code because the card properties file was insufficient.
Watchwolf is for instance possible with just properties.

The first step was to fully replace the card properties file with a file generated from set text spoilers.

Then I started added one by one the rule text patterns. Each time I added a new pattern, not only did the engine support a bunch of new cards, but also some of the existing card specific code could be removed, for instance a triggered ability.

At the moment there are 2510 supported cards, with 166 still requiring card specific code. However, for some of them, I can still add patterns, like for the Cruel Edict type effect.

I could actually add patterns for all of the remaining hardcoded cards, but for a card like Aven Mimeomancer that Melvin already mentioned this would make not much sense because it is both a complex and unique effect.

Also, when I speak of a 9200 cards potential, I refer to the entire card pool starting from 7th edition and Invasion. But the engine does not and will not support all these cards. For instance Planeswalkers, multiple targets, split cards are not considered at the moment to be supported.
User avatar
ubeefx
DEVELOPER
 
Posts: 748
Joined: 23 Nov 2010, 19:16
Has thanked: 34 times
Been thanked: 249 times

Re: Magarena 2012

Postby ubeefx » 07 Nov 2012, 21:25

A new release of Magarena 2012 is available with 2650 cards.
Unless you are a deck builder, that seems plenty to me to have some fun.

What is my motivation for Magarena 2012?

First, after working on Dreamwalkers, it felt quite satisfying to work again on a project that other people actually play.
Second, it is an update for Magarena 1.11 or for the lucky few that got Magarena LE 1.13.
Third, bring some of the Dreamwalkers goodies to Magarena.

What were the things I wanted to improve?

UI

Some improvements that should make the game more enjoyable :
  • updated wood theme, which I personally like a lot
  • improved startup screen like Dreamwalkers
  • improved deck viewer like Dreamwalkers
  • the aaargh sound like in Dreamwalkers
  • text information from text mode on card popups, very useful feature
AI

The major flaw of the MiniMax AI was that it could take ages in some situations to find a move.
I dislike cheating in AI. I think in real life few people would appreciate that an opponent can see your hand and which cards you will draw.
So I would like to disagree that MCTS that needs the cheating is the real answer to that.
I added some tricks so that the AI now always responds in a certain time related to the difficulty level.
I played several games with it and I think it still plays decently and is very responsive.
The AI in Dreamwalkers also has this property, but that was largely thanks to the lowered complexity.

Cards

I took the starting idea how to implement cards from Dreamwalkers, improved it and applied this to Magarena.
I wanted to add 2000 cards in a nice way and I think I did.
I look forward to see how many new cards will be supported over a year without writing a single line of code.

Compliancy

The discard to maximum hand size at cleanup rule was actually very easy to add, so I did.
The layer system with timestamps was necessary to support much more cards.

Enjoy. :D
User avatar
ubeefx
DEVELOPER
 
Posts: 748
Joined: 23 Nov 2010, 19:16
Has thanked: 34 times
Been thanked: 249 times

Re: Magarena 2012

Postby Huggybaby » 08 Nov 2012, 14:54

Hello ubeefx,

The cancel function of the picture downloader doesn't work, requiring a visit to Task Manager if one wants to stop it.
User avatar
Huggybaby
Administrator
 
Posts: 3205
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 696 times
Been thanked: 594 times

Re: Magarena 2012

Postby ubeefx » 08 Nov 2012, 19:17

The cancel function of the picture downloader doesn't work, requiring a visit to Task Manager if one wants to stop it.
Yeah I agree with that much images this is even more annoying than it was, needs to be fixed...
User avatar
ubeefx
DEVELOPER
 
Posts: 748
Joined: 23 Nov 2010, 19:16
Has thanked: 34 times
Been thanked: 249 times

Re: Magarena 2012

Postby Huggybaby » 09 Nov 2012, 02:47

Please check, I played a game and couldn't tap Plague Myr for mana.
User avatar
Huggybaby
Administrator
 
Posts: 3205
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 696 times
Been thanked: 594 times

PreviousNext

Return to Dreamwalkers

Who is online

Users browsing this forum: No registered users and 17 guests


Who is online

In total there are 17 users online :: 0 registered, 0 hidden and 17 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 17 guests

Login Form