private void Start()
    {
        Test01 T1 = new Test01(1);
        Test01 T2 = new Test01(2);
        Test01 T3 = new Test01(3);
        Test01 T4 = new Test01(4);

        test01s.AddLast(T1);
        AddCreate(T2);
        AddCreate(T3);
        AddCreate(T4);

        Debug.Log("第一个" + test01s.First.Value.num);
        Debug.Log("最后一个" + test01s.Last.Value.num);
        Debug.Log("第一个的下一个" + test01s.First.Next.Value.num);


        foreach (var item in test01s)
        {
            Debug.Log("目前内部的顺序" + item.num);
        }
        for (LinkedListNode <Test01> current = test01s.Last; current != null; current = current.Previous)
        {
            Debug.Log("销毁顺序" + current.Value.num);
            //Debug.Log("销毁的顺序"+current.Value.num);
        }
    }
Ejemplo n.º 2
0
        public void Dispatch(Session session, byte[] buffer)
        {
            ushort opcode = BitConverter.ToUInt16(buffer, Packet.OpcodeIndex);

//			object message = this.Network.MessagePacker.DeserializeFrom(null, memoryStream);
            Test01.Receive();
            Debug.Log("receive msg:" + opcode);
        }
Ejemplo n.º 3
0
        public void Test01_AssemblyAttribute()
        {
            Test01 test     = new Test01();
            var    c1AsmRef = test.c2.Compilation.GetReferencedAssemblySymbol(test.c1);

            Assert.IsType <RetargetingAssemblySymbol>(c1AsmRef);
            test.TestAttributeRetargeting(c1AsmRef);
        }
Ejemplo n.º 4
0
        public void Test01_NamedTypeAttribute()
        {
            Test01 test      = new Test01();
            var    testClass = test.c2.Compilation.GlobalNamespace.GetTypeMembers("TestClass").Single();

            Assert.IsType <RetargetingNamedTypeSymbol>(testClass);
            test.TestAttributeRetargeting(testClass);
        }
