Ejemplo n.º 1
0
        void PrepareChanceIndex_OnNodeBegin(ChanceTree tree, PrepareChanceIndexContext[] stack, int depth)
        {
            PrepareChanceIndexContext context = stack[depth];
            Int64 n     = context.NodeIdx;
            int   round = (depth - 1) / _playersCount;

            if (depth > 0)
            {
                stack[depth - 1].ChanceIdx.CopyTo(context.ChanceIdx, 0);
                int curPlayer = tree.Nodes[n].Position;
                context.ChanceIdx[curPlayer] += CalculateChanceOffset(round, curPlayer) * tree.Nodes[n].Card;

                int oppChanceIdx       = 0;
                int oppChanceIdxOffset = 1;
                for (int p = 0; p < _playersCount; ++p)
                {
                    if (p == HeroPosition)
                    {
                        continue;
                    }
                    oppChanceIdx       += oppChanceIdxOffset * context.ChanceIdx[p];
                    oppChanceIdxOffset *= _chanceIndexSizes[p][round];
                }

                if (curPlayer == _playersCount - 1)
                {
                    // All players got cards in this round - store the node index.
                    _chanceTreeNodes[round][context.ChanceIdx[HeroPosition]][oppChanceIdx] = (int)n;
                }
            }
        }
Ejemplo n.º 2
0
        void PrepareChanceIndex_OnNodeBegin(ChanceTree tree, PrepareChanceIndexContext[] stack, int depth)
        {
            PrepareChanceIndexContext context = stack[depth];
            Int64 n     = context.NodeIdx;
            int   round = (depth - 1) / PLAYERS_COUNT;

            if (depth > 0)
            {
                stack[depth - 1].ChanceIdx.CopyTo(context.ChanceIdx, 0);
                int curPlayer = tree.Nodes[n].Position;
                context.ChanceIdx[curPlayer] += CalculateChanceOffset(round, curPlayer) * tree.Nodes[n].Card;

                if (curPlayer == PLAYERS_COUNT - 1)
                {
                    // All players got cards in this round - store the node index.
                    _chanceTreeNodes[round][context.ChanceIdx[_oppPosition]][context.ChanceIdx[HeroPosition]] = (int)n;
                }
            }
        }