Example #1
0
        public async Task Run(CommandArgs args)
        {
            var evt = MasterData.Instance.events.Last();

            RankData data;

            lock (Program.SekaiFile)
                data = RankData.FromFile($"sekai_event{evt.id}.csv");


            int.TryParse(args.Arg, out int rank);

            if (!data.ranks.ContainsKey(rank))
            {
                await args.Callback("排名数据不存在");

                return;
            }

            var x = data.timestamp.Select(l => (double)l).ToArray();
            var y = data.ranks[rank].Select(l => (double)l).ToArray();

            var fit  = LSE(x, y);
            var fit2 = PassZero(x.Select(l => l - evt.startAt).ToArray(), y);

            await args.Callback($"排名{rank}的预测分数为\n{(int)(fit.Item1 * evt.aggregateAt + fit.Item2)} (LSE)\n{(int)(fit2 * (evt.aggregateAt - evt.startAt))} (过原点)");
        }