Example #1
0
 // constructor function
 public CELL(MBR W)
 {
     this.current = W;
     this.next = null;
     this.prev = null;
     this.child = null;
 }
Example #2
0
 // constructor
 public Cut_info(float cost, float cut, CELL C1, CELL C2)
 {
     this.cost = cost;
     this.cut = cut;
     S1 = new LIST(C1);
     S2 = new LIST(C2);
 }
Example #3
0
    public Board()
    {
        for (uchar i = 0; i < PlayerDef.MAX; i++)
        {
            for (uchar j = 0; j < PawnDef.CAPTURE_MAX; j++)
            {
                captured[i, j] = 0;
            }
        }

        for (uchar j = 1; j <= BoardDef.HEIGHT; j++)
        {
            for (uchar i = 1; i <= BoardDef.WIDTH; i++)
            {
                matrix[j, i] = new CELL(PlayerDef.NONE, PawnDef.NONE);
            }
        }

        for (uchar i = 0; i < BoardDef.WIDTH + 2; i++)
        {
            matrix[0, i] = new CELL(PlayerDef.WALL, PawnDef.NONE);
            matrix[BoardDef.HEIGHT + 1, i] = new CELL(PlayerDef.WALL, PawnDef.NONE);
        }

        for (uchar j = 1; j <= BoardDef.HEIGHT; j++)
        {
            matrix[j, 0] = new CELL(PlayerDef.WALL, PawnDef.NONE);
            matrix[j, BoardDef.WIDTH + 1] = new CELL(PlayerDef.WALL, PawnDef.NONE);
        }

        turn  = PlayerDef.FIRST;
        enemy = PlayerDef.SECOND;
    }
Example #4
0
 public void Fill(CELL cell)
 {
     for (int i = 0; i < mainLayer.Length; i++)
     {
         mainLayer[i] = (byte)cell;
     }
 }
Example #5
0
        public static RoomType SetRandomRoomType(CELL TargetCell)
        {
            int count = rand.Next(0, 3);

            switch (count)
            {
            case 0:
                TargetCell.Room_type = RoomType.Trap;
                break;

            case 1:
                TargetCell.Room_type = RoomType.Treasure;
                //так я открыла комнаты с сокровищем
                break;

            case 2:
                TargetCell.Room_type = RoomType.Enemy;
                // а так закрыла с врагами
                break;

            default:
                TargetCell.Room_type = RoomType.None;
                break;
            }
            return(TargetCell.Room_type);
        }
Example #6
0
        public Sector(int x, int y)
        {
            this.x = x;
            this.y = y;

            this.topLeft = this.top = this.topRight = this.left = this.center = this.right = this.bottomLeft = this.bottom = this.bottomRight = CELL.FLOOR;
        }
Example #7
0
        private void swap(Point p1, Point p2)
        {
            CELL temp = Nodes[p1.y][p1.x];

            Nodes[p1.y][p1.x] = Nodes[p2.y][p2.x];
            Nodes[p2.y][p2.x] = temp;
        }
Example #8
0
    // constructor
    public LIST(CELL c)
    {
        CELL ptr, temp_cell;
        MBR temp_mbr;

        ptr = c;
        this.head = null;
        while (ptr != null)
        {
            temp_cell = new CELL(ptr.current);

            if (this.head == null)
            {
                this.head = temp_cell;
            }
            else
            {
                this.head.prev = temp_cell;
                temp_cell.next = this.head;
                this.head = temp_cell;
            }

            ptr = ptr.next;
        }
    }
Example #9
0
        // список соседних клеток
        public static List <CELL> GetNeighbours(CELL[,] arr, CELL TargetCell, int dlin, int shirina)
        {
            List <CELL> list_cell = new List <CELL>();

            if (TargetCell.x + 1 < dlin)
            {
                if (arr[TargetCell.x + 1, TargetCell.y].type == " ")
                {
                    list_cell.Add(arr[TargetCell.x + 1, TargetCell.y]);
                }
            }
            if (TargetCell.x - 1 > 0)
            {
                if (arr[TargetCell.x - 1, TargetCell.y].type == " ")
                {
                    list_cell.Add(arr[TargetCell.x - 1, TargetCell.y]);
                }
            }
            if (TargetCell.y + 1 < shirina)
            {
                if (arr[TargetCell.x, TargetCell.y + 1].type == " ")
                {
                    list_cell.Add(arr[TargetCell.x, TargetCell.y + 1]);
                }
            }
            if (TargetCell.y - 1 > 0)
            {
                if (arr[TargetCell.x, TargetCell.y - 1].type == " ")
                {
                    list_cell.Add(arr[TargetCell.x, TargetCell.y - 1]);
                }
            }
            return(list_cell);
        }
Example #10
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    private void Start()
    {
        //	Gather potential sub-entity information and existing cell information
        _parentEntity = transform.parent.GetComponentInParent <CELL_ENTITY> ();
        _parentCell   = transform.parent.GetComponentInParent <CELL> ();
        if (_parentEntity != null)
        {
            //	If the entity is a sub-entity, register with the parent entity
            _parentEntity.On_Cell_Entity_Generate += Generate;
        }
        else
        {
            //	If the entity is not a sub-entity, register with the cell
            _parentCell.On_Cell_Generate += Generate;
        }

        //	Define the audience
        _audience = new List <NPC> ();

        //	Set the tag for the entity
        if (isPointOfInterest && this.name != "NPC")
        {
            tag = "Point_Of_Interest";
        }
    }
Example #11
0
        // список соседних непосещеных клеток через одну
        public static List <CELL> GetCellNeighbours(CELL[,] arr, CELL TargetCell, int dlin, int shirina)
        {
            List <CELL> list_cell = new List <CELL>();

            if (TargetCell.x + 2 < dlin)
            {       //ячейка и не посещеная
                if (arr[TargetCell.x + 2, TargetCell.y].type == " " && !arr[TargetCell.x + 2, TargetCell.y].vision)
                {
                    list_cell.Add(arr[TargetCell.x + 2, TargetCell.y]);
                }
            }
            if (TargetCell.x - 2 > 0)
            {
                if (arr[TargetCell.x - 2, TargetCell.y].type == " " && !arr[TargetCell.x - 2, TargetCell.y].vision)
                {
                    list_cell.Add(arr[TargetCell.x - 2, TargetCell.y]);
                }
            }
            if (TargetCell.y + 2 < shirina)
            {
                if (arr[TargetCell.x, TargetCell.y + 2].type == " " && !arr[TargetCell.x, TargetCell.y + 2].vision)
                {
                    list_cell.Add(arr[TargetCell.x, TargetCell.y + 2]);
                }
            }
            if (TargetCell.y - 2 > 0)
            {
                if (arr[TargetCell.x, TargetCell.y - 2].type == " " && !arr[TargetCell.x, TargetCell.y - 2].vision)
                {
                    list_cell.Add(arr[TargetCell.x, TargetCell.y - 2]);
                }
            }
            return(list_cell);
        }
Example #12
0
        public static CELL GetLongWay(CELL[,] arr, int dlin, int shirina)
        {
            Stack <CELL> Way = new Stack <CELL>();

            for (int i = 0; i < dlin; i++)
            {
                for (int j = 0; j < shirina; j++)
                {
                    if (arr[i, j].type == " ")
                    {
                        arr[i, j].vision = false;
                    }
                }
            }
            Random rand        = new Random();
            CELL   startCell   = arr[1, 1];
            CELL   currentCell = startCell;

            Way.Push(currentCell);
            currentCell.Way_count = 0;
            do
            {
                List <CELL> list_cell = GetCellNeighbours_with_step(arr, currentCell, dlin, shirina);
                if (list_cell.Count != 0)
                {
                    int  poryadok      = rand.Next(list_cell.Count);
                    CELL NeighbourCell = arr[list_cell[poryadok].x, list_cell[poryadok].y];
                    Way.Push(currentCell);
                    arr[currentCell.x, currentCell.y].vision        = true;
                    arr[currentCell.x, currentCell.y].type          = " ";
                    arr[NeighbourCell.x, NeighbourCell.y].Way_count = arr[currentCell.x, currentCell.y].Way_count + 1;
                    currentCell = arr[NeighbourCell.x, NeighbourCell.y];
                }
                else
                {
                    if (Way.Count != 0)
                    {
                        arr[currentCell.x, currentCell.y].vision = true;
                        CELL last_cell = Way.Pop();
                        currentCell            = arr[last_cell.x, last_cell.y];
                        currentCell.Way_count -= 1;
                    }
                }
            } while (Get_count(arr, dlin, shirina) != 0);
            int  max_value      = 0;
            CELL max_value_cell = new CELL();

            for (int i = 0; i < dlin; i++)
            {
                for (int j = 0; j < shirina; j++)
                {
                    if (max_value < arr[i, j].Way_count)
                    {
                        max_value      = arr[i, j].Way_count;
                        max_value_cell = arr[i, j];
                    }
                }
            }
            return(max_value_cell);
        }
