Exemplo n.º 1
0
        static void Main(string[] args)
        {
            GraphNode <char> root = new GraphNode <char>('a');
            var b = root.AddTwoWay('b', 2);
            var c = root.AddTwoWay('c', 1);
            var d = b.AddTwoWay('d', 4);

            c.AddTwoWay(d, 1);
            var e = b.AddTwoWay('e', 5);

            d.AddTwoWay(e, 3);

            var res = Floyd.Perform(root);
            List <GraphNode <char> > path = ReconstructPath(res, root, e);

            foreach (var p in path)
            {
                Console.WriteLine(p.Value);
            }

            foreach (var aa in res)
            {
                foreach (var bb in aa.Value)
                {
                    Console.Write(bb.Value?.Value + " ");
                }
                Console.WriteLine();
            }
        }
Exemplo n.º 2
0
        public void MainMethod()
        {
            const int SIZE        = 700;
            const int THREAD_SIZE = 3;
            Floyd     floyd       = new Floyd(SIZE).Generate();

            floyd.Run(THREAD_SIZE);
            System.Console.WriteLine(floyd[12, 9]);
        }
Exemplo n.º 3
0
        public void DoIt()
        {
            var helpList = new int[_graf.GetVertexCount()];

            foreach (var edge in _graf.GetEdgeList())
            {
                helpList[edge.StartVertex - 1]++;
                helpList[edge.FinishVertex - 1]++;
            }
            var counter = 0;

            foreach (var numOfVertex in helpList)
            {
                if (numOfVertex == 0)
                {
                    _result = "Нет Эйлерова цикла, граф несвязный";
                    return;
                }
                counter += numOfVertex % 2;
            }
            var floyd = new Floyd(_graf);
            var flag  = true;

            foreach (var edge in floyd.Matrix)
            {
                if (edge > 99999)
                {
                    flag = false;
                }
            }
            if (flag)
            {
                if (counter == 0)
                {
                    _result = "Есть Эйлеров цикл";
                    if (_mainDrawer.GetCheckedVetex() < 0)
                    {
                        return;
                    }
                    _mainDrawer.TimingDraw(GetEdgeList());
                    return;
                }
                else
                {
                    _result = "Нет Эйлерова цикла, есть вершины с нечетной степенью";
                    return;
                }
            }
            else
            {
                _result = "Нет Эйлерова цикла, граф несвязный";
                return;
            }
        }
Exemplo n.º 4
0
    private static void test05()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST05 tests CYCLE_FLOYD for F5.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    17 June 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int lam = 0;
        int mu  = 0;

        Console.WriteLine("");
        Console.WriteLine("TEST05");
        Console.WriteLine("  Test CYCLE_FLOYD for F5().");
        Console.WriteLine("  f5(i) = mod ( 16383 * i + 1, 65536 ).");

        int x0 = 1;

        Console.WriteLine("");
        Console.WriteLine("  Starting argument X0 = " + x0 + "");

        Floyd.cycle_floyd(f5, x0, ref lam, ref mu);

        Console.WriteLine("");
        Console.WriteLine("  Reported cycle length is " + lam + "");
        Console.WriteLine("  Expected value is 8");
        Console.WriteLine("");
        Console.WriteLine("  Reported distance to first cycle element is " + mu + "");
        Console.WriteLine("  Expected value is 0");

        int i = 0;

        x0 = 1;
        Console.WriteLine("  " + i + "  " + x0 + "");
        for (i = 1; i <= 10; i++)
        {
            x0 = f5(x0);
            Console.WriteLine("  " + i + "  " + x0 + "");
        }
    }
