forum.webdiplomacy.net

webDip dev coordination forum / public access todo list
It is currently Fri Nov 24, 2017 8:00 pm

All times are UTC




Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Power Choice
PostPosted: Thu Aug 07, 2008 9:03 pm 
Offline

Joined: Thu Aug 07, 2008 9:00 pm
Posts: 14
Have you ever thought about making it so players joining a game can choose the power they control (or indicate a preference)? I know on the official site you probably want to keep the system assignment, but for private installs and friendly games, it would be nice to have the option.


Top
 Profile  
 
 Post subject: Re: Power Choice
PostPosted: Thu Aug 07, 2008 11:42 pm 
Offline
Site Admin

Joined: Sat Jun 28, 2008 6:24 am
Posts: 892
That goes against the rules of the game, so it's not a top priority

But yep it has been suggested repeatedly, and would be a worthwhile thing to have I think


Top
 Profile  
 
 Post subject: Re: Power Choice
PostPosted: Fri Aug 08, 2008 4:11 pm 
Offline

Joined: Thu Aug 07, 2008 9:00 pm
Posts: 14
Would you accept a patch that implemented this feature?


Top
 Profile  
 
 Post subject: Re: Power Choice
PostPosted: Fri Aug 08, 2008 8:45 pm 
Offline
Site Admin

