It is currently 23 Jul 2019, 11:11
   
Text Size

New Magic program: Gleemin

General Discussion of the Intricacies

Moderator: CCGHQ Admins

New Magic program: Gleemin

Postby Ye Goblyn Queenne » 07 Jan 2011, 16:25

Hello everyone :)

I've just reached the first milestone of my Magic program, "Gleemin: the Magic Virtual Machine". It's my final year project for my computer science degree at Brighton university (in the UK) and it's written in Prolog (with some Java to be added soon, for the GUI).

You can find some information about the project and my code so far, here:

http://www.goblinopera.com/mathemagics/

Or download an executable file from here:

http://www.goblinopera.com/Gleemin/Gleemin_swi_Win32.zip
(Windows exe)

http://www.goblinopera.com/Gleemin/Gleemin_swi_linux.tar
(Linux executable)

The current milestone is simply an empty-shell Magic turn sequence. You can go through a turn to see all the phases and steps firing in the correct order and state-based actions (such as untapping, drawing, declaring attackers etc) being reported. No actions are actually taken by the game or players, yet- that's the next milestone that I need to finish by the end of the month (the GUI needs to be finished by February but I'm developing both together, by necessity, so hopefully it will take less). As the GUI is not done yet, the output is only textual.

The project must finish by April with a full AI. According to my schedule of activities for the project, I should start developing the AI by the beginning of March- so there's still two months to go.

In the meantime I would love some feedback, suggestions and so on.

Have fun and enjoy Magic :)

Stassa Patsantzis (Ye Goblyn Queenne).

(Edit: added links to the executables)
Last edited by Ye Goblyn Queenne on 08 Jan 2011, 19:59, edited 1 time in total.
Ye Goblyn Queenne
 
Posts: 20
Joined: 07 Jan 2011, 14:55
Has thanked: 1 time
Been thanked: 1 time

Re: New Magic program: Gleemin

Postby ubeefx » 07 Jan 2011, 19:40

Very cool and challenging to do as a last year university project! 8)
Prolog is also an interesting environment to program a Magic game.
I am very curious about the results you will achieve.
Magarena is also on this forum and has a MiniMax AI, you can read about it on page.
Good luck with the project!
User avatar
ubeefx
DEVELOPER
 
Posts: 404
Joined: 23 Nov 2010, 19:16
Has thanked: 14 times
Been thanked: 74 times

Re: New Magic program: Gleemin

Postby Ye Goblyn Queenne » 08 Jan 2011, 00:55

Hi ubeefx, yes, of course I know Magarena :) I have downloaded it but I haven't tried it yet. I have to anyway, as part of my project (I'll have to report on the current state of Magic AI). mtgrares has said your program's AI is very strong, I really have to try it out and have a look at your code too. Though I'm a rubbish player myself so I won't be much challenge... #^_^

Prolog is a natural choice for AI. Unfortunately it's not as accessible as, say, Java. My fellow students hate it, :cry:
Ye Goblyn Queenne
 
Posts: 20
Joined: 07 Jan 2011, 14:55
Has thanked: 1 time
Been thanked: 1 time

Re: New Magic program: Gleemin

Postby ubeefx » 08 Jan 2011, 10:24

I also followed a course on functional programming and it indeed requires a different approach and mindset to solve problems.
But for rule based systems Prolog is certainly a valid choice and it is interesting to see what it can offer in comparison with a traditional language.
User avatar
ubeefx
DEVELOPER
 
Posts: 404
Joined: 23 Nov 2010, 19:16
Has thanked: 14 times
Been thanked: 74 times

Re: New Magic program: Gleemin

Postby Ye Goblyn Queenne » 08 Jan 2011, 19:57

Ubeefx, was your course on Lisp? I understand that it's more often tought in US universities while Europeans prefer Prolog. I like both :)

I compiled a couple of executables for Windows and Linux, they can be found on the blog, or directly from here:

http://www.goblinopera.com/Gleemin/Gleemin_swi_Win32.zip
(Windows exe)

http://www.goblinopera.com/Gleemin/Gleemin_swi_linux.tar
(Linux executable)
Ye Goblyn Queenne
 
Posts: 20
Joined: 07 Jan 2011, 14:55
Has thanked: 1 time
Been thanked: 1 time

Re: New Magic program: Gleemin

Postby ubeefx » 08 Jan 2011, 23:06

It could have been Haskell, long time ago, I do not remember exactly. :)
User avatar
ubeefx
DEVELOPER
 
Posts: 404
Joined: 23 Nov 2010, 19:16
Has thanked: 14 times
Been thanked: 74 times

Re: New Magic program: Gleemin

Postby Arch » 08 Jan 2011, 23:55

This project is interesting to me for a couple of reasons;

The parsing of the MGL, as you refer to it, is something that's been on my mind from time to time. I've been looking for a way of going from card-text to data. If you could find a good way of doing something like that that I could steal I would be much obliged.

