It is currently 16 Dec 2017, 09:12
   
Text Size

Traversable Game State/Engine Code

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins

Re: Traversable Game State/Engine Code

Postby KrazyTheFox » 30 May 2015, 01:16

I've spent the past two days working out some important groundwork for getting combat working as well as fixing some issues. Cost payments are now enforced and you can cancel casting spells. Cards are checked before playing/casting to ensure it's legal to do so. After ensuring all of that worked, I implemented summoning sickness. Next I added in power, toughness, and damage and updated to UI to display all of these. I also started work on state based actions, primarily creature death due to lethal damage and placeholders for a few other important state based actions necessary to implement the starter set.

State based actions are processed in two parts to ensure that complex interactions are correctly accounted for, such as the recent Hurricane + Platinum Angel bug. First, all state based actions are checked to see which ones need processing based on the current game state. These are all added to a list. The list of actions is iterated over after all checks are completed and each action is executed. If any actions were taken, the process is repeated. It's simple, but it seems to do the job quite nicely.

Finally, I've started adding in loading cards from data files. They keep mostly in line with the current format (though that's likely to change significantly when it comes to scripting abilities, etc):
Code: Select all
Name:Bog Imp
ManaCost:1 B
Types:Creature Imp
StaticAbilities:Flying
PT:1/1

I've started working out the details of how I'm going to tackle combat. I'm hoping to have at least attacking completed by tomorrow evening and blocking by Sunday evening. I'm going to have to refactor the way I'm asking for input from players and I'd like to get that right early on.

Since most of the stuff here is under the hood, I'll skip the .gif this time. :P
User avatar
KrazyTheFox
Programmer
 
Posts: 716
Joined: 18 Mar 2014, 23:51
Has thanked: 66 times
Been thanked: 212 times

Re: Traversable Game State/Engine Code

Postby Xitax » 30 May 2015, 19:11

Are you... uh, completely rewriting Forge?
Xitax
 
Posts: 804
Joined: 16 May 2010, 17:19
Has thanked: 129 times
Been thanked: 104 times

Re: Traversable Game State/Engine Code

Postby KrazyTheFox » 30 May 2015, 19:14

Xitax wrote:Are you... uh, completely rewriting Forge?
Yeah, pretty much. :lol:

The fundamental building blocks of the engine need to change to support what I'm trying to do, so instead of trying to re-work it, I'm starting anew.
User avatar
KrazyTheFox
Programmer
 
Posts: 716
Joined: 18 Mar 2014, 23:51
Has thanked: 66 times
Been thanked: 212 times

Re: Traversable Game State/Engine Code

Postby mastroego » 31 May 2015, 06:02

:shock:
Any chance you'll code the 150+ missing cards too along the way? :mrgreen:
mastroego
 
Posts: 230
Joined: 22 Sep 2013, 14:04
Has thanked: 28 times
Been thanked: 16 times

Re: Traversable Game State/Engine Code

Postby KrazyTheFox » 31 May 2015, 17:21

mastroego wrote::shock:
Any chance you'll code the 150+ missing cards too along the way? :mrgreen:
I can say with certainty that some of the cards will probably never, ever be implemented (I'm looking at you, Chaos Orb). However, I'm making every attempt to keep things extremely flexible, so it's possible that at least some of those cards could be implemented without problems. Looking over the unimplemented card list, many of them should be doable. It's good that you reminded me to look at that list to see what kind of weird things I'll need to code the new engine for.
User avatar
KrazyTheFox
Programmer
 
Posts: 716
Joined: 18 Mar 2014, 23:51
Has thanked: 66 times
Been thanked: 212 times

Re: Traversable Game State/Engine Code

Postby friarsol » 31 May 2015, 17:35

A lot of them care about looking back in time at a certain event, so having a traversable game state will allow those to be implemented immediately.
friarsol
Global Moderator
 
Posts: 7136
Joined: 15 May 2010, 04:20
Has thanked: 230 times
Been thanked: 854 times

Re: Traversable Game State/Engine Code

Postby mastroego » 01 Jun 2015, 18:14

=D>

Well, I certainly don't mean to sound alarmed or anything, I'm just sincerely curious.
What will happen with the coded cards? I mean I can understand rewriting the engine [ :shock: ] but 15000 cards?
Ok, I know there are lands and simple cards too, still, such an undertaking seems almost too much to be believed.
Or will cards code be salvaged?

And don't worry, I think we can safely live without Chaos Orb and other meta-cards :wink:
mastroego
 
Posts: 230
Joined: 22 Sep 2013, 14:04
Has thanked: 28 times
Been thanked: 16 times

Re: Traversable Game State/Engine Code

Postby KrazyTheFox » 01 Jun 2015, 18:55

mastroego wrote:15000 cards?
It is a tall order, certainly. However, the system I'm building should also make scripting cards far more simple. Each ability, effect, etc. will be composed of a series of actions that, together, create a much more complex ability. In fact, the entire game is composed of these actions and that's how I'm making everything reversible. Each action does one thing and can undo that one thing. For example, the current Untap step goes like this:

Code: Select all
for each player, do a ClearManaPoolAction
for each creature the current player controls, if it has summoning sickness, do a RemoveSummoningSicknessAction
do an AdvancePhaseAction (advancing to the Untap step)
for each card the current player controls, if it's tapped, do an UntapCardAction

It's still going to be a lot of work to support the huge amount of cards we currently have implemented again, but now that we have existing cards as a reference, a lot of things should be find/replace and those that aren't won't be too hard to convert.

As with the rest of this project, I won't be surprised if it ends up taking years to being this up to the completeness level that Forge supports now. If I were able to work on this full time, it might take just a year. :lol:
User avatar
KrazyTheFox
Programmer
 
Posts: 716
Joined: 18 Mar 2014, 23:51
Has thanked: 66 times
Been thanked: 212 times

Re: Traversable Game State/Engine Code

Postby mastroego » 01 Jun 2015, 20:53

Krazy, I'm amazed and thankful that you're even willing to contemplate such a plan.
At the same time, I'd advise to consider carefully if it really is the right way to go about it.
Forge already has taken years to get where it is, and it gets SO MANY things right.
Not perfect, of course, nothing is.
And it's a miracle already, almost the entirety of non profit projects such as this end up as vaporware. Forge defied any reasonable expectation in this regard.
But starting from scratch, with a project that will require coding all the cards again?
You might risk losing the steam for the current iteration of this amazing project, and not having enough for the next one.

Not trying to sound negative, just prompting some additional thought, maybe from a different perspective.
I'll be here giving the feedback I can regardless :)
In any case, thanks for devoting your skills to this and may your plans see completion :)
mastroego
 