Example #13
0
        //Создаем новый лабиринт
        public static CELL[,] Get_New_labirint(int height, int width)
        {// да
            CELL[,] cellMaze = new CELL[height, width];
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    if (((i % 2 != 0) && (j % 2 != 0)) && ((i < height - 1) && (j < width - 1)))
                    {//room
                        cellMaze[i, j].x         = i;
                        cellMaze[i, j].y         = j;
                        cellMaze[i, j].type      = " ";
                        cellMaze[i, j].vision    = false;
                        cellMaze[i, j].Room_type = SetRandomRoomType(cellMaze[i, j]);
                    }
                    else
                    {//стена
                        cellMaze[i, j].x      = i;
                        cellMaze[i, j].y      = j;
                        cellMaze[i, j].type   = "0";
                        cellMaze[i, j].vision = false;
                    }
                }
            }
            CELL         Curent_cell        = cellMaze[1, 1];
            Stack <CELL> Do_you_know_de_way = new Stack <CELL>();
            Random       rand = new Random();

            do
            {
                List <CELL> list_cell = GetCellNeighbours(cellMaze, Curent_cell, height, width);
                if (list_cell.Count != 0)
                {
                    int  poryadok      = rand.Next(list_cell.Count);
                    CELL NeighbourCell = cellMaze[list_cell[poryadok].x, list_cell[poryadok].y];
                    RemoveWall(Curent_cell, NeighbourCell, cellMaze);
                    Do_you_know_de_way.Push(Curent_cell);
                    cellMaze[Curent_cell.x, Curent_cell.y].vision = true;
                    cellMaze[Curent_cell.x, Curent_cell.y].type   = " ";
                    Curent_cell = cellMaze[NeighbourCell.x, NeighbourCell.y];
                }
                else
                {
                    if (Do_you_know_de_way.Count != 0)
                    {
                        cellMaze[Curent_cell.x, Curent_cell.y].vision = true;
                        CELL last_cell = Do_you_know_de_way.Pop();
                        Curent_cell = cellMaze[last_cell.x, last_cell.y];
                    }
                }
            }while (Get_count(cellMaze, height, width) != 0);
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    cellMaze[i, j].vision = false;
                }
            }
            return(cellMaze);
        }
Example #14
0
 public bool Compare(CELL cell, MapSkinAsset.TileRuleType ruleType)
 {
     if (ruleType == MapSkinAsset.TileRuleType.BOTH)
     {
         return(true);
     }
     return((cell == CELL.WALL) == (ruleType == MapSkinAsset.TileRuleType.WALL));
 }
Example #15
0
 // insert a cell into the list of MBR
 public virtual void insertList(CELL newCell)
 {
     if (this.head != null)
     {
         this.head.prev = newCell;
     }
     newCell.next = this.head;
     this.head = newCell;
 }
Example #16
0
//C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#:
//ORIGINAL LINE: bool GetCell(int tox, int toy, CELL &cell) const
    public bool GetCell(int tox, int toy, ref CELL cell)
    {
        if (matrix[toy, tox].player != turn)
        {
            return(false);
        }

        cell = matrix[toy, tox];

        return(true);
    }
Example #17
0
        private void ChangeTurn()
        {
            if (Turn == CELL.O)
            {
                Turn = CELL.X;
                return;
            }

            if (Turn == CELL.X)
            {
                Turn = CELL.O;
                return;
            }
        }
Example #18
0
 public TicTacToeGame()
 {
     Board = new CELL[N][];
     for (int i = 0; i < N; i++)
     {
         Board[i] = new CELL[N];
     }
     for (int i = 0; i < N; i++)
     {
         for (int j = 0; j < N; j++)
         {
             Board[i][j] = CELL.E;
         }
     }
 }
Example #19
0
        public void ImportMapFromImage(string path, int moveX = 0, int moveY = 0)
        {
            var heightMeta = RawImage.LoadRawMetadataFromJson(path);
            var heightData = RawImage.LoadGrayscale16(path, heightMeta);

            int cellNumberX = heightData.GetLength(1) / MW_CELL;
            int cellNumberY = heightData.GetLength(0) / MW_CELL;

            var landList = new List <Record>();

            for (int y = 0; y < cellNumberY; y++)
            {
                for (int x = 0; x < cellNumberX; x++)
                {
                    var landRecord = new LAND();
                    landRecord.INTV = new INTV
                    {
                        CellX = x + moveX,
                        CellY = y + moveY,
                    };
                    landRecord.DATA = new DATA();
                    landRecord.VHGT = CreateHeightMapSubrecord(x * 64, y * 64, heightData);

                    var cellRecord = new CELL
                    {
                        NAME = new TES3Lib.Subrecords.Shared.NAME
                        {
                            EditorId = ""
                        },
                        DATA = new TES3Lib.Subrecords.CELL.DATA
                        {
                            Flags = new HashSet <TES3Lib.Enums.Flags.CellFlag>(),
                            GridX = landRecord.INTV.CellX,
                            GridY = landRecord.INTV.CellY,
                        },
                    };

                    landList.Add(cellRecord);
                    landList.Add(landRecord);
                }
            }

            var example = new TES3();

            example.Records.Add(createTES3HEader());
            example.Records.AddRange(landList);
            example.TES3Save($"{path}.esp");
        }
Example #20
0
    // Wai: I added this
    public node(CELL newHead, CELL newParent)
    {
        CELL tmp, newCell;

        this.parent = newParent;
        tmp = newHead;
        while (tmp != null)
        {
            newCell = new CELL(tmp.current);
            newCell.child = tmp.child;

            if (this.head != null)
            {
                this.head.prev = newCell;
            }
            newCell.next = this.head;
            this.head = newCell;
            tmp = tmp.next;
        }
    }
Example #21
0
        public void Test()
        {
            CELL[] cells = new CELL[HASHSIZE];
            cells[0]           = new CELL();
            cells[0].amount    = 123.45;
            cells[0].name      = "First Record";
            cells[0].precision = 50;
            cells[0].flags     = 0;
            cells[0].rank      = 0;

            cells[1]           = new CELL();
            cells[1].amount    = 9876.54;
            cells[1].name      = "Second Record";
            cells[1].precision = 3;
            cells[1].flags     = 0;
            cells[1].rank      = 1;

            cells[2]           = new CELL();
            cells[2].amount    = 24680.1357;
            cells[2].name      = "Third Record";
            cells[2].precision = 2;
            cells[2].flags     = 255;
            cells[2].rank      = 4;

            CELLTABLE ct = new CELLTABLE();

            ct.table = new IntPtr[HASHSIZE];
            for (int ix = 0; ix < HASHSIZE && cells[ix] != null; ix++)
            {
                int nSizeCell = Marshal.SizeOf(cells[ix]);
                ct.table[ix] = Marshal.AllocHGlobal(nSizeCell);
                Marshal.StructureToPtr(cells[ix], ct.table[ix], false);
            }

            int    nSizeTable = Marshal.SizeOf(ct);
            IntPtr pCellTable = Marshal.AllocHGlobal(nSizeTable);

            Marshal.StructureToPtr(ct, pCellTable, false);

            NativeFunction(pCellTable);
        }
