About decoupling GUI from game
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
12 posts
• Page 1 of 1
About decoupling GUI from game
by Max mtg » 01 Oct 2012, 19:28
I thought of how would forge be playable from a remote host. Like a person or AI program is giving commands to forge to play certain cards and perform other actions. But how is it possible when ability factories have hardcoded calls to GUI?
It looks like to me that depending of type of active player the input method will vary: GUI for local human player, some api calls for local AI, and over network iteraction for one who plays remotelly - no matter against who.
That means that all players interactions should be untied from rules enforcement engine. I guess
It does not even require to remove all those if-else's for different actions for AI and human player. AI code might even stay in its place.
So, I think that all the human player interaction should be somehow wrapped to make an overload with a different behaviour possible.
It looks like to me that depending of type of active player the input method will vary: GUI for local human player, some api calls for local AI, and over network iteraction for one who plays remotelly - no matter against who.
That means that all players interactions should be untied from rules enforcement engine. I guess
- Code: Select all
final Object o = GuiUtils.chooseOne("Choose first creature to exile", chooseGrave);
- Code: Select all
activePlayer.getCommuncation().chooseOne("Choose first creature to exile", chooseGrave)
It does not even require to remove all those if-else's for different actions for AI and human player. AI code might even stay in its place.
So, I think that all the human player interaction should be somehow wrapped to make an overload with a different behaviour possible.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: About decoupling GUI from game
by friarsol » 01 Oct 2012, 20:21
I like where this is headed and the possibilities of using a fake remote player to handle AI vs AI.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: About decoupling GUI from game
by moomarc » 02 Oct 2012, 08:55
This is when I wish I had more coding experience so that I could help out, but at the moment I'd do more harm than good. Sounds great though. Definitely a step in the right direction! 

-Marc
-
moomarc - Pixel Commander
- Posts: 2091
- Joined: 04 Jun 2010, 15:22
- Location: Johannesburg, South Africa
- Has thanked: 371 times
- Been thanked: 372 times
Re: About decoupling GUI from game
by silly freak » 03 Oct 2012, 08:35
Good idea, might just mention "Actor" as a better name than "Communication", though I'm weak on the naming department as well.
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: About decoupling GUI from game
by Max mtg » 03 Oct 2012, 10:50
First step: remove getHumanPlayer() calls from GUI code - use FControl.getPlayer() instead.
I'll commit the prerequisites at the first opportunity - that is in 8 hours (if the site does now fall down again)
This should bring us a step closer towards controlling any player from UI, not just the only human.
It should bring the project closer to hotseat games (though it would be completelly senseless if an opponent would see your hand)
I'll commit the prerequisites at the first opportunity - that is in 8 hours (if the site does now fall down again)
This should bring us a step closer towards controlling any player from UI, not just the only human.
It should bring the project closer to hotseat games (though it would be completelly senseless if an opponent would see your hand)
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: About decoupling GUI from game
by moomarc » 03 Oct 2012, 11:28
I don't really know the potential problems involved, but is it not worth waiting an extra day or two until after we release the RtR beta before we start changing every human player call?Max mtg wrote:First step: remove getHumanPlayer() calls from GUI code - use FControl.getPlayer() instead.
I'll commit the prerequisites at the first opportunity - that is in 8 hours
-Marc
-
moomarc - Pixel Commander
- Posts: 2091
- Joined: 04 Jun 2010, 15:22
- Location: Johannesburg, South Africa
- Has thanked: 371 times
- Been thanked: 372 times
Re: About decoupling GUI from game
by friarsol » 03 Oct 2012, 12:09
It seems like this may be something that's worth creating a branch for?
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: About decoupling GUI from game
by Max mtg » 03 Oct 2012, 13:18
I'll commit prerequisites to trunk, they are not likely to break a lot.friarsol wrote:It seems like this may be something that's worth creating a branch for?
As for the changes - yes, they are going to be massive.
A branch would be great (but I have little knowledge on merging and reintegrating them)... although I used to implement even larger changes without branches.

Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: About decoupling GUI from game
by friarsol » 03 Oct 2012, 14:03
Think of it as decoupling massive compile/runtime errors from the trunkMax mtg wrote:A branch would be great (but I have little knowledge on merging and reintegrating them)... although I used to implement even larger changes without branches.

- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: About decoupling GUI from game
by Max mtg » 03 Oct 2012, 19:33
Compile errors do not get commited from my side.friarsol wrote:Think of it as decoupling massive compile/runtime errors from the trunkMax mtg wrote:A branch would be great (but I have little knowledge on merging and reintegrating them)... although I used to implement even larger changes without branches.
Runtime - yes, these are possible. On the other hand no headache for integration and merges into branches.
Generally, I do not want a branch because many other changes were made without them: the new UI by Doublestrike, my changing of predicates, new quest saves along with moving pets to data files, and cardprinted introduction a year ago. There was nothing that broke build for a significant time
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: About decoupling GUI from game
by silly freak » 03 Oct 2012, 21:02
I'd say a branch is worth it when you can expect the whole feature to take longer to implement with unstable states in between. The GUI changes would be something I'd say would qualify. Changing to predicates was practically just refactoring, and extracting a Communication/Actor interface is as well.
Any real logic changes can be made after the refactoring, and since it's basically adding an additional implementation of that interface, there should be little error potential while the feature is unfinished. On the other hand, that means that the potential for conflicts is small.
Any real logic changes can be made after the refactoring, and since it's basically adding an additional implementation of that interface, there should be little error potential while the feature is unfinished. On the other hand, that means that the potential for conflicts is small.
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: About decoupling GUI from game
by Doublestrike » 05 Oct 2012, 00:07
This is exciting! To add fuel to the fire, multiple playing fields in the match UI should be ready to go with minimal work.
@Max not sure what the big picture is but for multiplayer it may be best to not hard-code "human" or "computer" and perhaps have a list of Players with their types? Or, a list of Humans, a list of AI...just off the top of my head.
Cool!
@Max not sure what the big picture is but for multiplayer it may be best to not hard-code "human" or "computer" and perhaps have a list of Players with their types? Or, a list of Humans, a list of AI...just off the top of my head.
Cool!
---
A joke is a very serious thing.
A joke is a very serious thing.
-
Doublestrike - UI Programmer
- Posts: 715
- Joined: 08 Aug 2011, 09:07
- Location: Bali
- Has thanked: 183 times
- Been thanked: 161 times
12 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 25 guests