Ejemplo n.º 5
0
        public void Test01_ModuleAttribute()
        {
            Test01 test        = new Test01();
            var    c1AsmRef    = test.c2.Compilation.GetReferencedAssemblySymbol(test.c1);
            var    c1ModuleSym = c1AsmRef.Modules[0];

            Assert.IsType <RetargetingModuleSymbol>(c1ModuleSym);
            test.TestAttributeRetargeting(c1ModuleSym);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 反序列化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeserializeObject_Click(object sender, EventArgs e)
        {
            // 序列化設定
            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.MissingMemberHandling = MissingMemberHandling.Error;

            Test01 test01 = JsonConvert.DeserializeObject <Test01>(txtJson.Text, settings);
        }
Ejemplo n.º 7
0
        public void Test01_FieldAttribute()
        {
            Test01      test      = new Test01();
            var         testClass = test.c2.Compilation.GlobalNamespace.GetTypeMembers("TestClass").Single();
            FieldSymbol testField = testClass.GetMembers("testField").OfType <FieldSymbol>().Single();

            Assert.IsType <RetargetingFieldSymbol>(testField);
            test.TestAttributeRetargeting(testField);
        }
Ejemplo n.º 8
0
        public void Test01_ReturnTypeAttribute()
        {
            Test01       test       = new Test01();
            var          testClass  = test.c2.Compilation.GlobalNamespace.GetTypeMembers("TestClass").Single();
            MethodSymbol testMethod = testClass.GetMembers("TestMethod").OfType <MethodSymbol>().Single();

            Assert.IsType <RetargetingMethodSymbol>(testMethod);
            test.TestAttributeRetargeting_ReturnTypeAttributes(testMethod);
        }
Ejemplo n.º 9
0
        public static void Main(string[] args)
        {
            //CreateHostBuilder(args).Build().Run();

            //以下用于测试其中配置builder的顺序:
            Test01.CreateHostBuilder(args).Build().Run();
            //Test02.CreateHostBuilder(args).Build().Run();

            //Startup类不是必须的,可以直接用委托代替
            //Test03.CreateHostBuilder(args).Build().Run();
        }
Ejemplo n.º 10
0
    //初始化游戏信息设置
    void Start()
    {
        _instance = this;
        Vector3 angles = transform.eulerAngles;

        x = angles.y;
        y = angles.x;
        if (GetComponent <Rigidbody>())
        {
            GetComponent <Rigidbody>().freezeRotation = true;
        }
    }
Ejemplo n.º 11
0
        public void Test01_TypeParameterAttribute()
        {
            Test01       test       = new Test01();
            var          testClass  = test.c2.Compilation.GlobalNamespace.GetTypeMembers("TestClass").Single();
            MethodSymbol testMethod = testClass.GetMembers("TestMethod").OfType <MethodSymbol>().Single();

            Assert.IsType <RetargetingMethodSymbol>(testMethod);
            TypeParameterSymbol testTypeParameter = testMethod.TypeParameters[0];

            Assert.IsType <RetargetingTypeParameterSymbol>(testTypeParameter);
            test.TestAttributeRetargeting(testTypeParameter);
        }
Ejemplo n.º 12
0
        public void TestCsvWriterValues()
        {
            Test01             target = new Test01();
            CsvWriter <Test01> writer = new CsvWriter <Test01>();

            writer.RegField(o => o.A, "A");
            writer.RegFieldArray(o => o.B, target.B.Length, "B_#");
            writer.RegFieldClass(RegistClassTest02, o => o.D, "D");
            writer.RegFieldClassArray(RegistClassTest02, o => o.E, target.E.Length, "E_#");

            string body = writer.GetOneRowString(target);

            string ideal = "9,10,11,12,";

            ideal += "50,51,52,53,s000,";
            ideal += "100,101,102,103,s100,";
            ideal += "200,201,202,203,s200";

            body.Is(ideal);
        }
Ejemplo n.º 13
0
        public void TestCsvWriterTagNested()
        {
            Test01             target = new Test01();
            CsvWriter <Test01> writer = new CsvWriter <Test01>();

            writer.RegField(o => o.A, "A");
            writer.RegFieldArray(o => o.B, target.B.Length, "B_#");
            writer.RegFieldClass(RegistClassTest02, o => o.D, "D");
            writer.RegFieldClassArray(RegistClassTest02, o => o.E, target.E.Length, "E_#");

            string tag02 = writer.GetHeaderString();

            string ideal = "A,B_0,B_1,B_2,";

            ideal += "D.G,D.H_0,D.H_1,D.H_2,D.I,";
            ideal += "E_0.G,E_0.H_0,E_0.H_1,E_0.H_2,E_0.I,";
            ideal += "E_1.G,E_1.H_0,E_1.H_1,E_1.H_2,E_1.I";

            tag02.Is(ideal);
        }
    private void AddCreate(Test01 man)
    {
        LinkedListNode <Test01> current = test01s.First;

        Debug.Log("添加管理器顺序" + man.num);
        while (current != null)
        {
            if (man.num > current.Value.num)
            {
                break;
            }
            current = current.Next;
        }
        if (current != current.Next)
        {
            test01s.AddBefore(current, man);
        }
        else
        {
            test01s.AddLast(man);
        }
    }
Ejemplo n.º 15
0
 static void Main(string[] args)
 {
     Test01.DoTest();
     Test02.DoTest();
 }
Ejemplo n.º 16
0
 public void Test01_ReturnTypeAttribute()
 {
     Test01 test = new Test01();
     var testClass = test.c2.Compilation.GlobalNamespace.GetTypeMembers("TestClass").Single();
     MethodSymbol testMethod = testClass.GetMembers("TestMethod").OfType<MethodSymbol>().Single();
     Assert.IsType<RetargetingMethodSymbol>(testMethod);
     test.TestAttributeRetargeting_ReturnTypeAttributes(testMethod);
 }
Ejemplo n.º 17
0
 public void Test01_TypeParameterAttribute()
 {
     Test01 test = new Test01();
     var testClass = test.c2.Compilation.GlobalNamespace.GetTypeMembers("TestClass").Single();
     MethodSymbol testMethod = testClass.GetMembers("TestMethod").OfType<MethodSymbol>().Single();
     Assert.IsType<RetargetingMethodSymbol>(testMethod);
     TypeParameterSymbol testTypeParameter = testMethod.TypeParameters[0];
     Assert.IsType<RetargetingTypeParameterSymbol>(testTypeParameter);
     test.TestAttributeRetargeting(testTypeParameter);
 }
Ejemplo n.º 18
0
 public void Test01_FieldAttribute()
 {
     Test01 test = new Test01();
     var testClass = test.c2.Compilation.GlobalNamespace.GetTypeMembers("TestClass").Single();
     FieldSymbol testField = testClass.GetMembers("testField").OfType<FieldSymbol>().Single();
     Assert.IsType<RetargetingFieldSymbol>(testField);
     test.TestAttributeRetargeting(testField);
 }
Ejemplo n.º 19
0
 public void Test01_NamedTypeAttribute()
 {
     Test01 test = new Test01();
     var testClass = test.c2.Compilation.GlobalNamespace.GetTypeMembers("TestClass").Single();
     Assert.IsType<RetargetingNamedTypeSymbol>(testClass);
     test.TestAttributeRetargeting(testClass);
 }
Ejemplo n.º 20
0
 public void Test01_ModuleAttribute()
 {
     Test01 test = new Test01();
     var c1AsmRef = test.c2.Compilation.GetReferencedAssemblySymbol(test.c1);
     var c1ModuleSym = c1AsmRef.Modules[0];
     Assert.IsType<RetargetingModuleSymbol>(c1ModuleSym);
     test.TestAttributeRetargeting(c1ModuleSym);
 }
Ejemplo n.º 21
0
 public void Test01_AssemblyAttribute()
 {
     Test01 test = new Test01();
     var c1AsmRef = test.c2.Compilation.GetReferencedAssemblySymbol(test.c1);
     Assert.IsType<RetargetingAssemblySymbol>(c1AsmRef);
     test.TestAttributeRetargeting(c1AsmRef);
 }
Ejemplo n.º 22
0
        protected static void Main(string[] args)
        {
            Random rand = new Random();

            Console.WriteLine(rand.Next(100, 1000));          // .Next() 범위지정
            Console.WriteLine(rand.NextDouble());             // .NextDouble() 0~1까지의 임의의 소수점 난수
            Console.WriteLine((int)(rand.NextDouble() * 10)); // double은 int보다 컸기에 강제 형변환 가능
            Console.WriteLine();
            int[]    arr_int01    = new int[10];              // 배열
            long[]   arr_long01   = new long[10];
            string[] arr_string01 = new string[10];

            List <int> list_int01 = new List <int>(); // 리스트
            List <int> list_int02 = new List <int>()
            {
                1, 2, 3, 4
            };

            foreach (var item in list_int02)
            {
                Console.WriteLine("Count : " + list_int02.Count + "\tItem : " + item);
            }
            for (int i = 0; i < 10; i++)
            {
                list_int01.Add(rand.Next(1, 10));
            }
            Console.WriteLine();
            foreach (var item in list_int01)
            {
                Console.WriteLine("Count : " + list_int01.Count + "\tItem : " + item);
            }
            Console.WriteLine();
            list_int01.Remove(list_int01[0]);          // Remove는 해당 int를 가장 처음 발견한 것 지움
            list_int01.RemoveAt(list_int01.Count - 1); // RemoveAt은 해당 인덱스의 것 지움
            foreach (var item in list_int01)
            {
                Console.WriteLine("Count : " + list_int01.Count + "\tItem : " + item);
            }
            Console.WriteLine();
            Console.WriteLine(Math.Ceiling(53.4)); // 소수점 이하 올림
            Console.WriteLine(Math.Floor(53.4));   // 소수점 이하 삭제
            Console.WriteLine();

            Class2 man01 = new Class2("Jang", "pw", "Anyang");
            Class2 man02 = new Class2();
            Class2 man03 = new Class2()
            {
                addr = "Busan"
            };// public 인스턴스에 한에서 다형성 생성 가능

            man02.addr = "Seoul";
            man01.print();
            Class2.jobCode = "100";
            man01.print();
            man02.print();
            Console.WriteLine("\nClass3\n");
            Class3 class3 = new Class3();
            Test01 test01 = new Test01();// 내부클래스는 해당 내부클래스가

            // 생성된 클래스 내부에서만 사용이 가능하다.
            test01.Method();
            // Hidden hidden = new Hidden();
            // private 생성자이기에 생성자 접근이 불가능 하다.
            Sample sample = new Sample(); // static생성자는 접근이 가능하지만
                                          //  Console.WriteLine(sample.value); 정적으로 생성된 것은 접근이 불가능하다.

            Class4 class4 = new Class4();
        }
Ejemplo n.º 23
0
 public static void Test_Attribute_01()
 {
     Trace.WriteLine("Test_Attribute_01");
     Test01 t = new Test01();
     Type type = t.GetType();
     FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public);
     foreach (FieldInfo field in fields)
     {
         Attribute attrib = Attribute.GetCustomAttribute(field, typeof(ExportAttribute));
         if (attrib == null)
             Trace.WriteLine("field {0} dont have Export attribute", field.Name);
         else
             Trace.WriteLine("field {0} have Export attribute", field.Name);
     }
 }