Example #22
0
    //把鼠标位置屏幕坐标转为世界坐标


    public void AddItem(int id)
    {
        GameObject obj;

        obj = (GameObject)Instantiate(Resources.Load <GameObject>("uiitem"));
        obj.GetComponent <BagItem>().SetBagItem(id);


        for (int i = 0; i < cells.Count; i++)
        {
            if (cells[i].obj.transform.childCount == 0)
            {
                cells[i] = new CELL(cells[i].obj, 0);
            }
            if (cells[i].id == 0)
            {
                obj.transform.SetParent(cells[i].obj.transform, true);
                cells[i] = new CELL(cells[i].obj, id);
                obj.transform.localScale       = new Vector3(1, 1, 1);
                obj.transform.position         = cells[i].obj.transform.position;
                obj.transform.localEulerAngles = Vector3.zero;
                obj.transform.GetChild(0).GetComponent <Text>().text = "1";
                EventTriggerListener.Get(obj).onBeginDrag            = OnImageBeginDrag;
                EventTriggerListener.Get(obj).onDrag    = OnImageDrag;
                EventTriggerListener.Get(obj).onEndDrag = OnImageEndDrag;
                return;
            }
            else
            {
                if (cells[i].id == id)
                {
                    int tmp = int.Parse(cells[i].obj.transform.GetChild(0).GetChild(0).GetComponent <Text>().text);
                    tmp++;
                    cells[i].obj.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = tmp.ToString();
                    Destroy(obj);
                    return;
                }
            }
        }
    }
Example #23
0
        private Color SetLabelColor(CELL c)
        {
            switch (c)
            {
            case CELL.N1:
                return(Color.AliceBlue);

            case CELL.N2:
                return(Color.PapayaWhip);

            case CELL.N3:
                return(Color.PeachPuff);

            case CELL.N4:
                return(Color.Peru);

            case CELL.N5:
                return(Color.Orange);

            case CELL.N6:
                return(Color.OrangeRed);

            case CELL.N7:
                return(Color.Red);

            case CELL.N8:
                return(Color.Lime);

            case CELL.N9:
                return(Color.Gold);

            case CELL.N10:
                return(Color.Cyan);

            default:
                return(Color.Transparent);
            }
        }
Example #24
0
    // Filter out the duplicated objects.
    public virtual void filter()
    {
        CELL curr_cell;
        CELL next;

        for (curr_cell = this; curr_cell != null; curr_cell = curr_cell.next)
        {

            if (curr_cell.next != null)
            {
                next = curr_cell.next;
                while (next != null && next.current.oid == curr_cell.current.oid)
                {
                    next = next.next;
                }
                curr_cell.next = next;
                if (curr_cell.next != null)
                {
                    curr_cell.next.prev = curr_cell;
                }
            }
        }
    }
Example #25
0
        /// убрать стену
        private static void RemoveWall(CELL c1, CELL c2, CELL[,] arr)
        {
            int new_x;

            if (c1.x == c2.x)
            {
                new_x = c1.x;
            }
            else
            {
                new_x = (c1.x + c2.x) / 2;
            }
            int new_y;

            if (c1.y == c2.y)
            {
                new_y = c1.y;
            }
            else
            {
                new_y = (c1.y + c2.y) / 2;
            }
            arr[new_x, new_y].type = " ";
        }
Example #26
0
//C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#:
//ORIGINAL LINE: bool IsEnd() const
    protected bool IsEnd()
    {
        // 玉の位置を求める
        sbyte gyokux = this.gyokux[enemy];
        sbyte gyokuy = this.gyokuy[enemy];

        if (gyokux == 0)
        {
            return(false);
        }
        CELL cell = new CELL();

        if (turn == PlayerDef.FIRST)
        {
            // 玉の周囲
            if (GetCell(gyokux - 1, gyokuy, ref cell))
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (IsGyokuKinUpgrade(cell.pawn))
                if (IsGyokuKinUpgrade(cell.pawn))
                {
                    return(true);
                }
            }
            if (GetCell(gyokux + 1, gyokuy, ref cell))
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (IsGyokuKinUpgrade(cell.pawn))
                if (IsGyokuKinUpgrade(cell.pawn))
                {
                    return(true);
                }
            }
            if (GetCell(gyokux, gyokuy - 1, ref cell))
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (IsGyokuKinUpgrade(cell.pawn))
                if (IsGyokuKinUpgrade(cell.pawn))
                {
                    return(true);
                }
            }
            if (GetCell(gyokux, gyokuy + 1, ref cell))
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (IsGyokuKinUpgrade(cell.pawn) || cell.pawn == PawnDef::HU || cell.pawn == PawnDef::GIN)
                if (IsGyokuKinUpgrade(cell.pawn) || cell.pawn == PawnDef.HU || cell.pawn == PawnDef.GIN)
                {
                    return(true);
                }
            }
            if (GetCell(gyokux - 1, gyokuy - 1, ref cell))
            {
                if (cell.pawn == PawnDef.GYOKU || cell.pawn == PawnDef.GIN || cell.pawn == PawnDef.RYU)
                {
                    return(true);
                }
            }
            if (GetCell(gyokux + 1, gyokuy - 1, ref cell))
            {
                if (cell.pawn == PawnDef.GYOKU || cell.pawn == PawnDef.GIN || cell.pawn == PawnDef.RYU)
                {
                    return(true);
                }
            }
            if (GetCell(gyokux + 1, gyokuy + 1, ref cell))
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (IsGyokuKinUpgrade(cell.pawn) || cell.pawn == PawnDef::GIN)
                if (IsGyokuKinUpgrade(cell.pawn) || cell.pawn == PawnDef.GIN)
                {
                    return(true);
                }
            }
            if (GetCell(gyokux - 1, gyokuy + 1, ref cell))
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (IsGyokuKinUpgrade(cell.pawn) || cell.pawn == PawnDef::GIN)
                if (IsGyokuKinUpgrade(cell.pawn) || cell.pawn == PawnDef.GIN)
                {
                    return(true);
                }
            }

            // 桂
            if (gyokuy < BoardDef.HEIGHT)
            {
                if (GetCell(gyokux - 1, gyokuy + 2, ref cell))
                {
                    if (cell.pawn == PawnDef.KEI)
                    {
                        return(true);
                    }
                }
                if (GetCell(gyokux + 1, gyokuy + 2, ref cell))
                {
                    if (cell.pawn == PawnDef.KEI)
                    {
                        return(true);
                    }
                }
            }

            // 香
            for (int j = gyokuy + 1; j <= BoardDef.HEIGHT; j++)
            {
                if (matrix[j, gyokux].player == PlayerDef.NONE)
                {
                    continue;
                }
                if (matrix[j, gyokux].player == enemy)
                {
                    break;
                }
                if (matrix[j, gyokux].pawn == PawnDef.KYOH)
                {
                    return(true);
                }
                break;
            }
        }
        else
        {
            // 玉の周囲
            if (GetCell(gyokux - 1, gyokuy, ref cell))
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (IsGyokuKinUpgrade(cell.pawn))
                if (IsGyokuKinUpgrade(cell.pawn))
                {
                    return(true);
                }
            }
            if (GetCell(gyokux + 1, gyokuy, ref cell))
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (IsGyokuKinUpgrade(cell.pawn))
                if (IsGyokuKinUpgrade(cell.pawn))
                {
                    return(true);
                }
            }
            if (GetCell(gyokux, gyokuy - 1, ref cell))
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (IsGyokuKinUpgrade(cell.pawn) || cell.pawn == PawnDef::HU || cell.pawn == PawnDef::GIN)
                if (IsGyokuKinUpgrade(cell.pawn) || cell.pawn == PawnDef.HU || cell.pawn == PawnDef.GIN)
                {
                    return(true);
                }
            }
            if (GetCell(gyokux, gyokuy + 1, ref cell))
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (IsGyokuKinUpgrade(cell.pawn))
                if (IsGyokuKinUpgrade(cell.pawn))
                {
                    return(true);
                }
            }
            if (GetCell(gyokux - 1, gyokuy - 1, ref cell))
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (IsGyokuKinUpgrade(cell.pawn) || cell.pawn == PawnDef::GIN)
                if (IsGyokuKinUpgrade(cell.pawn) || cell.pawn == PawnDef.GIN)
                {
                    return(true);
                }
            }
            if (GetCell(gyokux + 1, gyokuy - 1, ref cell))
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (IsGyokuKinUpgrade(cell.pawn) || cell.pawn == PawnDef::GIN)
                if (IsGyokuKinUpgrade(cell.pawn) || cell.pawn == PawnDef.GIN)
                {
                    return(true);
                }
            }
            if (GetCell(gyokux + 1, gyokuy + 1, ref cell))
            {
                if (cell.pawn == PawnDef.GYOKU || cell.pawn == PawnDef.GIN || cell.pawn == PawnDef.RYU)
                {
                    return(true);
                }
            }
            if (GetCell(gyokux - 1, gyokuy + 1, ref cell))
            {
                if (cell.pawn == PawnDef.GYOKU || cell.pawn == PawnDef.GIN || cell.pawn == PawnDef.RYU)
                {
                    return(true);
                }
            }

            // 桂
            if (2 <= gyokuy)
            {
                if (GetCell(gyokux - 1, gyokuy - 2, ref cell))
                {
                    if (cell.pawn == PawnDef.KEI)
                    {
                        return(true);
                    }
                }
                if (GetCell(gyokux + 1, gyokuy - 2, ref cell))
                {
                    if (cell.pawn == PawnDef.KEI)
                    {
                        return(true);
                    }
                }
            }

            // 香
            for (int j = gyokuy - 1; 0 < j; j--)
            {
                if (matrix[j, gyokux].player == PlayerDef.NONE)
                {
                    continue;
                }
                if (matrix[j, gyokux].player == enemy)
                {
                    break;
                }
                if (matrix[j, gyokux].pawn == PawnDef.KYOH)
                {
                    return(true);
                }
                break;
            }
        }

        {
            int i;
            int j;
            // 飛龍
            i = gyokux + 1;
            while (true)
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (matrix[gyokuy][i].player == turn && Down(matrix[gyokuy][i].pawn) == PawnDef::HI)
                if (matrix[gyokuy, i].player == turn && Down(matrix[gyokuy, i].pawn) == PawnDef.HI)
                {
                    return(true);
                }
                if (matrix[gyokuy, i].player != PlayerDef.NONE)
                {
                    break;
                }
                i++;
            }
            i = gyokux - 1;
            while (true)
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (matrix[gyokuy][i].player == turn && Down(matrix[gyokuy][i].pawn) == PawnDef::HI)
                if (matrix[gyokuy, i].player == turn && Down(matrix[gyokuy, i].pawn) == PawnDef.HI)
                {
                    return(true);
                }
                if (matrix[gyokuy, i].player != PlayerDef.NONE)
                {
                    break;
                }
                i--;
            }
            j = gyokuy + 1;
            while (true)
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (matrix[j][gyokux].player == turn && Down(matrix[j][gyokux].pawn) == PawnDef::HI)
                if (matrix[j, gyokux].player == turn && Down(matrix[j, gyokux].pawn) == PawnDef.HI)
                {
                    return(true);
                }
                if (matrix[j, gyokux].player != PlayerDef.NONE)
                {
                    break;
                }
                j++;
            }
            j = gyokuy - 1;
            while (true)
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (matrix[j][gyokux].player == turn && Down(matrix[j][gyokux].pawn) == PawnDef::HI)
                if (matrix[j, gyokux].player == turn && Down(matrix[j, gyokux].pawn) == PawnDef.HI)
                {
                    return(true);
                }
                if (matrix[j, gyokux].player != PlayerDef.NONE)
                {
                    break;
                }
                j--;
            }

            // 角馬
            i = gyokux + 1;
            j = gyokuy + 1;
            while (true)
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (matrix[j][i].player == turn && Down(matrix[j][i].pawn) == PawnDef::KAKU)
                if (matrix[j, i].player == turn && Down(matrix[j, i].pawn) == PawnDef.KAKU)
                {
                    return(true);
                }
                if (matrix[j, i].player != PlayerDef.NONE)
                {
                    break;
                }
                i++;
                j++;
            }
            i = gyokux - 1;
            j = gyokuy + 1;
            while (true)
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (matrix[j][i].player == turn && Down(matrix[j][i].pawn) == PawnDef::KAKU)
                if (matrix[j, i].player == turn && Down(matrix[j, i].pawn) == PawnDef.KAKU)
                {
                    return(true);
                }
                if (matrix[j, i].player != PlayerDef.NONE)
                {
                    break;
                }
                i--;
                j++;
            }
            i = gyokux - 1;
            j = gyokuy - 1;
            while (true)
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (matrix[j][i].player == turn && Down(matrix[j][i].pawn) == PawnDef::KAKU)
                if (matrix[j, i].player == turn && Down(matrix[j, i].pawn) == PawnDef.KAKU)
                {
                    return(true);
                }
                if (matrix[j, i].player != PlayerDef.NONE)
                {
                    break;
                }
                i--;
                j--;
            }
            i = gyokux + 1;
            j = gyokuy - 1;
            while (true)
            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: if (matrix[j][i].player == turn && Down(matrix[j][i].pawn) == PawnDef::KAKU)
                if (matrix[j, i].player == turn && Down(matrix[j, i].pawn) == PawnDef.KAKU)
                {
                    return(true);
                }
                if (matrix[j, i].player != PlayerDef.NONE)
                {
                    break;
                }
                i++;
                j--;
            }
        }

        return(false);
    }
