Example #1
0
        static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *__ret = ILIntepreter.Minus(__esp, 0);

            var result_of_this_method = new Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor>();

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Example #2
0
        static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.UInt32 @mapTag = (uint)ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            Google.Protobuf.FieldCodec <Google.Protobuf.ProtobufIMessageAdaptor.Adaptor> @valueCodec = (Google.Protobuf.FieldCodec <Google.Protobuf.ProtobufIMessageAdaptor.Adaptor>) typeof(Google.Protobuf.FieldCodec <Google.Protobuf.ProtobufIMessageAdaptor.Adaptor>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            Google.Protobuf.FieldCodec <System.Int32> @keyCodec = (Google.Protobuf.FieldCodec <System.Int32>) typeof(Google.Protobuf.FieldCodec <System.Int32>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);


            var result_of_this_method = new Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor> .Codec(@keyCodec, @valueCodec, @mapTag);

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Example #3
0
        /// <summary>
        /// ELO天梯评分算法
        /// </summary>
        private Dictionary <int, int> ComputeElorating(Google.Protobuf.Collections.MapField <ulong, Protos.BS2CS_BattleEndInfo> battleEndInfos)
        {
            var teamToInfos = new Dictionary <int, List <Protos.BS2CS_BattleEndInfo> >();

            //先按队伍分
            foreach (var kv in battleEndInfos)
            {
                Protos.BS2CS_BattleEndInfo battleEndInfo = kv.Value;
                teamToInfos.AddToList(battleEndInfo.Team, battleEndInfo);
            }
            //计算每个队伍胜负值,胜+1,和+0.5,负+0
            var teamToWin = new Dictionary <int, double>();

            foreach (var kv in teamToInfos)
            {
                List <Protos.BS2CS_BattleEndInfo> infos = kv.Value;
                var result = infos[0].Result;                //取其中一个成员就知道结果
                switch (result)
                {
                case Protos.BS2CS_BattleEndInfo.Types.Result.Win:
                    //如果胜利,按照规则只有一队胜利,其他都失败
                    teamToWin[kv.Key] = teamToInfos.Count - 1;                            //胜+1
                    break;

                case Protos.BS2CS_BattleEndInfo.Types.Result.Draw:
                    teamToWin[kv.Key] = (teamToInfos.Count - 1) * 0.5;                              //和+0.5
                    break;

                case Protos.BS2CS_BattleEndInfo.Types.Result.Lose:
                    teamToWin[kv.Key] = 0;                            //负+0
                    break;
                }
            }
            //把玩家分配到个队伍
            var teamToUser = new Dictionary <int, List <CSUser> >();

            foreach (var kv in battleEndInfos)
            {
                CSUser user = CS.instance.battleStaging.GetUser(kv.Key);
                teamToUser.AddToList(kv.Value.Team, user);
            }

            //计算每个队伍的平均分值
            var teamToAvgHonor = new Dictionary <int, int>();

            foreach (var kv in teamToInfos)
            {
                int           rank  = 0;
                List <CSUser> users = teamToUser[kv.Key];
                int           count = users.Count;
                for (int i = 0; i < count; i++)
                {
                    rank += users[i].rank;
                }
                rank /= count;
                teamToAvgHonor[kv.Key] = rank;
            }
            //计算每个队伍的得分
            var teamToHonor = new Dictionary <int, int>();

            foreach (var kv in teamToAvgHonor)
            {
                double we = 0;
                //基数
                double K = AdaptationK(kv.Value);
                //计算与其他队伍的逻辑斯谛分布和
                foreach (var kv2 in teamToAvgHonor)
                {
                    if (kv.Key == kv2.Key)
                    {
                        continue;
                    }
                    var delta = kv2.Value - kv.Value;
                    we += 1 / (Math.Pow(10, delta / 400.0) + 1);                        //ELO算法公式,see https://blog.csdn.net/kaifeng2988/article/details/50171201
                }
                //获取胜负值
                double w = teamToWin[kv.Key];
                //最终得分
                double rn = K * (w - we);
                teamToHonor[kv.Key] = ( int )rn;
            }
            return(teamToHonor);
        }
Example #4
0
        static StackObject *CalculateSize_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor> .Codec @codec = (Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor> .Codec) typeof(Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor> .Codec).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor> instance_of_this_method = (Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor>) typeof(Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.CalculateSize(@codec);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method;
            return(__ret + 1);
        }
Example #5
0
        static StackObject *WriteTo_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor> .Codec @codec = (Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor> .Codec) typeof(Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor> .Codec).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            Google.Protobuf.CodedOutputStream @output = (Google.Protobuf.CodedOutputStream) typeof(Google.Protobuf.CodedOutputStream).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor> instance_of_this_method = (Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor>) typeof(Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.WriteTo(@output, @codec);

            return(__ret);
        }
Example #6
0
        static StackObject *Clone_5(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor> instance_of_this_method = (Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor>) typeof(Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.Clone();

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Example #7
0
        static StackObject *Add_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Collections.Generic.IDictionary <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor> @entries = (System.Collections.Generic.IDictionary <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor>) typeof(System.Collections.Generic.IDictionary <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor> instance_of_this_method = (Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor>) typeof(Google.Protobuf.Collections.MapField <System.Int32, Google.Protobuf.ProtobufIMessageAdaptor.Adaptor>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Add(@entries);

            return(__ret);
        }