Example #1
0
        public mino get_mino_han()
        {
            mino m = new mino(new int[, ] {
                { 0, 0, 0, 0, 0, 0, 1 },
                { 1, 1, 1, 1, 0, 1, 0 },
                { 0, 1, 0, 1, 0, 0, 0 },
                { 0, 0, 1, 0, 0, 1, 1 },
                { 0, 1, 0, 1, 0, 0, 0 },
                { 1, 0, 0, 0, 1, 1, 0 },
                { 0, 0, 0, 0, 0, 0, 1 },
            },

                              new pos[, ] {
                { new pos(0, 0), new pos(-1, 0), new pos(-1, +1), new pos(0, -2), new pos(-1, -2) },
                { new pos(0, 0), new pos(+1, 0), new pos(+1, -1), new pos(0, +2), new pos(+1, +2) },
                { new pos(0, 0), new pos(+1, 0), new pos(+1, +1), new pos(0, -2), new pos(+1, -2) },
                { new pos(0, 0), new pos(-1, 0), new pos(-1, -1), new pos(0, +2), new pos(-1, +2) },
            },

                              0,

                              new pos(),

                              "wu"
                              );

            return(m);
        }
Example #2
0
        //public mino get_mino_O()
        //{
        //    mino m = new mino(new int[,] {
        //    { 0, 0, 0, 0},
        //    { 0, 1, 1, 0},
        //    { 0, 1, 1, 0},
        //    { 0, 0, 0, 0},
        //    },

        //    new pos[,] {
        //    { new pos(0, 0)},
        //    { new pos(0, 0)},
        //    { new pos(0, 0)},
        //    { new pos(0, 0)},
        //    },

        //    0,

        //    new pos(),

        //    "O"
        //    );
        //    return m;
        //}

        public mino get_mino_O()
        {
            mino m = new mino(new int[, ] {
                { 0, 0, 0, 0 },
                { 0, 1, 1, 0 },
                { 0, 1, 1, 0 },
                { 0, 0, 0, 0 },
            },

                              new pos[, ] {
                { new pos(0, 0) },
                { new pos(0, 0) },
                { new pos(0, 0) },
                { new pos(0, 0) },
            },

                              0,

                              new pos(),

                              "O"
                              );

            return(m);
        }
Example #3
0
        }  // 不锁定判断tspin

        public mino clone()
        {
            mino cp = new mino(minofield, kicktable, stat, minopos, name);

            cp.locked    = this.locked; // spin需要更新吗
            cp.spinlast  = this.spinlast;
            cp.height    = this.height;
            cp.weight    = this.weight;
            cp.path      = this.path;
            cp.minopos.x = this.minopos.x;
            cp.minopos.y = this.minopos.y;
            return(cp);
        }
Example #4
0
        public bool Spawn_piece()
        {
            if (Next_queue.Count == 0)
            {
                return(false);
            }
            piece = Next_queue.Dequeue();
            piece.setpos(20, 3);
            bool isok = check_mino_ok(piece.minopos);

            isdead = !isok;
            return(true);
            //gene_next_piece();
        }
Example #5
0
        public void console_print(bool printmino = true, mino m = null)
        {
            Console.WriteLine("\n+--------------------+");
            bool[,] minopp = new bool[40, 10];
            //if (printmino/* && !m.locked)*/)
            //{
            //    for (int i = 0; i < m.height; ++i)
            //    {
            //        for (int j = 0; j < m.weight; ++j)
            //        {
            //            if (m.minofield[i, j] != 0)
            //                minopp[i + m.minopos.x, j + m.minopos.y] = true;
            //        }
            //    }
            //} //maxtspin slot search

            for (int i = 20; i >= 0; --i)
            {
                Console.Write("|");
                for (int j = 0; j < 10; ++j)
                {
                    if (minopp[i, j])
                    {
                        Console.Write("**");
                    }
                    else if (field[i, j])
                    {
                        Console.Write("[]");
                    }
                    else
                    {
                        Console.Write(" +");
                    }
                }
                Console.WriteLine("|");
            }
            //if (printmino && !m.locked)
            //{
            //    for (int i = 0; i < m.height; ++i)
            //    {
            //        for (int j = 0; j < m.weight; ++j)
            //        {
            //            if (m.minofield[i, j] != 0)
            //                field[i + m.minopos.x, j + m.minopos.y] = false;
            //        }
            //    }
            //}

            Console.WriteLine("+--------------------+\n");
        }