Example #27
0
    public MoveList GetMoveList(MoveList moveList)
    {
        moveList.clear();

        uchar lineMax = new uchar();
        uchar lineMin = new uchar();
        uchar lineTop = new uchar();
        uchar lineMid = new uchar();

        if (turn == PlayerDef.FIRST)
        {
            lineMax = 3;
            lineMin = 1;
            lineTop = 1;
            lineMid = 2;
        }
        else
        {
            lineMax = BoardDef.HEIGHT;
            lineMin = BoardDef.HEIGHT - 2;
            lineTop = BoardDef.HEIGHT;
            lineMid = BoardDef.HEIGHT - 1;
        }
        int forward = -1;

        if (turn == PlayerDef.SECOND)
        {
            forward = +1;
        }
        for (sbyte j = 1; j <= BoardDef.HEIGHT; j++)
        {
            for (sbyte i = 1; i <= BoardDef.WIDTH; i++)
            {
                CELL cell = matrix[(uchar)j, (uchar)i];
                if (cell.player == enemy)
                {
                    continue;
                }
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: Pawn pawn = cell.pawn;
                Pawn pawn = cell.pawn;
                int  x;
                int  y;
                switch (pawn)
                {
                case PawnDef.HU:
                    x = i;
                    y = j + forward;
                    if (y == lineTop || y == lineMid)
                    {
                        AddMove(PawnDef.NONE, i, j, x, y, true, moveList);
                    }
                    else
                    {
                        AddMove(PawnDef.NONE, i, j, x, y, false, moveList);
                        if (lineMin <= y && y <= lineMax)
                        {
                            AddMove(PawnDef.NONE, i, j, x, y, true, moveList);
                        }
                    }
                    break;

                case PawnDef.KYOH:
                    y = j + forward;
                    for (bool ret = true; 0 < y && y <= BoardDef.HEIGHT && ret; y += forward)
                    {
                        if (y == lineTop || y == lineMid)
                        {
                            ret &= AddMove(PawnDef.NONE, i, j, i, y, true, moveList);
                        }
                        else
                        {
                            ret &= AddMove(PawnDef.NONE, i, j, i, y, false, moveList);
                            if (lineMin <= y && y <= lineMax)
                            {
                                ret &= AddMove(PawnDef.NONE, i, j, i, y, true, moveList);
                            }
                        }
                    }
                    break;

                case PawnDef.KEI:
                    x = i - 1;
                    y = j - forward - forward;
                    if (0 < y && y < BoardDef.HEIGHT + 1)
                    {
                        if (y != lineTop && y != lineMid)
                        {
                            AddMove(PawnDef.NONE, i, j, x, y, false, moveList);
                        }
                        if (lineMin <= y && y <= lineMax)
                        {
                            AddMove(PawnDef.NONE, i, j, x, y, true, moveList);
                        }
                    }
                    break;

                case PawnDef.GIN:
                    AddMove(PawnDef.NONE, i, j, i - 1, j + forward, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i, j + forward, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i + 1, j + forward, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i - 1, j - forward, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i + 1, j - forward, false, moveList);
                    if ((lineMin <= (j + forward) && (j + forward) <= lineMax) || (lineMin <= j && j <= lineMax))
                    {
                        AddMove(PawnDef.NONE, i, j, i - 1, j + forward, true, moveList);
                        AddMove(PawnDef.NONE, i, j, i, j + forward, true, moveList);
                        AddMove(PawnDef.NONE, i, j, i + 1, j + forward, true, moveList);
                        AddMove(PawnDef.NONE, i, j, i - 1, j - forward, true, moveList);
                        AddMove(PawnDef.NONE, i, j, i + 1, j - forward, true, moveList);
                    }
                    break;

                case PawnDef.KIN:
                case PawnDef.HUN:
                case PawnDef.KYOHN:
                case PawnDef.KEIN:
                case PawnDef.GINN:
                    AddMove(PawnDef.NONE, i, j, i - 1, j + forward, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i, j + forward, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i + 1, j + forward, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i - 1, j, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i + 1, j, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i, j - forward, false, moveList);
                    break;

                case PawnDef.KAKU:
                    x = i + 1;
                    y = j + 1;
                    while (true)
                    {
                        if ((lineMin <= y && y <= lineMax) || (lineMin <= j && j <= lineMax))
                        {
                            if (AddMove(PawnDef.NONE, i, j, x, y, true, moveList) == false)
                            {
                                break;
                            }
                        }
                        else if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        x++;
                        y++;
                    }
                    x = i + 1;
                    y = j - 1;
                    while (true)
                    {
                        if ((lineMin <= y && y <= lineMax) || (lineMin <= j && j <= lineMax))
                        {
                            if (AddMove(PawnDef.NONE, i, j, x, y, true, moveList) == false)
                            {
                                break;
                            }
                        }
                        else if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        x++;
                        y -= 1;
                    }
                    x = i - 1;
                    y = j + 1;
                    while (true)
                    {
                        if ((lineMin <= y && y <= lineMax) || (lineMin <= j && j <= lineMax))
                        {
                            if (AddMove(PawnDef.NONE, i, j, x, y, true, moveList) == false)
                            {
                                break;
                            }
                        }
                        else if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        x -= 1;
                        y++;
                    }
                    x = i - 1;
                    y = j - 1;
                    while (true)
                    {
                        if ((lineMin <= y && y <= lineMax) || (lineMin <= j && j <= lineMax))
                        {
                            if (AddMove(PawnDef.NONE, i, j, x, y, true, moveList) == false)
                            {
                                break;
                            }
                        }
                        else if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        x -= 1;
                        y -= 1;
                    }
                    break;

                case PawnDef.UMA:
                    x = i + 1;
                    y = j + 1;
                    while (true)
                    {
                        if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        x++;
                        y++;
                    }
                    x = i + 1;
                    y = j - 1;
                    while (true)
                    {
                        if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        x++;
                        y -= 1;
                    }
                    x = i - 1;
                    y = j + 1;
                    while (true)
                    {
                        if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        x -= 1;
                        y++;
                    }
                    x = i - 1;
                    y = j - 1;
                    while (true)
                    {
                        if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        x -= 1;
                        y -= 1;
                    }
                    AddMove(PawnDef.NONE, i, j, i + 1, j, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i - 1, j, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i, j + 1, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i, j - 1, false, moveList);
                    break;

                case PawnDef.HI:
                    x = i + 1;
                    y = j;
                    while (true)
                    {
                        if (lineMin <= j && j <= lineMax)
                        {
                            if (AddMove(PawnDef.NONE, i, j, x, y, true, moveList) == false)
                            {
                                break;
                            }
                        }
                        else if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        x++;
                    }
                    x = i - 1;
                    y = j;
                    while (true)
                    {
                        if (lineMin <= j && j <= lineMax)
                        {
                            if (AddMove(PawnDef.NONE, i, j, x, y, true, moveList) == false)
                            {
                                break;
                            }
                        }
                        else if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        x -= 1;
                    }
                    x = i;
                    y = j + 1;
                    while (true)
                    {
                        if ((lineMin <= y && y <= lineMax) || (lineMin <= j && j <= lineMax))
                        {
                            if (AddMove(PawnDef.NONE, i, j, x, y, true, moveList) == false)
                            {
                                break;
                            }
                        }
                        else if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        y++;
                    }
                    x = i;
                    y = j - 1;
                    while (true)
                    {
                        if ((lineMin <= y && y <= lineMax) || (lineMin <= j && j <= lineMax))
                        {
                            if (AddMove(PawnDef.NONE, i, j, x, y, true, moveList) == false)
                            {
                                break;
                            }
                        }
                        else if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        y -= 1;
                    }
                    break;

                case PawnDef.RYU:
                    x = i + 1;
                    y = j;
                    while (true)
                    {
                        if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        x++;
                    }
                    x = i - 1;
                    y = j;
                    while (true)
                    {
                        if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        x -= 1;
                    }
                    x = i;
                    y = j + 1;
                    while (true)
                    {
                        if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        y++;
                    }
                    x = i;
                    y = j - 1;
                    while (true)
                    {
                        if (AddMove(PawnDef.NONE, i, j, x, y, false, moveList) == false)
                        {
                            break;
                        }
                        y -= 1;
                    }
                    AddMove(PawnDef.NONE, i, j, i + 1, j + 1, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i - 1, j + 1, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i + 1, j - 1, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i - 1, j - 1, false, moveList);
                    break;

                case PawnDef.GYOKU:
                    AddMove(PawnDef.NONE, i, j, i - 1, j - 1, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i, j - 1, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i + 1, j - 1, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i - 1, j, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i + 1, j, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i - 1, j + 1, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i, j + 1, false, moveList);
                    AddMove(PawnDef.NONE, i, j, i + 1, j + 1, false, moveList);
                    break;

                default:
                    // 空きだったら打ち
                    for (uchar roll = 0; roll < PawnDef.CAPTURE_MAX; roll++)
                    {
                        if (captured[turn, roll] == 0)
                        {
                            continue;
                        }
                        switch (roll)
                        {
                        case PawnDef.HU:
                            if (j != lineTop)
                            {
                                uchar k = new uchar();
                                for (k = 1; k <= BoardDef.HEIGHT; k++)
                                {
                                    if (matrix[k, i].player == turn && matrix[k, i].pawn == PawnDef.HU)
                                    {
                                        break;
                                    }
                                }
                                if (BoardDef.HEIGHT < k)
                                {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: AddMove(roll, 0, 0, i, j, false, moveList);
                                    AddMove(roll, 0, 0, i, j, false, moveList);
                                }
                            }
                            break;

                        case PawnDef.KYOH:
                            if (j != lineTop)
                            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: AddMove(roll, 0, 0, i, j, false, moveList);
                                AddMove(roll, 0, 0, i, j, false, moveList);
                            }
                            break;

                        case PawnDef.KEI:
                            if (j != lineTop && j != lineMid)
                            {
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: AddMove(roll, 0, 0, i, j, false, moveList);
                                AddMove(roll, 0, 0, i, j, false, moveList);
                            }
                            break;

                        case PawnDef.GIN:
                        case PawnDef.KIN:
                        case PawnDef.KAKU:
                        case PawnDef.HI:
//C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
//ORIGINAL LINE: AddMove(roll, 0, 0, i, j, false, moveList);
                            AddMove(roll, 0, 0, i, j, false, moveList);
                            break;

                        default:
                            break;
                        }
                    }

                    break;
                }
            }
        }

