Author Topic: Fair Pie  (Read 1855 times)

Offline Leviathan

  • Hero Member
  • *****
  • Posts: 4055
Fair Pie
« on: March 27, 2005, 10:02:37 AM »
Well as you know i want to make the fair equal pie map.

The current code you gave me didnt work Eddy for the stating locations..

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Fair Pie
« Reply #1 on: March 27, 2005, 11:34:59 AM »
What are you trying to do?

The current code in the help files that I wrote will randomly permute a list of starting locations. You specify all possibly starting locations, permute them, and then select the first few that you need. If you need more control, you can also use seperate lists and permute them seperately, then choose a few entries from each list.

Tell me exactly what you need and I can probably tell you how to do it.
 

Offline Leviathan

  • Hero Member
  • *****
  • Posts: 4055
Fair Pie
« Reply #2 on: March 27, 2005, 11:47:22 AM »
Well its gotta be how pie is for location setup.

There are six locations, two rows, top and bottom half of map:
1 | 2 | 3
4 | 5 | 6

How ever many players the game starts with i think player 1 should be randomly placed around the map and conditions set for otehr players around player 1.

In 2 player game:
If player 1 in location 1 then player 2 in location 6.
If player 1 in location 2 then player 2 in location 5.
If player 1 in location 3 then player 2 in location 4.
If player 1 in location 4 then player 2 in location 3.
If player 1 in location 5 then player 2 in location 2.
If player 1 in location 6 then player 2 in location 1.

In 3 player game:
If player 1 in location 1 then player 2 in location 3, player 3 in location 5.
Tho i think it should be random for the other 2 players, random of location 3 and 5.
So:
If player 1 in location 1 then player 2 and 3 use random of locations 3 and 5.
If player 1 in location 2 then player 2 and 3 use random of locations 4 and 6.
If player 1 in location 3 then player 2 and 3 use random of locations 1 and 5.
If player 1 in location 4 then player 2 and 3 use random of locations 2 and 6.
If player 1 in location 5 then player 2 and 3 use random of locations 3 and 5.
If player 1 in location 6 then player 2 and 3 use random of locations 2 and 4.

In 4 player game:
Two players on each side of the map, at first i though they used the cornet spots, but thats not the case. Random player 1 then 1 player next to player one, random of the two spots left. If the player is next to player 1 that should be mirrored but opsite on other side of map. So if there is location 2 or 5 in between player 1 and the other player it should be same on other side.
Eg.
Spot 1 and 2 vs spot 5 and 6.

In 5 player game:
Random all players...

In 6 player game:4
Player 1 gets randomised and all other locations are used to randomise other players location, or all 6 players get randomized because that would have same effect.
« Last Edit: March 27, 2005, 12:08:02 PM by Leviathan »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Fair Pie
« Reply #3 on: March 27, 2005, 11:57:05 AM »
Hmm, sounds easy enough for the two player case. Just don't randomize. Do you plan on similar setups for more players?


For the two player case, you could try something like this:
Code: [Select]
int InitProc()
{
int i;

// Randomize starting locations
//RandomizeStartingLocations(autosize(startLocation));

                i = TethysGame::GetRand(6); // Determine location for first base

// Place all bases on the map
InitPlayerResources(0);
StartLocation &sLoc = startLocation[i];
CreateBase(0, sLoc.x, sLoc.y, *sLoc.baseInfo);
Player[0].CenterViewOn(sLoc.x, sLoc.y);

InitPlayerResources(1);
StartLocation &sLoc = startLocation[5-i];
CreateBase(1, sLoc.x, sLoc.y, *sLoc.baseInfo);
Player[1].CenterViewOn(sLoc.x, sLoc.y);

...



Edit: Hmm, since you want more players...

Ok, so the locations aren't changing, but the way you're selecting is. I'd say maybe use a seperate list of integers to represent the starting locations. (Note: I'm using 0 based indexes here, so numbers 0-5 instead of 1-6 as in your diagram).

Code: [Select]
int twoPlayers[][2] = 
{
 { 0, 5 },
 { 1, 4 },
 { 2, 3 },
}

int threePlayers[][3] =
{
 { 0, 2, 4 },
 { 1, 3, 5 },
}

// 4, 5, and 6 maybe just complely randomize the 6 starting locations? Doesn't seem like there is a way to make it any more fairer

int sixPlayers[][6] =
{
 { 0, 1, 2, 3, 4, 5 }
}
Use the TethysGame.NoPlayers() to determine which array to use, and then use TethysGame.GetRand to determine which row of the array we want. Then you can permute the row and use the indexes into the starting location array when creating the bases.

I'm gonna go try out some test code and see if I can clean this up a bit.
 
« Last Edit: March 27, 2005, 12:21:01 PM by Hooman »

Offline Leviathan

  • Hero Member
  • *****
  • Posts: 4055
Fair Pie
« Reply #4 on: March 27, 2005, 12:09:53 PM »
I was thinking of doing it so in Basedata i just create the 6 bases, then randomly it uses the base infomation depending on where players should spawn.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Fair Pie
« Reply #5 on: March 27, 2005, 01:46:43 PM »
I'm trying to think of a clean and simple way of doing it. The following idea works and isn't too long.

Code: [Select]
	int numPlayers = 2;

int startingSelection[] = { 0, 2, 4, 1, 3, 5 }; // This order slightly simplifies the case of 3 Players
int i;

switch(numPlayers)
{
case 2:
  startingSelection[0] = rand() % 6; // startingSelection[0] = TethysGame::GetRand(6);
  startingSelection[1] = 5 - startingSelection[0];
  break;
case 3:
  int temp;

  temp = rand() % 2;      // temp = TethysGame::GetRand(2);
  RandomizeList(3, startingSelection);
  for (i = 0; i < 3; i++)
   startingSelection[i] |= temp;
  break;
default:
  RandomizeList(6, startingSelection);
}

for (i = 0; i < numPlayers; i++)
{
  // This is where you would create the bases
  cout << startingSelection[i] << endl;
}
Note that this is just test code to see if it pulls the right list of base indexes. It does work according to the rules that you want for 2 & 3 (& 6) players.
You can stick the startinSelection array in either the main file or the BaseData.h file, doesn't really matter much. In place of numPlayers, you should use TethysGame::NoPlayers(). The lines with "rand() % value" should be replace with the corresponding lines with "TethysGame::GetRand(value)". And of course, the cout line should be the actual base creation code. Just change the one line:
Code: [Select]
  StartLocation &sLoc = startLocation[i];
to
Code: [Select]
StartLocation &sLoc = startLocation[startingSelection[i]];

Let me know if you have trouble integrating the code. It'd probably be helpful if I had your project though so I can play around with code that actually has 6 starting locations instead of only 4.


 

Offline Leviathan

  • Hero Member
  • *****
  • Posts: 4055
Fair Pie
« Reply #6 on: March 30, 2005, 06:43:34 AM »
I havent tryed it yet but the 4 players cant be random, otherwise then 3 players could be on the top and one down the bottom. It has to be even and mirrored.