コード例 #1
0
ファイル: Search.cs プロジェクト: yuusuwalann/procon2015
        /* 石の配置 NG:null */
        private AGI_CalcFields placement(AGI_CalcFields agicOrgF, int stoneId, int kinds, int placeIdx, bool connectCheck)
        {
            AGI_CalcFields retAgicF = new AGI_CalcFields(agicOrgF, commonMap);

            AGI_Stones setStone = new AGI_Stones(agi.GetAgiStoneList().GetAgiStoneKindsList(stoneId).GetAGIStones(kinds));
            /* 石の加算処理 */
            for (int i = 0; i < setStone.GetSize(); i++)
            {
                int idx = agiST2agiF(retAgicF.GetMaxX(), retAgicF.GetMaxY(), setStone.GetXSize(), setStone.GetYSize(), placeIdx, i);
                retAgicF.SetAgiCalcNum
                    (idx,
                    retAgicF.GetAgiCalcFieldNum(idx) + setStone.GetNum(i));
            }
            /* 判定 */
            bool connectFlg = false;    /* 自陣と接続するか判定 */

            for (int i = 0; i < retAgicF.GetAgiCalcFieldsSize(); i++)
            {
                int tmp = retAgicF.GetAgiCalcFieldNum(i);
                if ((tmp > 0) && ((tmp % 2) == 0))
                {
                    /* 正の偶数値があった場合、自・壁・障のいずれかと重なる */
                    return null;
                }
                if ((connectFlg == false) && (tmp == -6)) /* 近傍(-7) + 自陣(1) */
                {
                    connectFlg = true;
                }
            }

            if ((connectCheck == true) && (connectFlg != true))
            {
                return null;
            }

            /* 加算前(石設置済み)に戻す */
            retAgicF.GetReturnCalcFld();

            return retAgicF;
        }
コード例 #2
0
        private int[] r90(AGI_Stones agiSt)
        {
            int[] ret = new int[agiSt.GetXSize() * agiSt.GetYSize()];

            for (int i = 0; i < agiSt.GetXSize(); i++)
            {
                for (int j = 0; j < agiSt.GetYSize(); j++)
                {
                    ret[((agiSt.GetYSize() - 1) - j) + i * agiSt.GetYSize()] = agiSt.GetNum(j * agiSt.GetXSize() + i);
                }
            }

            return ret;
        }
コード例 #3
0
 private int[] rev(AGI_Stones agiSt)
 {
     int[] ret = new int[agiSt.GetXSize() * agiSt.GetYSize()];
     for (int i = 0; i < agiSt.GetYSize(); i++)
     {
         int[] array = new int[agiSt.GetXSize()];
         for (int j = 0; j < agiSt.GetXSize(); j++)
         {
             array[j] = agiSt.GetNum(i * agiSt.GetXSize() + j);
         }
         Array.Reverse(array);
         for (int j = 0; j < agiSt.GetXSize(); j++)
         {
             ret[i * agiSt.GetXSize() + j] = array[j];
         }
     }
     return ret;
 }
コード例 #4
0
        private AGI_Stones createKinds(AGI_Stones target, int k, AGI_Stones org)
        {
            AGI_Stones retStone;
            int[] ret = new int[] { };
            int r = 0;
            int l = 0;
            int u = 0;
            int d = 0;

            switch (k)
            {
                case (int)Kinds.R90:
                    /* xサイズとyサイズを反転 */
                    retStone = new AGI_Stones(target.GetYSize(), target.GetXSize());
                    ret = r90(target);
                    r = org.GetUpReduct();
                    d = org.GetRightReduct();
                    l = org.GetDownReduct();
                    u = org.GetLeftReduct();

                    break;
                case (int)Kinds.R180:
                    /* xサイズとyサイズを反転 */
                    retStone = new AGI_Stones(target.GetYSize(), target.GetXSize());
                    ret = r90(target);
                    r = org.GetLeftReduct();
                    d = org.GetUpReduct();
                    l = org.GetRightReduct();
                    u = org.GetDownReduct();

                    break;
                case (int)Kinds.R270:
                    /* xサイズとyサイズを反転 */
                    retStone = new AGI_Stones(target.GetYSize(), target.GetXSize());
                    ret = r90(target);
                    r = org.GetDownReduct();
                    d = org.GetLeftReduct();
                    l = org.GetUpReduct();
                    u = org.GetRightReduct();
                    break;
                case (int)Kinds.REV_ORG:
                    /* xサイズとyサイズはそのまま */
                    retStone = new AGI_Stones(target.GetXSize(), target.GetYSize());
                    ret = rev(target);
                    r = org.GetLeftReduct();
                    d = org.GetDownReduct();
                    l = org.GetRightReduct();
                    u = org.GetUpReduct();
                    break;
                case (int)Kinds.REV_R90:
                    /* xサイズとyサイズを反転 */
                    ret = r90(target);
                    retStone = new AGI_Stones(target.GetYSize(), target.GetXSize());
                    r = org.GetUpReduct();
                    d = org.GetLeftReduct();
                    l = org.GetDownReduct();
                    u = org.GetRightReduct();
                    break;
                case (int)Kinds.REV_R180:
                    /* xサイズとyサイズを反転 */
                    ret = r90(target);
                    retStone = new AGI_Stones(target.GetYSize(), target.GetXSize());
                    r = org.GetRightReduct();
                    d = org.GetUpReduct();
                    l = org.GetLeftReduct();
                    u = org.GetDownReduct();
                    break;
                case (int)Kinds.REV_R270:
                    /* xサイズとyサイズを反転 */
                    ret = r90(target);
                    retStone = new AGI_Stones(target.GetYSize(), target.GetXSize());
                    r = org.GetDownReduct();
                    d = org.GetRightReduct();
                    l = org.GetUpReduct();
                    u = org.GetLeftReduct();
                    break;
                default:
                    retStone = null;
                    break;
            }

            for (int i = 0; i < ret.Length; i++)
            {
                retStone.SetStoneNum(i, ret[i]);
            }
            retStone.SetRightReduct(r);
            retStone.SetLeftReduct(l);
            retStone.SetUpReduct(u);
            retStone.SetDownReduct(d);

            return retStone;
        }