1
\$\begingroup\$

I'm making a minigame where up to 5 players have to race against AI or another player(the "enemy"). The race consists of prompts, the current player is asked to press a key in a given amount of time to make progress, if they fail they have to wait until it's their turn again to progress. The current player has to avoid being outran by the enemy they race against, else it's a game over for them.

My problem comes with the fairness of it, the turns are a plain cycle and feels boring, the enemy is dumb and always loses. The game is anticlimatic this way, so I'm looking for a way to choose the next player in a random way but at the same time being fair with the rest until a certain point(the difficulty defines how many consecutive rounds a player can take). I'd also like the game to give random 'boosts' to the players that are near the enemy(and also give the enemy a boost to make it challenging).

How can I achieve this? I'm using Python but I don't know if that matters.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ So when I understand your question correctly, you want to pick a random player each turn but at the same time control how many moves each player gets. Is that correct? \$\endgroup\$
    – Philipp
    Oct 28, 2019 at 8:56
  • \$\begingroup\$ Kind of. I don’t want a player to play more than X rounds. \$\endgroup\$
    – Daniel
    Nov 2, 2019 at 15:29

2 Answers 2

1
\$\begingroup\$

So you have a "one-button" gameplay and it's not engaging enough? Have you played NFSU? It had a drag race mode, which is basically pressing one button in perfect timing to outrace other competitors.

Why not try to replace turns with cooldowns. Whenever someone's cooldown reaches zero - they can have their turn and try to press the button in perfect time. The closer they are to the sweet spot, the less cooldown they'll get. You can adjust the difficulty by making a sweet spot wider or narrower making it less or more hard to hit.

\$\endgroup\$
0
\$\begingroup\$

If you are trying to keep the number of turns per player close to equal while making the order random, you could try a couple things:

1. Randomize the order of turns each round.

For each round of play, create a random ordering for the group of players you have. They all play through, and then for the next round you create another random ordering. So each player plays once each round, but you don't when in the round you'll play. You might get a player playing twice in a row, but only if they happen to be at the end of one round and the beginning of the next.

In Python, you could do that like this:

import random
random.seed()

player_list = ['Daniel Casares', 'pladams9', 'Mario', 'Computer 1', 'Computer 2']

while(!game_over):
  # Runs each ROUND
  random.shuffle(player_list)

  print(player_list)
  # Possible output: ['pladams9', 'Computer 1', 'Daniel Casares', 'Computer 2', 'Mario']

2. Randomize the choice of next player in an inversely proportional way.

For each turn, pick a random next player, but make their chance of going inversely proportional to the number of turns they've already had. By simply making a random choice, each player's expected number of turns would already be equal, but this method discourages runaway streaks where one person gets several turns in a row. Streaks are still possible though, so a single player could get multiple turns in a row.

One way in Python:

import random
random.seed()

player_list = ['Daniel Casares', 'pladams9', 'Mario', 'Computer 1', 'Computer 2']
player_turns = {player:1 for player in player_list} # Starting at 1 to avoid division by 0

while(!game_over):
  # Runs each TURN
  next_player = random.choices(
    population=list(player_turns.keys()), # All our players
    weights=[1/turns for turns in player_turns.values()], # 1 divided by the number of turns each player has had
    k=1)[0] # We only want one choice, so k=1; choices() returns a list, so we just take the first value
  player_turns[next_player] += 1 # Increment that player's turn count

  print(next_player)
  # Possible output: 'Computer 2'

For more information on random.shuffle and random.choices, you can check out: https://docs.python.org/3/library/random.html

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .