dominicprice / endplay

A suite of tools for generation and analysis of bridge deals. Read the documentation at https://endplay.readthedocs.io
MIT License
21 stars 5 forks source link

Calculation of IMP and VP #31

Open ThorvaldAagaard opened 11 months ago

ThorvaldAagaard commented 11 months ago

As far as I can see there is no implementation of functions to calculate IMPS and VP.

Looking at your types it might be a good idea to add types for Match and Team (and probably also tournament)

I have this script for calculating IMPS (Lorand Dali implementation), but not yet found a python-implementation for VP

import math
import bisect

IMP = [10, 40, 80, 120, 160, 210, 260, 310, 360, 420, 490, 590, 740, 890, 1090, 1290, 1490, 
            1740, 1990, 2240, 2490, 3490, 3990]

def get_imps(score1, score2):
    score_diff = score1 - score2
    imp = bisect.bisect_left(IMP, int(math.fabs(score_diff)))
    if score_diff >= 0:
        return imp
    else:
        return -imp

VP is well-defined here: http://www.worldbridge.org/resources/official-documents/wbf-victory-point-scales/