Ejemplo n.º 24
0
        private string Test01()
        {
            Test01 m = new Test01();

            return(JsonConvert.SerializeObject(new Test01())); // 預設 Include
        }
Ejemplo n.º 25
0
    static void Main(string[] args)
    {
        Random random = new Random();

        // Console.WriteLine(Type.GetType("SelectionRouletteRank"));

        //Cities c = new Cities("fm9.tsp");
        //Organism o = new Organism(c, GenotypeRepresentation.ADJACENCYLIST);
        //o.SetRandomGenotype(random);
        //o.genotype = new uint[] { 1 ,2, 7, 6, 8, 0, 3, 4, 5 };
        //Organism o2 = new Organism(c, GenotypeRepresentation.ADJACENCYLIST);
        //o2.SetRandomGenotype(random);
        //o2.genotype = new uint[] { 6, 4, 0, 5, 8, 1, 7, 3, 2 };
        //Console.WriteLine(o.Genotype + o);
        //Console.WriteLine(o2.Genotype + o2);
        //Crossover cr = new CrossoverAdjacencyAlternatingEdges();
        //Organism o3 = cr.Cross(o, o2, random);
        //Console.WriteLine(o3.Genotype + o3);
        //Console.WriteLine(o.IsVaild);
        //Console.WriteLine(o2.IsVaild);
        //Console.WriteLine(o3.IsVaild);

        //Console.ReadKey();
        //Organism o4 = new Organism(c, GenotypeRepresentation.PATH);
        //o4.genotype = new uint[] { 0,1,2,3,4,5,6,7,8 };

        //Test01 ta = new Test01(random, new StopNumEpochs(200),
        //                                new SelectionTournament(),
        //                                new CrossoverPathOX(),
        //                                new MutationPathTwoOpt(0.5),
        //                                new Cities("uy734.tsp"),
        //                                40,
        //                                4,
        //                                "plik.txt"
        //                                );
        //Console.ReadKey();
        //return;
        ////////////////////// fm9  wi29  27603. dj38 6656    uy734   79114     lu980     11340     vm22775    569,288

        //Algorithm a = new Algorithm(random,
        //                                                        new StopNumEpochs(50000),
        //                                                        new SelectionTournament(),
        //                                                        new CrossoverPathPMX(),
        //                                                        new MutationPathTwoOpt(0.5),
        //                                                        "wi29.tsp",
        //                                                        100, true, false
        //                                                        );
        //a.Run("test.txt");

        //Algorithm a = new Algorithm(random,
        //                                                        new StopNumEpochs(50),
        //                                                        new SelectionRouletteRank(),
        //                                                        new CrossoverOrdinalSinglePoint(),
        //                                                        new MutationNone(0.2),
        //                                                        "dj38.tsp",
        //                                                        100, true, false
        //                                                        );
        //a.Run();


        //Organism o1 = new Organism();
        //o1.SetRandomGenotype(random, new Cities("wi29.tsp"));
        //Console.WriteLine(o1);

        //Organism o2 = new Organism();
        //o2.SetRandomGenotype(random, new Cities("wi29.tsp"));
        //Console.WriteLine(o2);

        //Organism o3 = o1.RecombinationWithMutation(o2, random);
        //Console.WriteLine(o3);

        //Organism o4 = o1.Mutation(random,0.5);
        //Console.WriteLine(o4);

        //new TestAlgorithm<OrganismWithRepair>(
        //                                        new Algorithm(random,
        //                                                        new StopNumEpochs(700),
        //                                                        new SelectionRouletteRank(),
        //                                                        20, 0.2, false
        //                                                        )
        //                                        );



        Algorithm a = new Algorithm(random,
                                    new StopTime(10, DateTime.Parse("2020-01-01 00:00")),
                                    new SelectionTournament(),
                                    new CrossoverPathCX(),
                                    new MutationPathSwap(0),
                                    new Cities("wi29.tsp"),
                                    50, true, false
                                    );

        a.Run();
        Console.ReadKey();
        return;

        // ArgStop Stop Select Cross MutationArg Mutation CitiesFile PopulationSize SaveFile
        /// czytanie z parametrów
        ///
        //      0           1           2           3           4           5               6               7               8
        ///     DATAstopu   StopArg     StopType    selectType  CrossArg    CrossType       MutationArg     MutationType    PopulationSize
        ///
        ///     9           10          11
        ///     NumberRuns  TspFile     outFile

        /// wczytanie danych z wytycznych z wykładu
        // data stopu
        DateTime date = Convert.ToDateTime(args[0]);



        StopCondition stopCondition = null;
        double        argument      = double.Parse(args[1]);

        switch (args[2])
        {
        case "StopNumEpochs":
            stopCondition = new StopNumEpochs(Convert.ToInt32(argument), date);
            break;

        case "StopPopulationDeviation":
            stopCondition = new StopPopulationDeviation(argument);
            break;

        case "StopTime":
            stopCondition = new StopTime(Convert.ToInt32(argument), date);
            break;

        default:
            break;
        }
        SelectionType selectionType = null;

        switch (args[3])
        {
        case "SelectionRoulette":
            selectionType = new SelectionRoulette();
            break;

        case "SelectionRouletteRank":
            selectionType = new SelectionRouletteRank();
            break;

        case "SelectionTournament":
            selectionType = new SelectionTournament();
            break;

        default:
            Console.WriteLine("brak selection type");
            break;
        }

        Crossover crossover = null;

        argument = double.Parse(args[4]);
        switch (args[5])
        {
        case "CrossoverAdjacencyAlternatingEdges":
            crossover = new CrossoverAdjacencyAlternatingEdges();
            break;

        case "CrossoverAdjacencySubtourChunks":
            crossover = new CrossoverAdjacencySubtourChunks();
            break;

        case "CrossoverOrdinalSinglePoint":
            crossover = new CrossoverOrdinalSinglePoint();
            break;

        case "CrossoverPathCX":
            crossover = new CrossoverPathCX();
            break;

        case "CrossoverPathOX":
            crossover = new CrossoverPathOX();
            break;

        case "CrossoverPathPMX":
            crossover = new CrossoverPathPMX();
            break;

        case "InverOver":
            crossover = new InverOver(argument);
            break;

        default:
            Console.WriteLine("brak crossover type");
            break;
        }

        Mutation mutation = null;

        argument = double.Parse(args[6]);
        switch (args[7])
        {
        case "MutationAdjacencyUsingPathTwoOpt":
            mutation = new MutationAdjacencyUsingPathTwoOpt(argument);
            break;

        case "MutationNone":
            mutation = new MutationNone(argument);
            break;

        case "MutationOridinalOnePoint":
            mutation = new MutationOridinalOnePoint(argument);
            break;

        case "MutationPathSwap":
            mutation = new MutationPathSwap(argument);
            break;

        case "MutationPathTwoOpt":
            mutation = new MutationPathTwoOpt(argument);
            break;

        default:
            Console.WriteLine("brak mutation type");
            mutation = new MutationNone(argument);
            break;
        }

        int populationSize = int.Parse(args[8]);
        int numberRuns     = int.Parse(args[9]);

        Cities cities = new Cities(args[10]);


        Test01 t = new Test01(random, stopCondition,
                              selectionType,
                              crossover,
                              mutation,
                              cities,
                              populationSize,
                              numberRuns,
                              args[11]);



        //Console.ReadKey();
    }