//C++ TO C# CONVERTER TODO TASK: C# does not allow setting or comparing #define constants:
#if USE_PRIORITY != PRIORITY_NONE
        moveList.sort();
#endif
        return(moveList);
    }
Example #28
0
    // Concate 2 nodes (MBR list) together
    internal virtual void concate(node concat_node)
    {
        CELL tail;

        if (this.head == null)
        {
            this.head = concat_node.head;
            return ;
        }
        if (concat_node.head == null)
            return ;

        tail = this.head;
        while (tail.next != null)
            tail = tail.next;
        tail.next = concat_node.head;
        concat_node.head.prev = tail;
    }
Example #29
0
    // insert new node to subtree of this node
    // return number of nodes inserted
    internal virtual Split_info insert_obj(MBR obj, int fillfactor)
    {
        int counter = 0; // number of nodes inserted
        Split_info sp;
        CELL tmp;
        MBR tmpmbr;

        sp = new Split_info();
        // try to insert data object to children
        for (CELL curr_cell = head; curr_cell != null; curr_cell = curr_cell.next)
        {
            // check children for overlapping with data object
            if (curr_cell.current.check_overlap(obj.mbr) == 1 && curr_cell.current.oid == 0)
            {
                // check if curr_cell is data cell
                if (curr_cell.child != null)
                {
                    // non-data node
                    // insert into subtree
                    sp = curr_cell.child.insert_obj(obj, fillfactor);
                    if (sp.newnode != null)
                    {
                        curr_cell.current.mbr = sp.mbr2;
                        if (sp.xcut >= 0 && (curr_cell.current.cutxh == - 1 || sp.xcut < curr_cell.current.cutxh))
                            curr_cell.current.cutxh = sp.xcut;
                        if (sp.ycut >= 0 && (curr_cell.current.cutyh == - 1 || sp.ycut < curr_cell.current.cutyh))
                            curr_cell.current.cutyh = sp.ycut;
                        curr_cell.resize();
                        tmpmbr = new MBR(sp.mbr);
                        this.insert(tmpmbr);
                        this.head.child = sp.newnode;
                        this.head.child.parent = this.head;
                        this.head.current.cutxl = sp.cutxl;
                        this.head.current.cutyl = sp.cutyl;
                        this.head.current.cutxh = sp.cutxh;
                        this.head.current.cutyh = sp.cutyh;

                        if (sp.xcut >= 0 && (this.head.current.cutxl == - 1 || sp.xcut > this.head.current.cutxl))
                            this.head.current.cutxl = sp.xcut;
                        if (sp.ycut >= 0 && (this.head.current.cutyl == - 1 || sp.ycut > this.head.current.cutyl))
                            this.head.current.cutyl = sp.ycut;
                        this.head.resize();
                    }
                    else
                    {
                        curr_cell.resize();
                    }
                    counter++;
                }
            }
        }

        sp = new Split_info();
        if (counter == 0)
        {
            // attach new child to this node
            attach(obj);
        }
        if (this.getlength() > fillfactor)
        {
            sp = this.splitnode(fillfactor);
        }
        if (this.parent != null)
        {
            this.parent.resize();
        }
        return sp;
    }
