Example #1
0
                public VoteNode put(int i_index, NodePool i_pool)
                {
                    VoteNode[] n    = this.nodes;
                    int        ridx = this.remining - 1;

                    for (int i = n.Length - 1; i >= 0; i--)
                    {
                        if (i == ridx)
                        {
                            VoteNode t = i_pool.prePush();
                            if (t == null)
                            {
                                return(null);
                            }
                            //新規作成
                            n[i]    = t;
                            t.index = i_index;
                            t.count++;
                            this.remining--;
                            return(t);
                        }
                        if (n[i].index == i_index)
                        {
                            //既存に追記
                            n[i].count++;
                            return(n[i]);
                        }
                    }
                    //終端到達で無効
                    return(null);
                }
Example #2
0
            public int findMax()
            {
                int max        = 0;
                int index      = 0;
                int array_size = NUM_OF_ARRAY;

                for (int x = this.root.remining; x < array_size; x++)
                {
                    VoteNode nx = this.root.nodes[x];
                    for (int y = nx.remining; y < array_size; y++)
                    {
                        VoteNode ny = nx.nodes[y];
                        for (int an = ny.remining; an < array_size; an++)
                        {
                            VoteNode na = ny.nodes[an];
                            for (int sc = na.remining; sc < array_size; sc++)
                            {
                                VoteNode ns = na.nodes[sc];
                                if (ns.count >= max)
                                {
                                    index = nx.index | ((ny.index | ((na.index | (ns.index << 7)) << 7)) << 7);
                                    max   = ns.count;
                                }
                            }
                        }
                    }
                }
                return((max < 3) ? -1 : index);
            }
Example #3
0
    void GenerateNewNode(string name)
    {
        GameObject newNode = Instantiate(nodeObj);

        newNode.transform.SetParent(content.transform);
        VoteNode newVoteNode = newNode.GetComponent <VoteNode> ();

        newVoteNode.Initialize(name);
        voteNodeList.Add(newVoteNode);
    }
Example #4
0
 public bool vote16(int x, int y, int angle, int scale, int weight)
 {
     for (int ix = 0; ix <= 1; ix++)
     {
         VoteNode r1 = this.root.put(x + ix, this.pool);
         if (r1 == null)
         {
             return(false);
         }
         for (int iy = 0; iy <= 1; iy++)
         {
             VoteNode r2 = r1.put(y + iy, this.pool);
             if (r2 == null)
             {
                 return(false);
             }
             for (int ia = 0; ia <= 1; ia++)
             {
                 //X,Y,A
                 VoteNode r3 = r2.put(angle + ia, this.pool);
                 if (r3 == null)
                 {
                     return(false);
                 }
                 for (int is_ = 0; is_ <= 1; is_++)
                 {
                     VoteNode r4 = r3.put(scale + is_, this.pool);
                     if (r4 == null)
                     {
                         return(false);
                     }
                     //if(r4.count==1){//debug
                     //	nol++;
                     //}
                 }
             }
         }
     }
     return(true);
 }
Example #5
0
 public TreeVoteMap(int i_size)
 {
     this.pool = new NodePool(i_size);
     this.root = new VoteNode(NUM_OF_ARRAY);
 }