Exemplo n.º 5
0
    private static void test01()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST01 tests CYCLE_FLOYD for a tiny example.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    17 June 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int lam = 0;
        int mu  = 0;

        Console.WriteLine("");
        Console.WriteLine("TEST01");
        Console.WriteLine("  Test CYCLE_FLOYD on F1().");
        Console.WriteLine("  f1(0) = 6.");
        Console.WriteLine("  f1(1) = 6.");
        Console.WriteLine("  f1(2) = 0.");
        Console.WriteLine("  f1(3) = 1.");
        Console.WriteLine("  f1(4) = 4.");
        Console.WriteLine("  f1(5) = 3.");
        Console.WriteLine("  f1(6) = 3.");
        Console.WriteLine("  f1(7) = 4.");
        Console.WriteLine("  f1(8) = 0.");

        const int x0 = 2;

        Console.WriteLine("");
        Console.WriteLine("  Starting argument X0 = " + x0 + "");

        Floyd.cycle_floyd(f1, x0, ref lam, ref mu);

        Console.WriteLine("");
        Console.WriteLine("  Reported cycle length is " + lam + "");
        Console.WriteLine("  Expected value is 3");
        Console.WriteLine("");
        Console.WriteLine("  Reported distance to first cycle element is " + mu + "");
        Console.WriteLine("  Expected value is 2");
    }
        static void Main(string[] args)
        {
            var test1 = new Test(20);

            Console.WriteLine();
            var test2 = new Test();

            Console.WriteLine();
            // 2 + 4 + 6 + 8 + 10 = 30
            var SumAp = new SumAp(2, 2, 5);

            Console.WriteLine();
            var Floyd = new Floyd(10);
        }
Exemplo n.º 7
0
        public void TestFloyd()
        {
            GraphNode <char> root = new GraphNode <char>('a');
            var b = root.AddTwoWay('b', 2);
            var c = root.AddTwoWay('c', 1);
            var d = b.AddTwoWay('d', 4);

            c.AddTwoWay(d, 1);
            var e = b.AddTwoWay('e', 5);

            d.AddTwoWay(e, 3);

            Floyd.Perform(root);
        }
Exemplo n.º 8
0
        public static void FloydExample()
        {
            Console.WriteLine("\nFloyd Algorithm:");

            // found this matrix in the internet
            int[,] graph =
            {
                {    0,    6, 9999,   11 },
                { 9999,    0,    4, 9999 },
                { 9999, 9999,    0,    2 },
                { 9999, 9999, 9999,    0 }
            };

            Floyd.FloydAlgorithm(graph, 4);
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            double[,] gr = new double[5, 5] {
                { 0, 12, 5, Infinity, 2 },
                { 7, 0, 11, Infinity, 10 },
                { 4, 7, 0, Infinity, 17 },
                { 19, 2, 5, 0, 4 },
                { 15, 8, 1, Infinity, 0 }
            };

            Floyd floyd = new Floyd(5, gr);

            floyd.Calculate();

            Console.ReadKey();
        }
Exemplo n.º 10
0
    private static void test04()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST04 tests CYCLE_FLOYD for F4.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    17 June 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int lam = 0;
        int mu  = 0;

        Console.WriteLine("");
        Console.WriteLine("TEST04");
        Console.WriteLine("  Test CYCLE_FLOYD for F4().");
        Console.WriteLine("  f4(i) = mod ( 31421 * i + 6927, 65536 ).");

        const int x0 = 1;

        Console.WriteLine("");
        Console.WriteLine("  Starting argument X0 = " + x0 + "");

        Floyd.cycle_floyd(f4, x0, ref lam, ref mu);

        Console.WriteLine("");
        Console.WriteLine("  Reported cycle length is " + lam + "");
        Console.WriteLine("  Expected value is 65536");
        Console.WriteLine("");
        Console.WriteLine("  Reported distance to first cycle element is " + mu + "");
        Console.WriteLine("  Expected value is 0");
    }
Exemplo n.º 11
0
    private static void test03()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST03 tests CYCLE_FLOYD for F3.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    14 June 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int lam = 0;
        int mu  = 0;

        Console.WriteLine("");
        Console.WriteLine("TEST03");
        Console.WriteLine("  Test CYCLE_FLOYD for F3().");
        Console.WriteLine("  f3(i) = mod ( 123 * i + 456, 100000 ).");

        const int x0 = 789;

        Console.WriteLine("");
        Console.WriteLine("  Starting argument X0 = " + x0 + "");

        Floyd.cycle_floyd(f3, x0, ref lam, ref mu);

        Console.WriteLine("");
        Console.WriteLine("  Reported cycle length is " + lam + "");
        Console.WriteLine("  Expected value is 50000");
        Console.WriteLine("");
        Console.WriteLine("  Reported distance to first cycle element is " + mu + "");
        Console.WriteLine("  Expected value is 0");
    }