It seems the high-level design/angle of attack is very similar to how I was going to do my own implementation. (Placing the complexity of interaction in the cards themselves rather then tangling it up in the game-engine, if I understood your blog correctly.) It will be interesting to see how it works out for you. I never got very far so I'm not sure it's a completely sound approach but it seemed feasible.

It's prolog. Prolog is an interesting language and it's been on my "to learn"-list for some time but I've never really had any good motivation to study it. Given the points above though maybe it's time to start...
User avatar
Arch
Programmer
 
Posts: 206
Joined: 04 Jul 2009, 09:35
Has thanked: 0 time
Been thanked: 15 times

Re: New Magic program: Gleemin

Postby MageKing17 » 09 Jan 2011, 05:31

Arch wrote:The parsing of the MGL, as you refer to it, is something that's been on my mind from time to time. I've been looking for a way of going from card-text to data. If you could find a good way of doing something like that that I could steal I would be much obliged.
There are actually a couple projects working on parsing rules text directly. I made a simple version to speed up work on Incantus cards that parses an Oracle spoiler and generates code based on what it sees (it's very hard-coded and basically just catches common abilities). A couple of other people are trying to create a grammar-based approach, but as far as I know, none of those approaches are anywhere near complete.
User avatar
MageKing17
Programmer
 
Posts: 473
Joined: 12 Jun 2008, 20:40
Has thanked: 5 times
Been thanked: 9 times

Re: New Magic program: Gleemin

Postby Arch » 09 Jan 2011, 08:45

MageKing17 wrote:There are actually a couple projects working on parsing rules text directly. I made a simple version to speed up work on Incantus cards that parses an Oracle spoiler and generates code based on what it sees (it's very hard-coded and basically just catches common abilities). A couple of other people are trying to create a grammar-based approach, but as far as I know, none of those approaches are anywhere near complete.
I usually don't venture outside this sub-forum so I would easily miss something like that. What projects/people are working towards a grammar? Searching the boards didn't really yield any answer to that and I'm interested in incomplete attempts as well.
User avatar
Arch
Programmer
 
Posts: 206
Joined: 04 Jul 2009, 09:35
Has thanked: 0 time
Been thanked: 15 times

Re: New Magic program: Gleemin

Postby Ye Goblyn Queenne » 09 Jan 2011, 15:28

Arch, hi. Thanks for having the patience to read my blog carefully :)

I have indeed noticed posts here about parsing Magic cards' text. We all seem to have the same approach, if I remember correctly and it's the natural one, develop a formal grammar and write a parser for it. I think it only makes sense, the Magic rules text is basically a scripting language nowadays, so having an interpreter to read it in and execute it is the natural next step, I'm surprised WIzards haven't done it yet.

Again I think Prolog is a natural choice for this, as the one thing everyone agrees on about it is how good it is in natural language processing and for rapid prototyping, including that of compilers/ interpreters. Basically, you can declare your own operators with minimal fuss and it's weakly typed so it's easy to develop and test your design. Also it has its own syntactic sugar for natural language (called Definite Clause Grammars or DCG) which again speeds things up a lot. MGL incorporates a lot of natural language but imposes some syntactic restrictions (like the "<Abilityname> : <Effect>" thingy) and I guess that's why it's been a tough nut to crack (natural language processing is indeed no picnic!).

I started the blog to talk about Prolog too, with my code for the project as an example. There are some good tutorials around the internet, this being probably the friendliest and the one that has helped me the most:

http://www.amzi.com/AdventureInProlog/index.php

... it's an adventure game, written in Prolog. It helps that it's a game, believe me ;)

Here's the bit about Prolog's natural language processing abilities:

http://www.amzi.com/AdventureInProlog/a15nlang.php

I'll try to make a post about starting out with Prolog for the absolute beginner today, hopefully.

Just one note though, this year I'm coding the gameplay and the AI. I plan to begin coding the MGL parser next year, once I'm finished with my degree (the truth is that's my favourite part so I'm leaving it for last, ^_^). I'll have to do some theoretical spade work this year though, so I'll keep everyone posted. I'm quite open to working with others btw.


ubeefx wrote:It could have been Haskell, long time ago, I do not remember exactly. :)
Haskel. Uh, damn, another language I've installed the tools to learn and never really got round to... :shame:


Arch wrote:
MageKing17 wrote:There are actually a couple projects working on parsing rules text directly. I made a simple version to speed up work on Incantus cards that parses an Oracle spoiler and generates code based on what it sees (it's very hard-coded and basically just catches common abilities). A couple of other people are trying to create a grammar-based approach, but as far as I know, none of those approaches are anywhere near complete.
I usually don't venture outside this sub-forum so I would easily miss something like that. What projects/people are working towards a grammar? Searching the boards didn't really yield any answer to that and I'm interested in incomplete attempts as well.
I just had a look and there's this thread started by proud:

viewtopic.php?f=27&t=2543

I haven't had time to read it carefuly but again I think we pretty much have the same plan.
Ye Goblyn Queenne
 
Posts: 20
Joined: 07 Jan 2011, 14:55
Has thanked: 1 time
Been thanked: 1 time

Re: New Magic program: Gleemin

Postby ubeefx » 09 Jan 2011, 15:32

I tried out your executable and it works. :) It sure helps not having to install SWI Prolog.
In Magarena it is possible to have different implementations for the gameplay or turn structure.
While developing AI, it can help to use a simplified turn structure at first.
Like start with a single main, some burn spells and lands and no combat and let application grow.
User avatar
ubeefx
DEVELOPER
 