Example #30
0
    private void SelectPawn(int x, int y)
    {
        CELL cell = board.GetCell(x, y);

        if (step == "idle")
        {
            board.GetMoveList(moveListTmp);
            List <Move> moveList = new List <Move>();

            while (0 < moveListTmp.size())
            {
                Move move = moveListTmp.front();

                if (move.from.x == x && move.from.y == y)
                {
                    moveList.Add(move);
                }

                moveListTmp.pop_front();
            }

            if (moveList.Count == 0)
            {
                return;
            }

            selectMove.from.x    = (uchar)x;
            selectMove.from.y    = (uchar)y;
            selectMove.from.pawn = cell.pawn;

            foreach (Move moveTmp in moveList)
            {
                GameObject highlight = IndexToCell(moveTmp.to.x, moveTmp.to.y);
                highlight.GetComponent <MeshRenderer>().material.color = new Color(1.0f, 1.0f, 1.0f, 0.5f);
            }

            step = "select";
        }
        else if (step == "select")
        {
            board.GetMoveList(moveListTmp);
            List <Move> moveList = new List <Move>();

            if (selectMove.reserve == PawnDef.NONE)
            {
                while (0 < moveListTmp.size())
                {
                    Move move = moveListTmp.front();

                    if (move.from.x == selectMove.from.x && move.from.y == selectMove.from.y && move.to.x == x && move.to.y == y)
                    {
                        moveList.Add(move);
                    }

                    moveListTmp.pop_front();
                }
            }
            else
            {
                while (0 < moveListTmp.size())
                {
                    Move move = moveListTmp.front();

                    if (move.reserve == selectMove.reserve && move.to.x == x && move.to.y == y)
                    {
                        moveList.Add(move);
                    }

                    moveListTmp.pop_front();
                }
            }

            selectMove.to.x    = (uchar)x;
            selectMove.to.y    = (uchar)y;
            selectMove.to.pawn = cell.pawn;

            if (1 < moveList.Count)
            {
                UpgradeObject.SetActive(true);
                step = "upgrade";
                return;
            }

            if (moveList.Count == 0)
            {
                // 選択キャンセル
                selectMove = new Move(GlobalMembers.MOVE_ZERO);
                ResetHighlight();
                step = "idle";
                return;
            }

            if (moveList[0].upgrade == true)
            {
                int top = 0;
                if (board.GetPlayer() == PlayerDef.SECOND)
                {
                    top = BoardDef.HEIGHT;
                }
                if ((selectMove.from.pawn == PawnDef.HU && selectMove.to.y != top) ||
                    (selectMove.from.pawn == PawnDef.KYOH && selectMove.to.y != top) ||
                    selectMove.from.pawn == PawnDef.KAKU || selectMove.from.pawn == PawnDef.HI
                    )
                {
                    // 成らない事もできる
                    UpgradeObject.SetActive(true);
                    step = "upgrade";
                    return;
                }
            }

            Debug.Log("move");
            selectMove.upgrade = moveList[0].upgrade;
            BoardMove(selectMove);
            TurnEnd();
        }
    }
        public List <CellRayTracingModel> interfeCellGen(DataRange dataRange)
        {
            List <CellRayTracingModel> res = new List <CellRayTracingModel>();
            Point pMin = new Point();

            pMin.X = dataRange.minLongitude;
            pMin.Y = dataRange.minLatitude;
            pMin.Z = 0;
            LTE.Utils.PointConvertByProj.Instance.GetProjectPoint(pMin);

            Point pMax = new Point();

            pMax.X = dataRange.maxLongitude;
            pMax.Y = dataRange.maxLatitude;
            pMax.Z = 0;
            LTE.Utils.PointConvertByProj.Instance.GetProjectPoint(pMax);

            double      maxBh       = 90;   //最大建筑物高度
            int         radius      = 1200; //干扰源覆盖半径
            String      tarBaseName = dataRange.infAreaId + "_";
            List <CELL> cells       = new List <CELL>();
            int         batch       = 10;
            int         cnt         = 0;

            //计算测试数据总数
            int    lx       = (int)Math.Ceiling((pMax.X - pMin.X) / dataRange.tarGridX);
            int    ly       = (int)Math.Ceiling((pMax.Y - pMin.Y) / dataRange.tarGridY);
            int    lz       = (int)Math.Ceiling(maxBh / dataRange.tarGridH);
            long   uidBatch = long.Parse((lx * ly * lz).ToString());
            String dbName   = "CELL";
            int    initOff  = 1500000;
            int    uid      = (int)UIDHelper.GenUIdByRedis(dbName, uidBatch) + initOff;

            for (double x = pMin.X; x < pMax.X; x += dataRange.tarGridX)
            {
                for (double y = pMin.Y; y < pMax.Y; y += dataRange.tarGridY)
                {
                    for (double z = 30; z <= maxBh; z += 30)
                    {
                        cnt++;
                        Random r    = new Random(uid);
                        CELL   cELL = new CELL();
                        cELL.ID             = uid;
                        cELL.CellName       = dataRange.infAreaId + "_" + uid;
                        cELL.Altitude       = 13;
                        cELL.AntHeight      = (decimal)z;
                        cELL.x              = (decimal)x;
                        cELL.y              = (decimal)y;
                        cELL.CI             = uid;
                        cELL.eNodeB         = uid;
                        cELL.EIRP           = 32;
                        cELL.Azimuth        = 0;
                        cELL.Tilt           = r.Next(4, 16); //下倾角范围4~16之间随机取
                        cELL.EARFCN         = 63;
                        cELL.CoverageRadius = radius;
                        cells.Add(cELL);

                        CellRayTracingModel rayCell = new CellRayTracingModel();
                        rayCell.cellName         = cELL.CellName;
                        rayCell.reflectionNum    = 3;
                        rayCell.diffPointsMargin = 5;
                        rayCell.diffractionNum   = 2;
                        rayCell.threadNum        = 3;
                        rayCell.incrementAngle   = 180;
                        rayCell.computeIndoor    = false;
                        rayCell.computeDiffrac   = true;
                        rayCell.distance         = radius;
                        res.Add(rayCell);

                        uid++;
                    }
                    if (res.Count >= batch)
                    {
                        IbatisHelper.ExecuteInsert("CELL_BatchInsert", cells);
                        cells.Clear();
                    }
                }
            }
            if (cells.Count > 0)
            {
                IbatisHelper.ExecuteInsert("CELL_BatchInsert", cells);
            }

            return(res);
        }