Exemplo n.º 12
0
    public int[,] connects;                                 //邻接矩阵

    public void Start()
    {
        connects = new int[pnum + 1, pnum + 1];
        for (int i = 0; i <= pnum; i++)
        {
            for (int j = 0; j <= pnum; j++)
            {
                connects[i, j] = 0;
            }
        }
        InitConnect();
        for (int i = 1; i <= pnum; i++)
        {
            for (int j = 1; j <= pnum; j++)
            {
                if (connects[i, j] == 1)
                {
                    connects[j, i] = 1;
                }
            }
        }
        int[,] path = Floyd.floyd(ref pnum, ref connects, ref pPosition);
        int l = 0;
    }
Exemplo n.º 13
0
        public void Small()
        {
            Floyd floyd = new Floyd(Tester.SMALL_SIZE).Generate();

            floyd.Run();
        }
Exemplo n.º 14
0
    private static void test02()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST02 tests R8MAT_FLOYD.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    27 November 2008
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int N = 6;

        double[] a =
        {
            0.0,  -1.0, -1.0, -1.0, -1.0, -1.0,
            2.0,   0.0, -1.0, -1.0, -1.0,  5.0,
            5.0,   7.0,  0.0, -1.0,  2.0, -1.0,
            -1.0,  1.0,  4.0,  0.0, -1.0,  2.0,
            -1.0, -1.0, -1.0,  3.0,  0.0,  4.0,
            -1.0,  8.0, -1.0, -1.0,  3.0, 0.0
        }

        ;
        int i;
        int j;

        Console.WriteLine("");
        Console.WriteLine("TEST02");
        Console.WriteLine("  R8MAT_FLOYO uses Floyd's algorithm to find the");
        Console.WriteLine("  shortest distance between all pairs of nodes");
        Console.WriteLine("  in a directed graph, starting from the initial array");
        Console.WriteLine("  of direct node-to-node distances.");

        Console.WriteLine("");
        Console.WriteLine("  In the initial direct distance array, if");
        Console.WriteLine("    A(I,J) = -1,");
        Console.WriteLine("  this indicates there is NO directed link from");
        Console.WriteLine("  node I to node J.  In that case, the value of");
        Console.WriteLine("  of A(I,J) is essentially \"infinity\".");

        typeMethods.r8mat_print(N, N, a, "  Initial direct distance array:");

        double huge = typeMethods.r8_huge();

        for (j = 0; j < N; j++)
        {
            for (i = 0; i < N; i++)
            {
                a[i + j * N] = a[i + j * N] switch
                {
                    -1.0 => huge,
                    _ => a[i + j * N]
                };
            }
        }

        Floyd.r8mat_floyd(N, ref a);

        for (j = 0; j < N; j++)
        {
            for (i = 0; i < N; i++)
            {
                if (Math.Abs(a[i + j * N] - huge) <= double.Epsilon)
                {
                    a[i + j * N] = -1.0;
                }
            }
        }

        Console.WriteLine("");
        Console.WriteLine("  In the final shortest distance array, if");
        Console.WriteLine("    A(I,J) = -1,");
        Console.WriteLine("  this indicates there is NO directed path from");
        Console.WriteLine("  node I to node J.");

        typeMethods.r8mat_print(N, N, a, "  Final shortest distance array:");
    }
Exemplo n.º 15
0
    private static double test03_sub(int n)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST03_SUB tests I4MAT_FLOYD.
    //
    //  Discussion:
    //
    //    The matrix size is input by the user.
    //
    //    The matrix A has the property that
    //
    //      A(I,J) = 1 if I is divisible by J.
    //
    //  Example:
    //
    //    N = 6
    //
    //    1 0 0 0 0 0
    //    1 1 0 0 0 0
    //    1 0 1 0 0 0
    //    1 1 0 1 0 0
    //    1 0 0 0 1 0
    //    1 1 1 0 0 1
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    20 July 2011
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, int N, the size of the matrix.
    //
    //    Output, double TEST03, the CPU time required by I4MAT_FLOYD.
    //
    {
        int j;

        int[] a = new int[n * n];

        int huge = typeMethods.i4_huge() / 2;

        for (j = 0; j < n; j++)
        {
            int i;
            for (i = 0; i < n; i++)
            {
                a[i + j * n] = ((i + 1) % (j + 1)) switch
                {
                    0 => 1,
                    _ => huge
                };
            }
        }

        DateTime time1 = DateTime.Now;

        Floyd.i4mat_floyd(n, ref a);

        DateTime time2 = DateTime.Now;

        double wtime = (time2 - time1).TotalSeconds;

        return(wtime);
    }