Posts: 404
Joined: 23 Nov 2010, 19:16
Has thanked: 14 times
Been thanked: 74 times

Re: New Magic program: Gleemin

Postby Huggybaby » 09 Jan 2011, 21:07

A couple topics about parsing rules, etc.:
viewtopic.php?p=16845#p16845
viewtopic.php?f=27&t=2543

And there must be more.
User avatar
Huggybaby
Administrator
 
Posts: 3081
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 580 times
Been thanked: 573 times

Re: New Magic program: Gleemin

Postby Incantus » 09 Jan 2011, 21:36

Ye Goblyn Queenne wrote:
ubeefx wrote:It could have been Haskell, long time ago, I do not remember exactly. :)
Haskel. Uh, damn, another language I've installed the tools to learn and never really got round to... :shame:

I highly recommend "Learn you a Haskell for Great Good" http://learnyouahaskell.com/ to learn Haskell. I've been trying to pick it up for a few years, and this guide, while playful, does a really good job explaining some of the trickier aspects (like monads and zippers). I'm still waiting for the next chapters to be written (hopefully on monad transformers and arrows).

Anyway, to bring this on-topic, I've been mulling the idea of implementing a rules based AI in haskell or LISP, which both have good facilities for building backtracking AIs.
Incantus
DEVELOPER
 
Posts: 267
Joined: 29 May 2008, 15:53
Has thanked: 0 time
Been thanked: 3 times

Re: New Magic program: Gleemin

Postby Huggybaby » 09 Jan 2011, 21:42

If you do, try to keep it modular and remember if it's not in Java, good luck finding help from volunteers. :P
User avatar
Huggybaby
Administrator
 
Posts: 3081
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 580 times
Been thanked: 573 times

Re: New Magic program: Gleemin

Postby Ye Goblyn Queenne » 10 Jan 2011, 02:37

ubeefx wrote:I tried out your executable and it works. :) It sure helps not having to install SWI Prolog.
Woa! Best news all day! Thanks ubeefx! I guess you must have tried the Linux executable ;)

ubeefx wrote:In Magarena it is possible to have different implementations for the gameplay or turn structure.
While developing AI, it can help to use a simplified turn structure at first.
Like start with a single main, some burn spells and lands and no combat and let application grow.
Yes, I understand. I was planning to begin with creature combat first, on a kind of sandbox (so not really a turn structure in there at all), then integrate that with the turn, then see about spells. I may have to cut some corners to present a finished project anyway.

In any case my card pool is the Intro Packs form M11, so I don't even have to do Planeswalkers combat or loyalty abilities- yet. I'm taking it easy!

Huggybaby wrote:If you do, try to keep it modular and remember if it's not in Java, good luck finding help from volunteers. :P
Lol, quite true! But if it's done like you say, modular, then anyone can just plug the AI and the rules engine into their own front-end, written in their favourite language. Actually, I was hoping to re-use an existing GUI from an open-source project, rather than have to write my own ('cause I really have no time to do that) but I really have no time to do that (see what I did there?). Maybe I'm overestimating the difficulty though- there's a foreign language interface for Swi-Prolog that lets Java call Prolog and v.v.

Thanks for linking to those posts. I need to find some time to read them (two assignments and an exam coming up in the next two weeks. Yikes!).


Incantus wrote:
Ye Goblyn Queenne wrote:
ubeefx wrote:It could have been Haskell, long time ago, I do not remember exactly. :)
Haskel. Uh, damn, another language I've installed the tools to learn and never really got round to... :shame:

I highly recommend "Learn you a Haskell for Great Good" http://learnyouahaskell.com/ to learn Haskell. I've been trying to pick it up for a few years, and this guide, while playful, does a really good job explaining some of the trickier aspects (like monads and zippers). I'm still waiting for the next chapters to be written (hopefully on monad transformers and arrows).

Anyway, to bring this on-topic, I've been mulling the idea of implementing a rules based AI in haskell or LISP, which both have good facilities for building backtracking AIs.
Wow! That looks really cool! Thanks! I'll give it a try :D

Ooh, LISP is powerful!! It's the other natural choice for this kind of project. Of course, if you want backtracking you may well end up writing Prolog in Lisp...
Ye Goblyn Queenne
 
Posts: 20
Joined: 07 Jan 2011, 14:55
Has thanked: 1 time
Been thanked: 1 time

Next

Return to Magic Rules Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest


Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 10 minutes)
Most users ever online was 287 on 31 Mar 2019, 04:11

Users browsing this forum: No registered users and 1 guest

Login Form