Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

# Agents can have priori knowledge of expected game length

See original GitHub issue

Emphasis on expected.

Since the game length is defined to be `int(200-40*np.log(random.random()))`, which has an expected value of 240, agents can make use of this in undesirable (?) ways. I.e. use a probabilistic approach to try to deceive the opponent at the end of the game with no consequences.

I think this is an unintended issue since

• The whole point of the random game length was to prevent this behavior
• It is not in the “spirit” of the iterated prisoner’s dilemma

### Issue Analytics

• State:
• Created 2 years ago
• Comments:16 (1 by maintainers)

#### Top GitHub Comments

6reactions
peterHoburgcommented, May 20, 2021

It also has a max value of `1765` due to random.random() returning a float with limited decimals.

`random.random()` also uses a deterministic number generator and a single instance of the seed class, so you can actually figure out the number of games based off the calls to the underlying class.

But that would fall under the cheating and get your code kicked out?

3reactions
colonelwatchcommented, May 24, 2021

There’s no such thing, really, as “expected game length” in this tournament. The distribution of possible game lengths is a log curve going from 200 to infinity. Finding the average value of that kind of curve is meaningless.

In fact, I ran a Monte-Carlo simulation for the odds of the game ending at a given turn. After turn 200, it goes from 0 to 2.5% and stays there. This is exactly as carykh says: a low but equal probability that the game will end.

The samples get too sparse after 500 rounds give or take, but the odds of reaching 500 is 0.056% anyway. If anyone is curious or wants to check me (please correct me if you see something), here’s the code:

``````import numpy as np
from matplotlib import pyplot as plt

# Sample all possibilities
lengths = np.random.rand(10000000)
lengths = 200-40*np.log(lengths)
lengths = lengths.astype(int) # convert to integers, since this is a round count
lengths_temp = lengths.copy() # working copy

# Progressively calculate odds of game ending on this turn then lop off possiblity curve
game_end_odds = []
for i in range(600):
if(len(lengths_temp) != 0):
game_end_odds.append(len(lengths_temp[lengths_temp == i])/len(lengths_temp))
lengths_temp = lengths_temp[lengths_temp > i]
else:
game_end_odds.append(0)

# Convert odds to percent chance
game_end_odds = np.array(game_end_odds)
game_end_odds *= 100

plt.plot(game_end_odds)
plt.xlabel('Rounds')
plt.ylabel('Chance of Game Ending (%)')
plt.title('Chance of Game Ending on Given Round')
plt.show()

print("Chance of reaching 500 rounds:", 100*len(lengths[lengths >= 500])/len(lengths), "%")
``````

#### Top Results From Across the Web

CS 165A Discussion 1 - UCSB Computer Science
The agent's prior knowledge of the environment. • The actions that the agent can perform. • The agent's percept sequence to date.
Aumann's agreement theorem - Wikipedia
The theorem concerns agents who share a common prior and update their probabilistic beliefs by Bayes' rule. It states that if the probabilistic...
Priori Knowledge - an overview | ScienceDirect Topics
One is that mathematics can claim to give a priori knowledge of (universally applicable to) objects of possible experience because it is the...
The Role of A-priori Information in Networks of Rational Agents ...
The a-priori knowledge of n is formalized as a Bayesian setting where at the beginning of the algorithm agents only know a prior...
The Role of A-priori Information in Networks of Rational Agents
However, what if agents have partial knowledge about n? We ... The problems we examine here can be solved in the game-theoretic setting...

#### Troubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free