I am trying to attempt to make a system where once a match starts people are separated into two teams. Sorta like how some Team Tournaments are created, but instead of randomly placing people it goes one by one placing each player into a team(EX: Player 1 Blue Team, Player 2 Red Team, Player 3 Blue Team,etc). I am known for having an abundance of unnecessary variables and did not want to over cloud my mind with them.
|
Dayvon64 wrote:
Sorta like how some Team Tournaments are created, but instead of randomly placing people it goes one by one placing each player into a team(EX: Player 1 Blue Team, Player 2 Red Team, Player 3 Blue Team,etc). That's still random, or to be more accurate it's arbitrary. A random distribution is good; I think what you mean is you don't want the teams to end up lopsided by simply flipping a coin to see who goes on which team. When you're distributing players to teams, generally what you want to do at each step is 1) pick a random player from the list of unassigned players, and 2) assign them to the team with the fewest people. There are other ways to go about this of course; if players have a certain level of power/skill that you can roughly quantify, you may want to try to keep the total balanced between the two teams. Lode Wars had teams of different colors with different abilities, where a team with powerful equipment might only get 1/2 as many people as a generic team. Weighting team counts like Lode Wars did is actually pretty easy. With teams you also need to consider what happens when someone logs in or out. You should keep track of a player's team once the game/round starts, so that if they log out and back in they're on the same team. New players should be assigned to the team that needs them most, or a random choice if more than one. Most likely, you don't want to have vars like team1 and team2. Rather, it's best to keep your teams in a list. Consider this: team Handling login and logout shouldn't be too difficult from there. To lookup the actual /team datum a player has, just check teams[player.team]; if it's null they don't have a team. To see if two players are on the same team, just compare their team vars. You can also setup items in the game world that are team-specific, by giving them a team var also. In SotS II, I went ahead and gave the team var to every atom, because some turfs need it, many objs do, and of course all player mobs (when in team mode, anyway). |
This simply compares the size of one team to the other and adds the player to the smaller of the two. When both teams have an equal amount, the first list is used by default.