Example #6
0
        public void console_print(bool printmino = true, mino m = null)
        {
            Console.WriteLine("\n+--------------------+");
            if (printmino && !m.locked)
            {
                for (int i = 0; i < m.height; ++i)
                {
                    for (int j = 0; j < m.weight; ++j)
                    {
                        if (m.minofield[i, j] != 0)
                        {
                            field[i + m.minopos.x, j + m.minopos.y] = 1;
                        }
                    }
                }
            }
            for (int i = 20; i >= 0; --i)
            {
                Console.Write("|");
                for (int j = 0; j < 10; ++j)
                {
                    if (field[i, j] != 0)
                    {
                        Console.Write("[]");
                    }
                    else
                    {
                        Console.Write(" +");
                    }
                }
                Console.WriteLine("|");
            }
            if (printmino && !m.locked)
            {
                for (int i = 0; i < m.height; ++i)
                {
                    for (int j = 0; j < m.weight; ++j)
                    {
                        if (m.minofield[i, j] != 0)
                        {
                            field[i + m.minopos.x, j + m.minopos.y] = 0;
                        }
                    }
                }
            }

            Console.WriteLine("+--------------------+\n");
        }
Example #7
0
 public bool use_hold()
 {
     piece.reset();
     if (holdpiece == null)
     {
         if (Next_queue.Count == 0)
         {
             return(false);
         }
         holdpiece = piece;
         Spawn_piece();
         //gene_next_piece();
     }
     else
     {
         mino temp = holdpiece;
         holdpiece = piece;
         piece     = temp;
     }
     piece.reset();
     return(true);
 }
Example #8
0
        static public List <mino> findalltslot(simpboard Board)
        {
            List <mino> allpos = new List <mino>();

            bool[,,] visit  = new bool[42, 12, 4];
            bool[,,] visit1 = new bool[42, 12, 4];
            Queue <mino_stat> minoque = new Queue <mino_stat>();

            if (!Board.piece.check_mino_ok(ref Board, Board.piece.minopos))
            {
                return(allpos);
            }
            minoque.Enqueue(new mino_stat(Board.piece.minopos, Board.piece.stat));
            visit[Board.piece.minopos.x + 2, Board.piece.minopos.y + 2, Board.piece.stat] = true;
            mino_gene minogen = new mino_gene();
            mino      temp    = Board.piece.clone();

            while (minoque.Count != 0)
            {
                mino_stat node = minoque.Dequeue();

                //visit[node.minoopos.x, node.minoopos.y, node.stat] = true; // 硬降
                temp.setpos(node.minoopos);
                temp.setstat(node.stat);
                if (temp.left_rotation(ref Board) != -1)
                {
                    if (!visit[temp.minopos.x + 2, temp.minopos.y + 2, temp.stat])
                    {
                        visit[temp.minopos.x + 2, temp.minopos.y + 2, temp.stat] = true;
                        minoque.Enqueue(new mino_stat(temp.minopos, temp.stat, node.idx, node.path, 2, node.movetime));
                    }
                }

                temp.setpos(node.minoopos);
                temp.setstat(node.stat);
                if (temp.right_rotation(ref Board) != -1)
                {
                    if (!visit[temp.minopos.x + 2, temp.minopos.y + 2, temp.stat])
                    {
                        visit[temp.minopos.x + 2, temp.minopos.y + 2, temp.stat] = true;
                        minoque.Enqueue(new mino_stat(temp.minopos, temp.stat, node.idx, node.path, 3, node.movetime));
                    }
                }

                temp.setpos(node.minoopos);
                temp.setstat(node.stat);

                if (temp.left_move(ref Board))
                {
                    if (!visit[temp.minopos.x + 2, temp.minopos.y + 2, temp.stat])
                    {
                        visit[temp.minopos.x + 2, temp.minopos.y + 2, temp.stat] = true;
                        minoque.Enqueue(new mino_stat(temp.minopos, temp.stat, node.idx, node.path, 0, node.movetime));
                    }
                }
                temp.setpos(node.minoopos);
                temp.setstat(node.stat);
                if (temp.right_move(ref Board))
                {
                    if (!visit[temp.minopos.x + 2, temp.minopos.y + 2, temp.stat])
                    {
                        visit[temp.minopos.x + 2, temp.minopos.y + 2, temp.stat] = true;
                        minoque.Enqueue(new mino_stat(temp.minopos, temp.stat, node.idx, node.path, 1, node.movetime));
                    }
                }

                temp.setpos(node.minoopos);
                temp.setstat(node.stat);

                int dis = temp.soft_drop_floor(ref Board);
                //{
                if (!visit[temp.minopos.x + 2, temp.minopos.y + 2, temp.stat])
                {
                    visit[temp.minopos.x + 2, temp.minopos.y + 2, temp.stat] = true;
                    minoque.Enqueue(new mino_stat(temp.minopos, temp.stat, node.idx, node.path, -dis, node.movetime, repeat: dis));
                }
                //}
                if (!visit1[temp.minopos.x + 2, temp.minopos.y + 2, temp.stat])
                {
                    visit1[temp.minopos.x + 2, temp.minopos.y + 2, temp.stat] = true;

                    mino fi = temp.clone();
                    fi.spinstatupdate(ref Board);
                    fi.path = node;
                    allpos.Add(fi);
                }



                //source.setpos
            }

            return(allpos);
        }