Exemplo n.º 16
0
        public void SizeSmall_ThreadBig()
        {
            Floyd floyd = new Floyd(Tester.SMALL_SIZE).Generate();

            floyd.Run(Tester.BIG_THREAD);
        }
Exemplo n.º 17
0
        public void SizeMiddle_ThreadBig()
        {
            Floyd floyd = new Floyd(Tester.MIDDLE_SIZE).Generate();

            floyd.Run(Tester.BIG_THREAD);
        }
Exemplo n.º 18
0
        public void SizeMiddle_ThreadSmall()
        {
            Floyd floyd = new Floyd(Tester.MIDDLE_SIZE).Generate();

            floyd.Run(Tester.SMALL_THREAD);
        }
Exemplo n.º 19
0
        public void Big()
        {
            Floyd floyd = new Floyd(Tester.BIG_SIZE).Generate();

            floyd.Run();
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            Floyd f = new Floyd(9);

            Console.WriteLine(f);
        }
Exemplo n.º 21
0
 public static void FloydTest()
 {
     var Floyd = new Floyd(10);
 }
Exemplo n.º 22
0
    private static void test01()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST01 tests I4MAT_FLOYD.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    27 November 2008
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int N = 6;

        int[] a =
        {
            0,  -1, -1, -1, -1, -1,
            2,   0, -1, -1, -1,  5,
            5,   7,  0, -1,  2, -1,
            -1,  1,  4,  0, -1,  2,
            -1, -1, -1,  3,  0,  4,
            -1,  8, -1, -1,  3, 0
        }

        ;
        int i;
        int j;

        Console.WriteLine("");
        Console.WriteLine("TEST01");
        Console.WriteLine("  I4MAT_FLOYO uses Floyd's algorithm to find the");
        Console.WriteLine("  shortest distance between all pairs of nodes");
        Console.WriteLine("  in a directed graph, starting from the initial array");
        Console.WriteLine("  of direct node-to-node distances.");

        Console.WriteLine("");
        Console.WriteLine("  In the initial direct distance array, if");
        Console.WriteLine("    A(I,J) = -1,");
        Console.WriteLine("  this indicates there is NO directed link from");
        Console.WriteLine("  node I to node J.  In that case, the value of");
        Console.WriteLine("  of A(I,J) is essentially \"infinity\".");

        typeMethods.i4mat_print(N, N, a, "  Initial direct distance array:");

        int huge = typeMethods.i4_huge() / 2;

        for (j = 0; j < N; j++)
        {
            for (i = 0; i < N; i++)
            {
                a[i + j * N] = a[i + j * N] switch
                {
                    -1 => huge,
                    _ => a[i + j * N]
                };
            }
        }

        Floyd.i4mat_floyd(N, ref a);

        for (j = 0; j < N; j++)
        {
            for (i = 0; i < N; i++)
            {
                if (a[i + j * N] == huge)
                {
                    a[i + j * N] = -1;
                }
            }
        }

        Console.WriteLine("");
        Console.WriteLine("  In the final shortest distance array, if");
        Console.WriteLine("    A(I,J) = -1,");
        Console.WriteLine("  this indicates there is NO directed path from");
        Console.WriteLine("  node I to node J.");

        typeMethods.i4mat_print(N, N, a, "  Final shortest distance array:");
    }
Exemplo n.º 23
0
    private static void test04()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST04 uses Floyd's method for a triangulation.
    //
    //  Discussion:
    //
    //     8  41--42--43--44  45--46--47--48
    //     |   | \ | \ | \ |   | \ | \ | \ |
    //     7  33--34--35--36  37--38--39--40
    //     |   | \ |                   | \ |
    //     6  29--30                  31--32
    //     |   | \ |                   | \ |
    //     5  25--26                  27--28
    //     |   | \ |                   | \ |
    //     4  21--22                  23--24
    //     |   | \ |                   | \ |
    //     3  17--18                  19--20
    //     |   | \ |                   | \ |
    //     2   9--10--11--12--13--14--15--16
    //     |   | \ | \ | \ | \ | \ | \ | \ |
    //     1   1---2---3---4---5---6---7---8
    //     |
    //     +---1---2---3---4---5---6---7---8
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    02 March 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int ELEMENT_NUM = 46;
        int NODE_NUM    = 48;

        double[] d = new double[NODE_NUM * NODE_NUM];
        int      element;

        int[] element_node =
        {
            1,   2,  9,
            2,  10,  9,
            2,   3, 10,
            3,  11, 10,
            3,   4, 11,
            4,  12, 11,
            4,   5, 12,
            5,  13, 12,
            5,   6, 13,
            6,  14, 13,
            6,   7, 14,
            7,  15, 14,
            7,   8, 15,
            8,  16, 15,
            9,  10, 17,
            10, 18, 17,
            15, 16, 19,
            16, 20, 19,
            17, 18, 21,
            18, 22, 21,
            19, 20, 23,
            20, 24, 23,
            21, 22, 25,
            22, 26, 25,
            23, 24, 27,
            24, 28, 27,
            25, 26, 29,
            26, 30, 29,
            27, 28, 31,
            28, 32, 31,
            29, 30, 33,
            30, 34, 33,
            31, 32, 39,
            32, 40, 39,
            33, 34, 41,
            34, 42, 41,
            34, 35, 42,
            35, 43, 42,
            35, 36, 43,
            36, 44, 43,
            37, 38, 45,
            38, 46, 45,
            38, 39, 46,
            39, 47, 46,
            39, 40, 47,
            40, 48, 47
        }

        ;
        int i;
        int j;

        double[] xy =
        {
            1.0, 1.0,
            2.0, 1.0,
            3.0, 1.0,
            4.0, 1.0,
            5.0, 1.0,
            6.0, 1.0,
            7.0, 1.0,
            8.0, 1.0,
            1.0, 2.0,
            2.0, 2.0,
            3.0, 2.0,
            4.0, 2.0,
            5.0, 2.0,
            6.0, 2.0,
            7.0, 2.0,
            8.0, 2.0,
            1.0, 3.0,
            2.0, 3.0,
            7.0, 3.0,
            8.0, 3.0,
            1.0, 4.0,
            2.0, 4.0,
            7.0, 4.0,
            8.0, 4.0,
            1.0, 5.0,
            2.0, 5.0,
            7.0, 5.0,
            8.0, 5.0,
            1.0, 6.0,
            2.0, 6.0,
            7.0, 6.0,
            8.0, 6.0,
            1.0, 7.0,
            2.0, 7.0,
            3.0, 7.0,
            4.0, 7.0,
            5.0, 7.0,
            6.0, 7.0,
            7.0, 7.0,
            8.0, 7.0,
            1.0, 8.0,
            2.0, 8.0,
            3.0, 8.0,
            4.0, 8.0,
            5.0, 8.0,
            6.0, 8.0,
            7.0, 8.0,
            8.0, 8.0
        }

        ;

        Console.WriteLine("");
        Console.WriteLine("TEST04");
        Console.WriteLine("  Start with a triangulation, and use R8_FLOYD");
        Console.WriteLine("  to determine the pairwise distance matrix.");
        //
        //  Must initialize distances to -1
        //
        for (j = 0; j < NODE_NUM; j++)
        {
            for (i = 0; i < NODE_NUM; i++)
            {
                d[i + j * NODE_NUM] = -1.0;
            }
        }

        //
        //  Diagonals are 0.
        //
        for (i = 0; i < NODE_NUM; i++)
        {
            d[i + i * NODE_NUM] = 0.0;
        }

        //
        //  Initialize D to the one-step distance.
        //
        for (element = 0; element < ELEMENT_NUM; element++)
        {
            int n1 = element_node[2 + element * 3] - 1;
            for (i = 0; i < 3; i++)
            {
                int n2 = element_node[i + element * 3] - 1;
                d[n1 + n2 * NODE_NUM] = Math.Sqrt(Math.Pow(xy[0 + n1 * 2] - xy[0 + n2 * 2], 2)
                                                  + Math.Pow(xy[1 + n1 * 2] - xy[1 + n2 * 2], 2));
                d[n2 + n1 * NODE_NUM] = d[n1 + n2 * NODE_NUM];
                n1 = n2;
            }
        }

        //
        //  Reset -1 values to R8_HUGE.
        //
        for (j = 0; j < NODE_NUM; j++)
        {
            for (i = 0; i < NODE_NUM; i++)
            {
                d[i + j * NODE_NUM] = d[i + j * NODE_NUM] switch
                {
                    -1.0 => typeMethods.r8_huge(),
                    _ => d[i + j * NODE_NUM]
                };
            }
        }

        //
        //  Update D to the N-1 step distance.
        //
        Floyd.r8mat_floyd(NODE_NUM, ref d);

        typeMethods.r8mat_print(NODE_NUM, NODE_NUM, d, "  Distance matrix");
    }
}
Exemplo n.º 24
0
        /// <summary>
        /// 创建数据库
        /// </summary>
        public void CreateAllDbs()
        {
            db = OpenDb();

            #region 初始化存档表相关数据
            //存档数据表
            db.ExecuteQuery("create table if not exists RecordsTable (Id integer primary key autoincrement not null, RoleId text not null, Name text not null, Data text, DateTime text not null)");
            //用户基础数据表
            db.ExecuteQuery("create table if not exists UserDatasTable (Id integer primary key autoincrement not null, Data text, AreaFoodNum integer not null, TimeAngle single not null, TimeTicks long not null, BelongToRoleId text not null, DateTime text not null)");
            #endregion

            #region 初始化角色相关数据
            //当前获得的伙伴数据表
            db.ExecuteQuery("create table if not exists RolesTable (Id integer primary key autoincrement not null, RoleId text not null, RoleData text not null, State integer not null, SeatNo integer not null, HometownCityId text not null, BelongToRoleId text not null, InjuryType integer not null, Ticks long not null, DateTime text not null)");
            //背包数据表
            db.ExecuteQuery("create table if not exists BagTable (Id integer primary key autoincrement not null, ItemId text not null, Type integer not null, Num integer not null, MaxNum integer not null, Lv integer not null, BelongToRoleId text not null)");
            //玩家进入的区域大地图记录表
            db.ExecuteQuery("create table if not exists EnterAreaTable (Id integer primary key autoincrement not null, AreaName text not null, BelongToRoleId text not null)");
            //玩家进入的城镇记录表
            db.ExecuteQuery("create table if not exists EnterCityTable (Id integer primary key autoincrement not null, CityId text not null, BelongToRoleId text not null)");
            //兵器匣数据表
            db.ExecuteQuery("create table if not exists WeaponsTable (Id integer primary key autoincrement not null, WeaponId text not null, BeUsingByRoleId text not null, BelongToRoleId text not null)");
            //秘籍数据表
            db.ExecuteQuery("create table if not exists BooksTable (Id integer primary key not null, BookId text not null, State integer not null, SeatNo integer not null, BeUsingByRoleId text not null, BelongToCityId text not null, BelongToRoleId text not null)");
            #endregion

            #region 初始化任务表相关数据
            //当前可以操作的任务数据表(包括可以接取的任务,已完成的任务和接取条件不满足的任务)
            db.ExecuteQuery("create table if not exists TasksTable (Id integer primary key autoincrement not null, TaskId text not null, ProgressData text not null, CurrentDialogIndex integer not null, State integer not null, BelongToRoleId text not null)");
            //初始化动态事件表
            db.ExecuteQuery("create table if not exists EventsTable (Id integer primary key autoincrement not null, X integer not null, Y integer not null, Type integer not null, EventId text not null, SceneId text not null, Name text not null, BelongToRoleId text not null)");
            #endregion

            #region 初始化战斗记录相关数据
            //战斗获胜记录表
            db.ExecuteQuery("create table if not exists FightWinedRecordsTable (Id integer primary key autoincrement not null, FightId text not null, Star integer not null, Num integer not null, DateTime text not null, BelongToRoleId text not null)");
            //使用过的技能记录表
            db.ExecuteQuery("create table if not exists UsedTheSkillRecordsTable (Id integer primary key autoincrement not null, SkillId text not null, Num integer not null, DateTime text not null, BelongToRoleId text not null)");
            //各阶段兵器暴击次数记录表
            db.ExecuteQuery("create table if not exists WeaponPowerPlusSuccessedRecordsTable (Id integer primary key autoincrement not null, PlusIndex integer not null, Num integer not null, DateTime text not null, BelongToRoleId text not null)");
            //使用过的物品记录表
            db.ExecuteQuery("create table if not exists UsedItemRecordsTable (Id integer primary key autoincrement not null, ItemId text not null, Num integer not null, BelongToRoleId text not null)");
            #endregion

            #region 初始化工坊相关数据
            //工坊资源表
            db.ExecuteQuery("create table if not exists WorkshopResourceTable (Id integer primary key autoincrement not null, ResourcesData text not null, Ticks long not null, WorkerNum int not null, MaxWorkerNum int not null, BelongToRoleId text not null)");
            //工坊打造兵器表
            db.ExecuteQuery("create table if not exists WorkshopWeaponBuildingTable (Id integer primary key autoincrement not null, WeaponId text not null, State int not null, BelongToCityId text not null, BelongToRoleId text not null)");
            #endregion

            initTasks();

            db.CloseSqlConnection();

            //初始化佛洛依德算法
            TextAsset            asset = Resources.Load <TextAsset>("Data/Json/FloydDis");
            List <List <float> > dis   = JsonManager.GetInstance().DeserializeObject <List <List <float> > >(asset.text);
            floyd = new Floyd(dis, dis.Count);
            asset = Resources.Load <TextAsset>("Data/Json/SceneIndexToIds");
            cityIndexToIdMapping = JsonManager.GetInstance().DeserializeObject <Dictionary <int, string> >(asset.text);
            asset = Resources.Load <TextAsset>("Data/Json/SceneIndexToNames");
            cityIndexToNameMapping = JsonManager.GetInstance().DeserializeObject <Dictionary <int, string> >(asset.text);
            asset = null;
            dis   = null;

//			AddNewRecord(currentRoleId, "-", "{}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//
//			UserData userData = new UserData();
//			userData.AreaFood = JsonManager.GetInstance().GetMapping<ItemData>("ItemDatas", "1");
//			userData.AreaFood.Num = 0;
//			userData.AreaFood.MaxNum = 100;
//			userData.PositionStatu = UserPositionStatusType.InCity;
//			userData.CurrentAreaSceneName = "Area0";
//			userData.CurrentCitySceneId = "1";
//			userData.CurrentAreaX = 9;
//			userData.CurrentAreaY = 8;
//			AddNewUserData(JsonManager.GetInstance().SerializeObjectDealVector(userData), userData.AreaFood.Num, currentRoleId, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//
//			RoleData role = JsonManager.GetInstance().GetMapping<RoleData>("RoleDatas", "1");
//			role.IsHost = true;
//			role.Id = currentRoleId;
//			role.Occupation = OccupationType.None;
//			role.ResourceBookDataIds.Clear();
//			if (AddNewRole(currentRoleId, JsonManager.GetInstance().SerializeObjectDealVector(role), (int)RoleStateType.InTeam, 0, role.HometownCityId, currentRoleId, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))) {
//				AddNewWeapon(role.ResourceWeaponDataId, role.Id);
//				AddNewWeapon("2");
//				AddNewWeapon("22");
//				AddNewWeapon("11");
//				AddNewWeapon("3");
//			}

//			role = JsonManager.GetInstance().GetMapping<RoleData>("RoleDatas", "2");
//			AddNewRole(role.Id, JsonManager.GetInstance().SerializeObjectDealVector(role), (int)RoleStateType.InTeam, 1, role.HometownCityId, currentRoleId, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//			role = JsonManager.GetInstance().GetMapping<RoleData>("RoleDatas", "3");
//			AddNewRole(role.Id, JsonManager.GetInstance().SerializeObjectDealVector(role), (int)RoleStateType.InTeam, 2, role.HometownCityId, currentRoleId, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
        }
Exemplo n.º 25
0
        public void Middle()
        {
            Floyd floyd = new Floyd(Tester.MIDDLE_SIZE).Generate();

            floyd.Run();
        }