[CODE] Mulligan (FINAL)

All code submission.
almosthumane
Posts: 66
Joined: Wed Mar 31, 2010 3:52 am

[CODE] Mulligan (FINAL)

Post by almosthumane »

------------Mulligan Final---------------
Executable -> http://rapidshare.com/files/377717104/template.rar.html (Fixed shuffle)
Source (GameStateDuel.cpp)->On the Bottom of this post (fixed shuffle)
--------------------------------------------
Finally made it!
The C++ pointers where breaking me :shock:

On GameStateDuel.cpp I've changed the "in duel" menu option to present a Mulligan option.


Code: Select all

	      case DUEL_STATE_MULLIGAN://Almhum
      if(menu){
        menu->Update(dt);
		if (menu->closed)
		{
		  if (game->turn < 1 && game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN)
		  {
		      int cardsinhand = game->players[0]->game->hand->nb_cards;
			  for (int i = 0 ; i < cardsinhand; i ++) 
				game->currentPlayer->game->putInZone(game->currentPlayer->game->hand->cards[0],game->players[0]->game->hand ,game->players[0]->game->library);
			  
			  game->forceShuffleLibraries();
			  
			  for (int i = 0; i < (cardsinhand-1); i ++)	game->draw();
			  
			  mGamePhase = DUEL_STATE_PLAY;
		  }
		  else mGamePhase = DUEL_STATE_PLAY;
		}
      }
      break;//Almhum
At the moment can be exploited, but you can test as is.
http://www.mediafire.com/file/mdrzwzu5jjt/template.rar
(executable that also as autophaseskip)

Have a nice weekend.

[EDIT ABRA: renamed]
Attachments

[The extension rar has been deactivated and can no longer be displayed.]

Last edited by almosthumane on Mon Apr 19, 2010 5:09 pm, edited 4 times in total.
salmelo
Posts: 47
Joined: Thu Mar 11, 2010 4:11 pm

Re: Mulligan Code (1st version)

Post by salmelo »

well, i gave it a (very) quick look over, and it looks good.

One thing i'd like to suggest though, once the mulligan menu item stops doing anything, could it be removed from the list? I don't know if thats possible as I haven't looked at the code for menus at all.

Other than that though it looks great so far.
almosthumane
Posts: 66
Joined: Wed Mar 31, 2010 3:52 am

Re: Mulligan Code (1st version)

Post by almosthumane »

Thank you for the attention salmelo!

I've polished the code to my "final version" and it already adresses that issues. Now it's not a menu option. The game check if you haven't play any cards and if so, when you press "START" it automatically does the mulligan. If a card has been played the normal menu appears.

I believe it's better that way and as a bonus the code is written only in one place inside GameStateDuel.cpp, which makes this feature easier to patch if it's not integrated in any SVN release.

I've updated the 1st post with "Final version" files
wololo
Site Admin
Posts: 3727
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Mulligan Code (FINAL)

Post by wololo »

Thanks almosthumane :)

I've thought a lot about mulligan, and although I haven't looked at your code yet I must say I'm surprised you made it so quickly. There are lots of issues with mulligan and I'm not sure your code takes all of them into account.
On top of my mind, a few things that prevented me from working on mulligan so far:

- Mulligan should be simultaneous for both players. How does your code handle that for the AI ?
- What happens if one player does not mulligan, but the other does. Does the first player still have an option to mulligan after that ? (it shouldn't be the case)
- Have you thought of a (future) implementation for a 2 (human) players game ? (assuming we ever get network)

The rules of mulligan are extremely complex in terms of User Interaction and this has always blocked me. If your solution is a "quick and dirty hack" to offer mulligan for the player with lots of flaws, I need to discuss with the other devs to decide if we want to include that or not.
almosthumane
Posts: 66
Joined: Wed Mar 31, 2010 3:52 am

Re: Mulligan Code (FINAL)

Post by almosthumane »

Hi woholo,

I have no idea if this code (or other mulligan code) is going to be implemented any time soon. That's why I made a simple and easy to patch version of the mulligan (thanks you all, the code in wagic being explicit enough so that anyone without C++ programming skills can understand it).
That's why I dropped fancy ideas and what I meant with "FINAL" is just to say that, the code as is works great and that any user shouldn't expect more work from me on that (at least from some time) except for cases when the "test review" shows a need of code changes.
wololo wrote: - Mulligan should be simultaneous for both players. How does your code handle that for the AI ?
The code doesn't handle AI. Though mulligan penalizes AI decks are already so unfair against a "Starters deck" that I don't pity it! :D

It would be easy to put the code working on AI (but not placed in here).
But as I stated before I want a easy to patch solution.
The code I made for Auto Phase skip, touchs many files and it's "boring" to maintain in case of constant official changes on those files (which haven't happened so far).
wololo wrote: - Have you thought of a (future) implementation for a 2 (human) players game ? (assuming we ever get network)
- What happens if one player does not mulligan, but the other does. Does the first player still have an option to mulligan after that ? (it shouldn't be the case)
In case "2 Player mode" ever returns that needs a change. That's the fancy solution with a proper menu and a extra "mulligan phase" that can be implemented but though they're not disruptive to the code, require changes in many files. For a feature that might not be integrated, I believe, that's "too much effort" for too few improvement.

But if you like the code and intend to put in the main build, I can work those limitations, though I cann't test them on PSP and test performance impact.
abrasax
Posts: 976
Joined: Wed Oct 15, 2008 7:46 am
Location: Switzerland

Re: Mulligan Code (FINAL)

Post by abrasax »

The rules of mulligan are extremely complex in terms of User Interaction and this has always blocked me. If your solution is a "quick and dirty hack" to offer mulligan for the player with lots of flaws, I need to discuss with the other devs to decide if we want to include that or not.
Hi,

Just to say my opinion on the subject.... The mulligan has been a constant request from the beginning of wagic, even if it is a "quick and dirty hack", I think it will be sufficient for most users... the limitations, and complex ruling are from no use at the moment... The fact that the AI cannot handle mulligan is the least of the problem of the AI... some other improvment might be considered as more important for the AI as to handle or not handle mulligan... as for 2 player support, either we can remove the mulligan rules in case of 2 player, or we can think again about it when we are so far...

So all to say i think the advantage of implementing mulligan now, is bigger than the disadvantage we might have... I didn't have time at all to test any of the new features/code added recently to the SVN, I'm to busy with my work and forum support currently, so I cannot judge on the code and its implementation...atm... but will try to give it a try (maybe next week as I will be traveling and will have time in my hotel room)...

Grüssi

Abra
We need your Help !!!
New to wagic ? Be sure to check the following :

Bug report: Bug reporting
Help us: Add cards & Compiling.
Customize: Themes FAQ, All images thread, Abra's Mediafire folder
almosthumane
Posts: 66
Joined: Wed Mar 31, 2010 3:52 am

Re: Mulligan Code (FINAL)

Post by almosthumane »

Had to make a fix on this one. This wasn'r shuffling the right way. :oops:

Updated the links on the top.
Pausing
Posts: 36
Joined: Sun Apr 11, 2010 8:31 pm

Re: Mulligan Code (FINAL)

Post by Pausing »

where to put this on the psp?
wololo
Site Admin
Posts: 3727
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Mulligan Code (FINAL)

Post by wololo »

abrasax wrote: So all to say i think the advantage of implementing mulligan now, is bigger than the disadvantage we might have... I didn't have time at all to test any of the new features/code added recently to the SVN, I'm to busy with my work and forum support currently, so I cannot judge on the code and its implementation...atm... but will try to give it a try (maybe next week as I will be traveling and will have time in my hotel room)...

Grüssi

Abra
As usual a very good point, and I agree with you.

With the small amount of free time I have these days, I'm very happy that other coders such as almosthumane get involved. I suggest that whoever has the time to test almosthumane's code also adds it to the SVN if they think it works good enough. You, or me, or whoever else has the time.
almosthumane
Posts: 66
Joined: Wed Mar 31, 2010 3:52 am

Re: Mulligan Code (FINAL)

Post by almosthumane »

Pausing wrote:where to put this on the psp?
This is the Win32 test file. The eboot is bellow, but it has all the (unrelevant) changes I've made in my personal build. Please just consider the mulligan.

http://www.mediafire.com/file/gumntit2ndn/EBOOT.PBP

As for a "dirty" integration of mulligan in 2 Player it's enough to change the condiction from turn <1 to turn<2
Post Reply