Skip to content

Instantly share code, notes, and snippets.

@nicoddemus
Last active April 5, 2021 20:42
Show Gist options
  • Save nicoddemus/17285399e422437e4340 to your computer and use it in GitHub Desktop.
Save nicoddemus/17285399e422437e4340 to your computer and use it in GitHub Desktop.
Soccer score generator
Seed: 173015
0 X 1
1 X 1
0 X 2
1 X 1
2 X 1
1 X 1
1 X 3
2 X 2
1 X 3
1 X 1
1 X 0
0 X 0
1 X 0
3 X 0
2 X 0
0 X 0
0 X 1
1 X 3
1 X 1
1 X 3
1 X 0
1 X 1
0 X 3
1 X 1
2 X 2
2 X 0
1 X 1
1 X 1
1 X 1
0 X 0
Seed: 979667
3 X 1
1 X 1
1 X 0
0 X 0
0 X 1
2 X 2
1 X 1
1 X 1
0 X 0
0 X 1
0 X 0
0 X 2
1 X 2
2 X 0
3 X 2
3 X 0
1 X 2
1 X 1
2 X 1
0 X 2
1 X 2
1 X 2
2 X 2
2 X 1
3 X 2
2 X 1
0 X 1
0 X 1
0 X 0
0 X 2
from __future__ import print_function
import bisect
import random
import time
# TODO: update using this later:
# "First, there is a group of results that occur with a frequency of around
# 10% each (1-0, 1-1, 2-1, 2-0, 0-0), totaling fewer than 50% of all matches.
# Second, there is a group of more mixed results, each of which occurs 5% of
# the time (1-2, 3-1, 3-0, 2-2), with both home and away teams scoring.
# And then there's everything else."
seed = int(time.time() % (1024 * 1024))
print('Seed: {}'.format(seed))
print()
scores = [
# percentage: score
(25, 0),
(70, 1),
(90, 2),
(100, 3),
]
def get():
p = random.randrange(100)
i = bisect.bisect_left(scores, (p, 0))
return scores[i][1]
for x in xrange(30):
print('{} X {}'.format(get(), get()))
@Fruthan
Copy link

Fruthan commented Mar 30, 2017

It must be using a random generator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment