Overview
| Comment: | Add functions to track average contribution, average and median scores |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
1de0c8566fa54f7c8f0060ec5d8adb1b |
| User & Date: | joel on 2018-11-22 16:02:27 |
| Other Links: | manifest | tags |
Context
|
2018-11-22
| ||
| 16:04 | Add score sheets for individual players to Excel output (closes [927402827e]) check-in: 940dde user: joel tags: trunk | |
| 16:02 | Add functions to track average contribution, average and median scores check-in: 1de0c8 user: joel tags: trunk | |
| 13:41 | Track player wins and losses check-in: eb8331 user: joel tags: trunk | |
Changes
Modified bunco.py from [481d05] to [dae914].
1 2 3 4 5 6 7 8 9 |
# Test
import csv, random, sqlite3
teammate_lookup = { 0: 2, 1: 3, 2: 0, 3: 1 }
fuzzydie_holder = 'x'
def TurnInProgress():
return -1
| > | 1 2 3 4 5 6 7 8 9 10 |
# Test
import csv, random, sqlite3
from statistics import median
teammate_lookup = { 0: 2, 1: 3, 2: 0, 3: 1 }
fuzzydie_holder = 'x'
def TurnInProgress():
return -1
|
| ︙ | ︙ | |||
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
self.round_scores.append(0)
self.round_roll_counts.append(0)
self.personal_roll_scores.append(0)
self.round_bunco_counts.append(0)
self.round_wins.append(0)
self.turn_progress = 0
self.current_streak = 0
def score_last_roll(self):
desired_num = Game.current_round() % 6
desired_num = 6 if desired_num == 0 else desired_num
roll_score = 0
| > > > > > > > > > | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
self.round_scores.append(0)
self.round_roll_counts.append(0)
self.personal_roll_scores.append(0)
self.round_bunco_counts.append(0)
self.round_wins.append(0)
self.turn_progress = 0
self.current_streak = 0
def average_contrib_pct(self):
pcts = []
for n in range(len(self.round_scores)):
if self.round_scores[n] > 0:
pcts.append(self.personal_roll_scores[n] / self.round_scores[n])
else:
pcts.append(0)
return sum(pcts) / len(pcts)
def score_last_roll(self):
desired_num = Game.current_round() % 6
desired_num = 6 if desired_num == 0 else desired_num
roll_score = 0
|
| ︙ | ︙ | |||
325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
cls.cur_round += 1
def print_status(self):
for n, table in enumerate(self.tables):
print(f"== TABLE {n+1} == Team 1:{table.team1_score} pts, Team 2:{table.team2_score} pts")
for player in table.players:
print(f" {player.name} {player.round_scores[Game.current_round() - 1]} points, streak {player.max_streak} buncos {sum(player.round_bunco_counts)}")
def prep_next_round(self):
# losers from head table move to next table
headtable_losers = self.tables[0].losers()
log_table_move(headtable_losers, "lost", self.tables[0], self.tables[1])
round_winners = self.tables[1].swap_for_winners(headtable_losers)
| > > > > > > > > > | 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
cls.cur_round += 1
def print_status(self):
for n, table in enumerate(self.tables):
print(f"== TABLE {n+1} == Team 1:{table.team1_score} pts, Team 2:{table.team2_score} pts")
for player in table.players:
print(f" {player.name} {player.round_scores[Game.current_round() - 1]} points, streak {player.max_streak} buncos {sum(player.round_bunco_counts)}")
def average_total_score(self):
all_scores = [sum(p.round_scores) for p in self.players]
return sum(all_scores) / len(all_scores)
def median_total_score(self):
all_scores = [sum(p.round_scores) for p in self.players]
return median(all_scores)
def prep_next_round(self):
# losers from head table move to next table
headtable_losers = self.tables[0].losers()
log_table_move(headtable_losers, "lost", self.tables[0], self.tables[1])
round_winners = self.tables[1].swap_for_winners(headtable_losers)
|
| ︙ | ︙ |