Joined: Sat Jun 28, 2008 6:24 am
Posts: 892
I would indeed, but (although I definitely don't want to put you off) this would be quite a chunky first phpDip project. Here are some criteria for it which you should consider:

  • It should be optional for each game, you select whether it's on/off in the game listings, and it's off by default
  • Players enter in a 1 to 7 ranking of their favorite countries on their user settings page, and if they haven't entered in their game ranking they don't see the "Power Choice" games (so no-one gets confused; since it's not a feature for newcomers)
  • The algorithm to determine who gets which spot should be fair (if two people have the same country as first choice it should have a fair algorithm to decide who gets it)
  • And this algorithm shouldn't be inefficient or overly complicated (I can't think of anything good off-hand at this hour :( )
  • It needs to remember that if there are 5 or 6 players Germany and Italy have to be taken by civil disorder players, even if Germany and Italy are one of the player's first choices
  • The way it'll affect cheaters (meta-gamers and multi-accounters) needs to be well thought out; will it make this sort of thing worse and how can that effect be limited


Also lots of people don't seem to want to select specific favorite powers, they just complain about getting the same power too often. Perhaps all that's needed is a system to try and balance things out, so players are less likely to get the same power over and over


I'm not trying to put you off, I'd definitely welcome this feature and so would a lot of players, but I think anyone who wants to work on it should have thought about the stuff above


Top
 Profile  
 
 Post subject: Re: Power Choice
PostPosted: Fri Aug 08, 2008 8:56 pm 
Offline

Joined: Thu Aug 07, 2008 9:00 pm
Posts: 14
Thanks kestas. I appreciate the fair warning and good actionable outline. I had done some preliminary work on it, but will now tailor towards what you've described. Some responses:

I hadn't thought of making the preference on a per-user level, but rather on a per-member level (so I may say I prefer to play England in this game, but Turkey in another one, for example). Just wondering what your thoughts were on that.

My first implementation only allowed people to indicate their top three choices -- easy enough to expand to seven. I was going for simplicity, but I can understand wanting to be thorough.

I have some thoughts on the algorithm to resolve disputes -- once I have the whole thing working, we can talk more about how that happens. My initial instinct is "whomever joined earlier gets their choice." Problems there, too, but I don't think there is 100% fair metric there.

I had thought about the cheating aspect a bit as well -- since this sort of thing is disallowed in tournament play, perhaps it makes sense for Power Choice games to not apply to rankings? It would essentially relegate them to friendly or casual games. You know a good bit more about the culture of PD, though, so I'll defer to any thoughts you may have there.


Top
 Profile  
 
 Post subject: Re: Power Choice
PostPosted: Sat Aug 09, 2008 3:31 am 
Offline
Site Admin

Joined: Sat Jun 28, 2008 6:24 am
Posts: 892
napthali wrote:
I hadn't thought of making the preference on a per-user level, but rather on a per-member level (so I may say I prefer to play England in this game, but Turkey in another one, for example). Just wondering what your thoughts were on that.

That was my first thought too, but there are two problems as far as I can tell:
- First off it means you need a way to select your preferences that's built into the "Join game" area of a game summary. That's not a lot of room, so it'd have to be fairly tight, which means it's likely to be more confusing (it's hard to forget how easy it is to confuse newcomers)
- Secondly, I don't think there's a good reason to want to choose to be a certain country in a certain game, unless you specifically want to try and be in a good position to ally with someone. I can't think of any other reason, and that reason is definitely against the spirit of the game I think. Doing it by user doesn't prevent people from changing it before joining a game with an ally, but it does make it clear the order shouldn't be changed for individual games.

I'm not sure, if you can think of a valid reason I'd be interested.

Quote:
My first implementation only allowed people to indicate their top three choices -- easy enough to expand to seven. I was going for simplicity, but I can understand wanting to be thorough.

Yup, three would be fine, but intuitively I imagine the algorithm would be simpler if there was a fixed order. If that's not the case then three would be fine though.

Quote:
I have some thoughts on the algorithm to resolve disputes -- once I have the whole thing working, we can talk more about how that happens. My initial instinct is "whomever joined earlier gets their choice." Problems there, too, but I don't think there is 100% fair metric there.

Hmm, I hadn't thought of that. It would definitely be simple and fast, but it'd mean people who start games would always get their choice, and people who join games started by others wouldn't, which would favor people who start all their games and don't join others' games.

I was thinking of something like: Start at a certain member and give him his first choice, then go to the next member and give him his first choice.
If there's a conflict where someone else has already taken the desired power one of the two members will then have to look for their second choice instead

Then whichever of the two members has had to take their second choice the most often is the one which gets their first choice, and whoever is left without has to look for a less favorite power

From a couple of quick n' dirty tests the idea seems to work okay, so at least this is available as a backup

Quote:
I had thought about the cheating aspect a bit as well -- since this sort of thing is disallowed in tournament play, perhaps it makes sense for Power Choice games to not apply to rankings? It would essentially relegate them to friendly or casual games. You know a good bit more about the culture of PD, though, so I'll defer to any thoughts you may have there.

Hmm, I think that would be an unpopular decision, and it'd require a new distinction for ranked/unranked games (currently all games in phpDip use points, so how friendly/serious a game is depends on the number of points). Since points are important to most players it'd limit the number of people who would play this game type, which would make the new feature less useful :(

I'm not really sure myself what I'd expect to happen regarding cheating, but I don't think it'd affect the basic design anyway so it could be dealt with later if necessary


Top
 Profile  
 
 Post subject: Re: Power Choice
PostPosted: Sat Aug 09, 2008 7:39 pm 
Offline

Joined: Thu Aug 07, 2008 9:00 pm
Posts: 14
kestasjk wrote:
That was my first thought too, but there are two problems as far as I can tell:
- First off it means you need a way to select your preferences that's built into the "Join game" area of a game summary. That's not a lot of room, so it'd have to be fairly tight, which means it's likely to be more confusing (it's hard to forget how easy it is to confuse newcomers)
- Secondly, I don't think there's a good reason to want to choose to be a certain country in a certain game, unless you specifically want to try and be in a good position to ally with someone. I can't think of any other reason, and that reason is definitely against the spirit of the game I think. Doing it by user doesn't prevent people from changing it before joining a game with an ally, but it does make it clear the order shouldn't be changed for individual games.


Good call on both of these. I'll put it on the user, but it may warrant a future FAQ entry. :-)

I'll defer any "cheating" concerns until the feature is up and working. At that point we can see how it might play out.

Speaking of which, I nearly have a working version ready. How do you prefer to handle it? Should I mail you a unified diff, zip up my working directory? Let me know what will be easiest for you.


Top
 Profile  
 
 Post subject: Re: Power Choice
PostPosted: Mon Aug 11, 2008 5:29 am 
Offline

Joined: Tue Jul 01, 2008 2:42 pm
Posts: 11
Location: chicago
kestasjk wrote:
I was thinking of something like: Start at a certain member and give him his first choice, then go to the next member and give him his first choice.
If there's a conflict where someone else has already taken the desired power one of the two members will then have to look for their second choice instead

Then whichever of the two members has had to take their second choice the most often is the one which gets their first choice, and whoever is left without has to look for a less favorite power


Another way you could do this is to do something like this:

1. Look at top choice for all players, if there are any nations picked that do not conflict, assign them.
2. For all conflicts, randomly choose one of the players to get the country in question.
3. For all remaining players, look at their second choice.
4. Repeat until all countries have been assigned.

The algorithm can be optimized some (there's really no need for a seventh round as there'll never be more than one person in it, etc). And obviously you'd need to add the caveat that when playing with 5 or 6 players that any preference for Italy and Germany (depending on the number of players, of course) would have to be ignored. Without dealing with those cases for the sake of simplicity, here's some psuedocode:

Code:
p[x][y] = players' choice lists, x = player index, y = preference index
round = current assignment round
countries[x][y] = countries desired this round, x = country index, y = players desiring country x this round index
assignments[x] = country assignments, x = country

round := 0

while round < 7 and all countries have not yet been assigned
    for i := 0 to 6
        push countries[p[i][round]], i (that is, append some reference to player i to the countries[countryname] array)

    for each country in game
        switch size of countries[country]
            case 0:
                next
            case 1:
                assignments[country] = countries[country][0]
            default:
                r = random number between 0 and size of countries[country]
                assignments[country] = countries[country][r]

    round := round + 1


It's a fairly O(n) algorithm and ought to be fair without adding any additional database requirements (beyond the preference list).


Top
 Profile  
 
 Post subject: Re: Power Choice
PostPosted: Mon Aug 11, 2008 5:38 am 
Offline

Joined: Thu Aug 07, 2008 9:00 pm
Posts: 14
In my current working version, it does a very simple algorithm that I think has much the same effect as you describe.

The pseudocode version is:

Code:
Players.shuffle

foreach(Players as Player) //outer loop
{
  foreach(Player.power_choices as choice) //inner loop
  {
    if (choice.is_available_in_this_game) //i.e., not a required civil disorder and not already taken by another player
    {
      Player.power = choice
      break //inner loop
    }
  }
}


It's nested loops, but the most times it could ever iterate would be 1+2+3+4+5+6+7=28, and that's assuming a perfectly degenerate case.

It guarantees that at least one person will get their first choice, and after that it's the luck of the initial shuffle and how popular your top countries are.

I like kestas's idea of looking at ties and deferring to the player who has gotten to play that country less, but was worried about the additional database queries and analysis that would entail. Certainly the resolution algorithm can be updated as necessary -- you could even imagine providing a few different options for the admin to choose from if necessary.


Top
 Profile  
 
 Post subject: Re: Power Choice
PostPosted: Mon Aug 11, 2008 11:50 pm 
Offline
Site Admin

Joined: Sat Jun 28, 2008 6:24 am
Posts: 892
napthali wrote:
Good call on both of these. I'll put it on the user, but it may warrant a future FAQ entry. :-)

Yup definitely

napthali wrote:
Speaking of which, I nearly have a working version ready. How do you prefer to handle it? Should I mail you a unified diff, zip up my working directory? Let me know what will be easiest for you.

Hmm, it'd be ideal for me if you could show me via your dev site, so that I don't need to reapply the patches if a change needs to be made or worry about security issues

If it were the hols I'd be more flexible, but I'm in week 3 of 17 of the current semester, and it's a tricky one, so you're going to see my lazy and picky side unless you wait until mid-Nov when I'll be able to engage more :( The only phpDip thing I'm likely to work on during the semester is the mod-CP, and then only if it saves me time


I think both the random algorithms are O(n^2), like my one (actually that's O(n^2 + g) where g is the number of games being played by all members). But both of yours are much simpler and neater, and mine requires new classes to work clearly, so yup doing it randomly is going to work fine I think.

I'm not 100% sure that your two algorithms have equivalent results. Intuitively it seems like deciding 1st, then 2nd, then 3rd place, instead of giving player 1 choice, then 2, then 3 (even when ordered randomly) seems more fair, but I'm probably wrong because I can't think of a reason. But we'll see anyway, good work!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group