Example #32
0
 internal virtual void recur_draw(CELL ptr, int color)
 {
     while (ptr != null)
     {
         if (ptr.current.oid == 0)
         {
             recur_draw(ptr.child.head, color + 1);
             draw_node(ptr.current.mbr, color);
         }
         else
         {
             draw_child(ptr.current.mbr, color);
         }
         ptr = ptr.next;
     }
 }
Example #33
0
    internal virtual void button3_MousePress(System.Object event_sender, System.Windows.Forms.MouseEventArgs event_Renamed)
    {
        // to do: code goes here.
        RECT rec;
        MBR obj;
        node result;
        CELL ptr;
        System.String text1, text2, text3, text4, text5;
        System.Single t1, t2, t3, t4;
        System.Int32 t5;

        result = new node();
        text1 = textField1.Text;
        text2 = textField2.Text;
        text3 = textField3.Text;
        text4 = textField4.Text;
        text5 = textField5.Text;

        textField1.Text = "";
        textField2.Text = "";
        textField3.Text = "";
        textField4.Text = "";
        textField5.Text = "";

        if (text1.Length == 0 || text2.Length == 0 || text3.Length == 0 || text4.Length == 0 || text5.Length != 0)
        {
            textArea1.ReadOnly = !true;
            textArea1.AppendText("Incorrect input\n");
            textArea1.ReadOnly = !false;
            return ;
        }
        else
        {
            t1 = System.Single.Parse(text1);
            t2 = System.Single.Parse(text2);
            t3 = System.Single.Parse(text3);
            t4 = System.Single.Parse(text4);
            //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Float.floatValue' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
            rec = new RECT((float) t1, (float) t2, (float) t3, (float) t4);

            result = root.search(rec);
        }

        textArea1.AppendText("Search result :\n");
        ptr = new CELL();
        ptr = result.head;
        while (ptr != null)
        {
            textArea1.AppendText("Object " + ptr.current.oid + "\n");
            ptr = ptr.next;
        }
    }
Example #34
0
    // attach new child to node
    internal virtual void attach(MBR obj)
    {
        CELL new_cell; // new cell inserted to list

        // create new cell
        new_cell = new CELL(obj);

        // insert into list of cells
        new_cell.next = head;
        if (head == null)
        {
            head = new_cell;
        }
        else
        {
            head.prev = new_cell;
            head = new_cell;
        }
    }
Example #35
0
    // Function called by to redistribute nodes in the list
    // by Nelson
    internal virtual Split_info redistribute_node(int ff, Cut_info cut)
    {
        node tmp, tmp2;
        Split_info info, info2;
        MBR tmpmbr;
        CELL ptr;
        RECT R1, R2, ns1, ns2;
        RECT parent, par2;
        int check1, check2;

        info = new Split_info();
        parent = new RECT();
        if (this.parent != null)
        {
            parent.low[0] = this.parent.current.mbr.low[0];
            parent.low[1] = this.parent.current.mbr.low[1];
            parent.high[0] = this.parent.current.mbr.high[0];
            parent.high[1] = this.parent.current.mbr.high[1];
        }
        else
        {
            parent = this.getnodesize();
        }
        par2 = this.getnodesize();
        tmp = new node();
        tmp2 = new node();
        tmp.parent = this.parent;
        tmp2.parent = this.parent;
        if (cut.dir == 'x')
        {
            R1 = new RECT(parent.low[0], parent.low[1], cut.cut, parent.high[1]);
            R2 = new RECT(cut.cut, parent.low[1], parent.high[0], parent.high[1]);
            info.xcut = cut.cut;
        }
        else
        {
            R1 = new RECT(parent.low[0], parent.low[1], parent.high[0], cut.cut);
            R2 = new RECT(parent.low[0], cut.cut, parent.high[0], parent.high[1]);
            info.ycut = cut.cut;
        }

        ptr = this.head;
        while (ptr != null)
        {
            check1 = ptr.current.check_overlap(R1);
            check2 = ptr.current.check_overlap(R2);

            if (check1 == 1 && check2 != 1)
            {
                tmp.insert(ptr.current);
                tmp.head.child = ptr.child;
                if (tmp.head.child != null)
                    tmp.head.child.parent = tmp.head;
            }
            else if (check1 != 1 && check2 == 1)
            {
                tmp2.insert(ptr.current);
                tmp2.head.child = ptr.child;
                if (tmp2.head.child != null)
                    tmp2.head.child.parent = tmp2.head;
            }
            else
            {
                if (ptr.child != null)
                {
                    info2 = ptr.child.splitnode(ff, cut);
                    tmp.insert(ptr.current);
                    tmp.head.child = ptr.child;
                    tmp.head.child.parent = tmp.head;

                    tmpmbr = new MBR(info2.mbr);
                    tmp2.insert(tmpmbr);
                    tmp2.head.child = info2.newnode;
                    tmp2.head.child.parent = tmp2.head;
                }
                else
                {
                    tmp.insert(ptr.current);
                    tmp.head.child = ptr.child;
                    tmp.parent = this.parent;

                    tmp2.insert(ptr.current);
                    tmp2.head.child = ptr.child;
                    tmp2.parent = this.parent;
                }
            }
            ptr = ptr.next;
        }
        this.head = tmp.head;
        if (this.parent != null)
        {
            this.parent.current.mbr = R1;
            info.cutxl = this.parent.current.cutxl;
            info.cutyl = this.parent.current.cutyl;
            info.cutxh = this.parent.current.cutxh;
            info.cutyh = this.parent.current.cutyh;
        }
        info.mbr2 = R1;
        info.mbr = R2;
        info.newnode = tmp2;
        return info;
    }
Example #36
0
    // Partition.  	return partition_info, a new node R and a list of
    //         	MBRs in S
    internal virtual Partition_info partition(node N, int fillfactor)
    {
        Partition_info result;
        Cut_info xsweep, ysweep;
        Cut_info select;
        CELL tmp, cur, cur_cell;

        result = new Partition_info();
        result.R.parent = N.parent;
        if (N.getlength() <= fillfactor)
        {
            result.R.head = N.head;
            return result;
        }
        xsweep = N.sweep('x', fillfactor);
        ysweep = N.sweep('y', fillfactor);

        cur = new CELL();
        select = new Cut_info();
        if (xsweep.cost == - 1 && ysweep.cost == - 1)
        {
            System.Console.Out.WriteLine("ERROR : Cannot Split node!!");
            System.Environment.Exit(1);
        }
        else if (xsweep.cost == - 1 || (xsweep.cost > ysweep.cost && ysweep.cost != - 1))
        {
            select = ysweep;
            result.xy = 'y';
        }
        else
        {
            select = xsweep;
            result.xy = 'x';
        }

        //	create the new node R
        cur = select.S1.head;

        while (cur != null)
        {
            cur_cell = new CELL(cur.current);

            //	find the child node
            tmp = N.head;
            if (tmp != null)
            {
                while (tmp.current.mbr.low[0] != cur_cell.current.mbr.low[0] || tmp.current.mbr.low[1] != cur_cell.current.mbr.low[1] || tmp.current.mbr.high[0] != cur_cell.current.mbr.high[0] || tmp.current.mbr.high[1] != cur_cell.current.mbr.high[1])
                {
                    tmp = tmp.next;
                }

                cur_cell.child = tmp.child;
                cur_cell.current = tmp.current;

                //      insert into the node
                if (result.R.head != null)
                {
                    result.R.head.prev = cur_cell;
                    cur_cell.next = result.R.head;
                }
                result.R.head = cur_cell;
            }
            cur = cur.next;
        }

        //      create the list S
        cur = select.S2.head;
        while (cur != null)
        {
            cur_cell = new CELL(cur.current);
            cur_cell.child = cur.child;
            result.S.insertList(cur_cell);
            cur = cur.next;
        }
        if (result.xy == 'x')
        {
            result.xcut = select.cut;
        }
        else if (result.xy == 'y')
        {
            result.ycut = select.cut;
        }
        return result;
    }