Posts: 230
Joined: 22 Sep 2013, 14:04
Has thanked: 28 times
Been thanked: 16 times

Re: Traversable Game State/Engine Code

Postby KrazyTheFox » 01 Jun 2015, 22:11

mastroego wrote:Not trying to sound negative, just prompting some additional thought, maybe from a different perspective.
I totally get where you're coming from and there's a definite possibility that I'll never actually finish this. That said, it's a fun project to work on right now and that's the most important part to me. While I may run out of steam (and probably will), there's a very good chance I'll come back to Forge (it's happened a couple times already). I tend to jump between a few projects at any given time. Additionally, once I have the core game together and the kinks worked out, I'll create a new branch on our SVN repo and hopefully some others will jump in and help out with it. If nothing else, it'll be there for someone else to pick up.

mastroego wrote:I'd advise to consider carefully if it really is the right way to go about it.
I'm not sure how else I'd get better AI into Forge, really. :P I would absolutely take the easier route if there was one.

mastroego wrote:I'll be here giving the feedback I can regardless :)
In any case, thanks for devoting your skills to this and may your plans see completion :)
Thanks! It's stuff like this that makes it all super satisfying. Getting to share cool things with people is half the reason I program stuff.
User avatar
KrazyTheFox
Programmer
 
Posts: 716
Joined: 18 Mar 2014, 23:51
Has thanked: 66 times
Been thanked: 212 times

Re: Traversable Game State/Engine Code

Postby mastroego » 02 Jun 2015, 15:52

Well, if I EVER get to a point in my life where I have more free time (something I'm actively striving for, but might not ever happen) I might try and pick up coding myself to help.
Life led me elsewhere, but I looked like I could become a good programmer in my youth :)

I'd have to start basically from scratch and all, but I think I might be able to code a bunch of cards from the basic building blocks.
So again, best of luck :)
mastroego
 
Posts: 230
Joined: 22 Sep 2013, 14:04
Has thanked: 28 times
Been thanked: 16 times

Re: Traversable Game State/Engine Code

Postby KrazyTheFox » 04 Jun 2015, 01:21

As it turns out, MtG combat is really complex. :lol:

I've been chipping away at it and some rudimentary AI. Right now I have most of the actual combat basics in place: declaring attackers, declaring blockers (including multi-blocking), assigning damage (rules not enforced), dealing damage to both players and creatures, and a state based action to kill creatures when their damage is lethal. Combat steps are removed and added as necessary. The AI attacks and blocks, but doesn't assign damage. The player can only attack so far. The AI also casts creatures and plays lands and is capable of making mana payments with mana abilities.

Hopefully I'll be able to implement the missing pieces for player input to get combat completely working within the next couple of days. There's also a couple undo/redo bugs I need to tackle.
User avatar
KrazyTheFox
Programmer
 
Posts: 716
Joined: 18 Mar 2014, 23:51
Has thanked: 66 times
Been thanked: 212 times

Re: Traversable Game State/Engine Code

Postby mastroego » 04 Jun 2015, 07:05

Hi again Krazy, do you remember this thread about Combat refactoring?
(I mean you might have been in hiatus)

viewtopic.php?f=52&t=15836
An entirely new (and, by the looks of it, quite complicated) algorithm was created by elcnesh in order to code a few more of the missing cards, like Viashino Bey.

I seem to remember that the blocking part could not be solved even then though.
Sorry if the information is redundant :)
mastroego
 
Posts: 230
Joined: 22 Sep 2013, 14:04
Has thanked: 28 times
Been thanked: 16 times

Re: Traversable Game State/Engine Code

Postby KrazyTheFox » 04 Jun 2015, 17:36

mastroego wrote:Hi again Krazy, do you remember this thread about Combat refactoring?
(I mean you might have been in hiatus)

viewtopic.php?f=52&t=15836
An entirely new (and, by the looks of it, quite complicated) algorithm was created by elcnesh in order to code a few more of the missing cards, like Viashino Bey.

I seem to remember that the blocking part could not be solved even then though.
Sorry if the information is redundant :)
That's good to know for future use. Right now I'm just focused on giving players the ability to declare attackers and blockers in the first place. I've got a few ideas to speed up blocking, but those will have to wait for the actual AI to be programmed in. The current "AI" is just here to demonstrate that these things work. It's very bad at actually playing the game and will remain that way for a while. :P
User avatar
KrazyTheFox
Programmer
 
Posts: 716
Joined: 18 Mar 2014, 23:51
Has thanked: 66 times
Been thanked: 212 times

Previous

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 2 guests


Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 10 minutes)
Most users ever online was 279 on 11 Jul 2013, 22:03

Users browsing this forum: No registered users and 2 guests

Login Form