コード例 #1
0
ファイル: SolverParser.cs プロジェクト: dpankratz/Cmput497Hex
    private static PMOVE init_PMOVE(int m, int RN)
    {
        PMOVE p = new PMOVE();

        p.local_move  = m;
        p.global_move = -1;//will calculate later
        if (RN == 1)
        {
            p.global_move = m;
            if (m <= BOARDSIZE * BOARDSIZE / 2)
            {
                p.global_move = m - 1;
            }
        }
        return(p);
    }
コード例 #2
0
ファイル: SolverParser.cs プロジェクト: dpankratz/Cmput497Hex
    private static void add_new_patterns(ref Dictionary <int, Pattern> all_patterns, Pattern cur_pattern,
                                         int bn, ref List <Pattern> working_patterns)
    {
        int i, j, k;
        Dictionary <int, int> local_global = new Dictionary <int, int>();

        for (i = 0; i < cur_pattern.vc_WMs.Count; i++)
        {
            for (j = 1; j < cur_pattern.vc_WMs[i].Count; j++)
            {
                local_global[cur_pattern.vc_WMs[i][j].local_move] = cur_pattern.vc_WMs[i][j].global_move;
            }
        }
        if (cur_pattern.RN == 1)
        {
            for (i = 1; i <= BOARDSIZE * BOARDSIZE - 1; i++)
            {
                if (i <= mid_point)
                {
                    local_global[i] = i - 1;
                }
                else
                {
                    local_global[i] = i;
                }
            }
        }

        if (cur_pattern.vc_ND[bn] == 0)
        {
            return;                             //nothing to add
        }
        int ND = cur_pattern.vc_vc_PPs[bn].Count;

        for (i = 0; i < ND; i++)
        {
            int ch_id = cur_pattern.vc_vc_PPs[bn][i][0];
            Dictionary <int, int> ch_pa = new Dictionary <int, int>();
            for (j = 1; j < cur_pattern.vc_vc_PPs[bn][i].Count; j++)
            {
                int m = cur_pattern.vc_vc_PPs[bn][i][j];
                ch_pa[j] = local_global[m];
            }
            Pattern p = new Pattern(all_patterns[ch_id]);

            for (j = 0; j < p.vc_WMs.Count; j++)
            {
                int   l;
                PMOVE pmove;
                for (k = 1; k < p.vc_WMs[j].Count; k++)
                {
                    pmove = new PMOVE();

                    l = p.vc_WMs[j][k].local_move;
                    //p.vc_BM[j].global_move = ch_pa[l];
                    pmove.global_move = ch_pa[l];
                    pmove.local_move  = p.vc_WMs[j][k].local_move;
                    p.vc_WMs[j][k]    = pmove;
                }
                pmove             = new PMOVE();
                l                 = p.vc_BM[j].local_move;
                pmove.global_move = ch_pa[l];
                pmove.local_move  = p.vc_BM[j].local_move;
                //p.vc_BM[j].global_move = ch_pa[l];
                p.vc_BM[j] = pmove;
            }
            working_patterns.Add(p);
        }
    }