Post History
MoshiBot from numpy.polynomial import Polynomial def MoshiBot(data, history): if len(history) < 10: return [180, 180, 0] lastmin = min(history[-1]) lastmid = sorted(history[-1])[1] ...
Answer
#1: Initial revision
## MoshiBot ```python from numpy.polynomial import Polynomial def MoshiBot(data, history): if len(history) < 10: return [180, 180, 0] lastmin = min(history[-1]) lastmid = sorted(history[-1])[1] projectedmin = lastmin projectedmid = lastmid if len(history) >= 10: cutoff = len(history) - 10 snapshot = history[cutoff:] minvalues = list(map(min, snapshot)) midvalues = list(map(lambda vals: sorted(vals)[1], snapshot)) xpoints = range(cutoff, cutoff + len(snapshot)) minprojection = Polynomial.fit(xpoints, minvalues, deg=2) midprojection = Polynomial.fit(xpoints, midvalues, deg=2) projectedmin = minprojection(len(history)) projectedmid = midprojection(len(history)) safemin = max(0, min(360, math.ceil(projectedmin + 1))) if safemin >= 180: # The model broke down return [180, 180, 0] mid = math.floor(180 - safemin / 2) if mid > projectedmid: return [safemin, mid, 360 - safemin - mid] else: mid = max(safemin, min(360 - safemin, math.ceil(projectedmid + 1))) return [safemin, mid, 360 - safemin - mid] ``` Attempts to predict the opponents next move using a regressive model.