Example #37
0
    // ofcreate creats an overflown node.
    internal virtual void ofcreate(int ff, int oid)
    {
        int counter;
        int total;
        int curr_id;

        total = 2 * ff + 1;
        curr_id = oid;
        this.head = null;

        // Create a number of cells and insert them to the cell list.

        for (counter = 0; counter < total; counter++)
        {

            MBR temp_mbr = new MBR(curr_id);
            CELL temp_cell = new CELL(temp_mbr);

            temp_cell.next = this.head;
            if (this.head == null)
            {
                this.head = temp_cell;
            }
            else
            {
                this.head.prev = temp_cell;
                this.head = temp_cell;
            }

            curr_id++;
        }
    }
Example #38
0
    internal CELL head; // Head of a list of MBRs

    #endregion Fields

    #region Constructors

    // constructor
    public LIST()
    {
        this.head = null;
    }
Example #39
0
 public static CELL Next(CELL val)
 {
     return((CELL)(((int)val << 1)));
 }
Example #40
0
    //  Delete the first occurence of W from a cell
    internal virtual void delOneCell(CELL C)
    {
        if (C == this.head)
            this.head = C.next;
        else
            C.prev.next = C.next;

        if (C.next != null)
            C.next.prev = C.prev;

        C.next = null;
        C.prev = null;
    }
Example #41
0
    // Use this for initialization
    void Start()
    {
        ai = new Ai();
        ai.AddWorker(ref ai);

        /*
         * string str = @"h18 y04 e04 g04 u00 r00 k03
         * . . . . . . . . .
         * . . . . . .r_ . .
         * . . . . . .U_ .o_
         * . . . . . . .^r .
         * . . . . . .^U . .
         * . . . . . . . . .
         * . . . . . . . . .
         * . . . . . . . . .
         * . . . . . . . . .
         * h00 y00 e00 g00 u00 r00 k01
         * first";
         */
        /*
         * string str = @"h16 y02 e04 g04 u02 r01 k03
         * . . . . .^R . .y_
         * . . . . . . .o_h_
         * . . . . . . . . .
         * . . . . . . .h_ .
         * . . . . . . .^h .
         * . . . . . .^y . .
         * . . . . . . . . .
         * . . . . . . . . .
         * . . . . . . . . .
         * h00 y00 e00 g00 u00 r00 k01
         * first";
         */
        string str = @"h16 y02 e04 g04 u02 r01 k03
 . . . . . . .^Ry_
 . . . . . . . .h_
 . . . . . . . .o_
 . . . . . . .h_ .
 . . . . . . .^h .
 . . . . . .^y . .
 . . . . . . . . .
 . . . . . . . . .
 . . . . . . . . .
h00 y00 e00 g00 u00 r00 k01
first";

        Debug.Log(str);
        board = new Board();
        board.Init(str);

        for (int j = 1; j <= BoardDef.HEIGHT; j++)
        {
            for (int i = 1; i <= BoardDef.WIDTH; i++)
            {
                float x = cellSize * (i - 1);
                float z = cellSize * -(j - 1);
                x -= cellSize * BoardDef.WIDTH / 2.0f - cellSize / 2.0f;
                z += cellSize * BoardDef.HEIGHT / 2.0f - cellSize / 2.0f;
                GameObject cell = Instantiate(CellPrefab, new Vector3(x, 0.01f, z), Quaternion.identity) as GameObject;
                cell.name             = "Cell(" + i + "," + j + ")";
                cell.transform.parent = CellsParent.transform;
            }
        }

        for (int j = 1; j <= BoardDef.HEIGHT; j++)
        {
            for (int i = 1; i <= BoardDef.WIDTH; i++)
            {
                CELL cell = board.GetCell(i, j);
                if (cell.player != PlayerDef.FIRST && cell.player != PlayerDef.SECOND)
                {
                    continue;
                }
                CreatePawn(cell.player, cell.pawn, i, j);
            }
        }

        Vector3 target;

        for (int i = 0; i < PawnDef.CAPTURE_MAX; i++)
        {
            float x = cellSize * (i + BoardDef.WIDTH - PawnDef.CAPTURE_MAX);
            float z = cellSize * -(BoardDef.HEIGHT + 1.5f - 1);
            x -= cellSize * BoardDef.WIDTH / 2.0f - cellSize / 2.0f;
            z += cellSize * BoardDef.HEIGHT / 2.0f - cellSize / 2.0f;
            GameObject cell = Instantiate(CellPrefab, new Vector3(x, 0.01f, z), Quaternion.identity) as GameObject;
            cell.name = "Reserve(" + PlayerDef.FIRST + "," + i + ")";

            cell.transform.parent = ReservesParent.transform;
            GameObject count = Instantiate(ReservesCountPrefab, new Vector3(x, 0.01f, z), Quaternion.identity) as GameObject;
            count.transform.parent = ReservesParent.transform;
            target   = Camera.main.transform.position;
            target.x = count.transform.position.x;
            count.transform.LookAt(target);
            count.name = "ReservesCount(0," + i + ")";
            count.SetActive(true);

            CreateReserve(PlayerDef.FIRST, (Pawn)i);
            SetReserveCount(PlayerDef.FIRST, (Pawn)i, board.GetReserve(PlayerDef.FIRST, (Pawn)i));
        }

        for (int i = 0; i < PawnDef.CAPTURE_MAX; i++)
        {
            float x = cellSize * i;
            float z = cellSize * -(-0.5f - 1);
            x -= cellSize * BoardDef.WIDTH / 2.0f - cellSize / 2.0f;
            z += cellSize * BoardDef.HEIGHT / 2.0f - cellSize / 2.0f;
            GameObject cell = Instantiate(CellPrefab, new Vector3(x, 0.01f, z), Quaternion.identity) as GameObject;
            cell.transform.parent = ReservesParent.transform;
            cell.name             = "Reserve(" + PlayerDef.SECOND + "," + i + ")";

            GameObject count = Instantiate(ReservesCountPrefab, new Vector3(x, 0.01f, z), Quaternion.identity) as GameObject;
            count.transform.parent = ReservesParent.transform;
            target   = Camera.main.transform.position;
            target.x = count.transform.position.x;
            count.transform.LookAt(target);
            count.name = "ReservesCount(1," + i + ")";
            count.SetActive(true);

            CreateReserve(PlayerDef.SECOND, (Pawn)i);
            SetReserveCount(PlayerDef.SECOND, (Pawn)i, board.GetReserve(PlayerDef.SECOND, (Pawn)i));
        }

        target   = Camera.main.transform.position;
        target.x = UpgradeObject.transform.position.x;
        UpgradeObject.transform.LookAt(target);

        ResetHighlight();

        //StartCoroutine("Search");
    }
Example #42
0
    // delete nodes of subtree in delete window
    internal virtual void delete(int oid)
    {
        int counter = 0; // number of nodes deleted

        if (this != null)
        {
            // check each children against delete window
            for (CELL curr_cell = this.head; curr_cell != null; curr_cell = curr_cell.next)
            {

                if (curr_cell.child != null)
                {
                    // search subtree
                    curr_cell.child.delete(oid);
                    if (curr_cell.child.head == null)
                    {
                        if (curr_cell.prev != null)
                        {
                            curr_cell.prev.next = curr_cell.next;
                        }
                        else
                        {
                            head = curr_cell.next;
                        }
                        if (curr_cell.next != null)
                        {
                            curr_cell.next.prev = curr_cell.prev;
                        }
                    }
                }
                else
                {
                    // search leaf
                    counter += delete_leaf(oid);
                }
            }
            if (counter > 0)
            {
                // some children deleted
                if (parent != null)
                {
                    // resize MBR of parent cell
                    parent.resize();
                }
            }
        }
        else
        {
            System.Console.Out.WriteLine("Error: Null node.");
        }
    }
Example #43
0
    internal virtual void insert(MBR W)
    {
        CELL ins_cell;

        ins_cell = new CELL(W);
        ins_cell.next = this.head;
        this.head = ins_cell;
        if (this.head.next != null)
            this.head.next.prev = this.head;
    }
Example #44
0
 // constructor function
 public node()
 {
     this.head = null;
     this.parent = null;
 }