diff --git a/server/activate.sh b/server/activate.sh index 81ffbe1..cda886f 100755 --- a/server/activate.sh +++ b/server/activate.sh @@ -12,6 +12,7 @@ source venv/bin/activate echo Installing required Python packages pip install -Ur requirements.txt + function run() { python -m nightr } diff --git a/server/nightr/app.py b/server/nightr/app.py index 18f58d5..f06fd6a 100644 --- a/server/nightr/app.py +++ b/server/nightr/app.py @@ -7,8 +7,8 @@ from typing import List import requests_cache from flask import Flask, jsonify -from strategies import dmi, steam, miloStrats -import Context +from server.nightr.strategies import dmi, steam, miloStrats +from server.nightr.util import Context app = Flask(__name__) @@ -19,8 +19,8 @@ strategies = { # name: (weight, probability function) "dmi": (0.5, dmi.probability), "steam": (1.0, steam.probability), - "australia" : (0.5, miloStrats.australiaStrat), - "camera" : (0.5, miloStrats.camImgStrat), + "australia": (1.0, miloStrats.australiaStrat), + "camera": (1.0, miloStrats.camImgStrat), } @@ -49,6 +49,12 @@ def probabilities(): median = statistics.median(p["weighted_probability"] for p in predictions) night = mean > 0.5 + # Invert if we're in Australia + if context.in_australia: + night = not night + for prediction in predictions: + prediction["night"] = not prediction["night"] + # Calculate contributions of predictions consensus_weight_sum = sum(p["weight"] for p in predictions if p["night"] == night) for prediction in predictions: diff --git a/server/nightr/steamplayerhistory.py b/server/nightr/steamplayerhistory.py index 1fad799..6f49a70 100644 --- a/server/nightr/steamplayerhistory.py +++ b/server/nightr/steamplayerhistory.py @@ -1,6 +1,8 @@ -import requests -from datetime import datetime import time +from datetime import datetime + +import requests + def main(): filename = "dotaplayers " + str(datetime.now()) + ".csv" @@ -16,5 +18,6 @@ def main(): f.close() time.sleep(100) + if __name__ == '__main__': main() \ No newline at end of file diff --git a/server/nightr/strategies/miloStrats.py b/server/nightr/strategies/miloStrats.py index 6aee18d..c5b0633 100644 --- a/server/nightr/strategies/miloStrats.py +++ b/server/nightr/strategies/miloStrats.py @@ -1,6 +1,8 @@ +from datetime import datetime + import cv2 -from datetime import datetime, timedelta from pytz import timezone + from server.nightr.util import Context, Prediction diff --git a/server/nightr/util.py b/server/nightr/util.py index ad4585d..d2f37d8 100644 --- a/server/nightr/util.py +++ b/server/nightr/util.py @@ -1,11 +1,15 @@ from dataclasses import dataclass, field -from typing import List, Tuple +from typing import List, Dict @dataclass class Context: - battery: float = 1.0 - coordinates: Tuple[float, float] = (0.0, 0.0) + battery: float + position: Dict[str, float] # {'latitude': '23.2583', 'longitude': '154.0417'} + + # App settings + in_australia: bool = False + flat_earth: bool = False @dataclass diff --git a/server/requirements.txt b/server/requirements.txt index ac757ed..776c8a0 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -1,4 +1,7 @@ Flask==1.0.2 requests==2.21.0 requests-cache==0.4.13 -pytz \ No newline at end of file +pytz +beautifulsoup4 +pandas +opencv-python