Exemple #1
0
        public int rand_tab()
        {
            /* get a random number */
            int r = random_.nextInt(tot);

            /* select the item */
            for (int i = 0; i < n; i++)
            {
                /* walk through the table */
                r -= table[i];
                if (r < 0)
                {
                    return(i);
                }
            }
            return(0);
        }
Exemple #2
0
    ////////////////////////////////////////////
    //Creation Call
    //Returns a new instance of the player.
    //note the pplayer name is also being set here
    public override AIPlayer createAIPlayer(int position, string logpath, string logname, CDLLHints hints,
                                            AIEventInterfaceI aiEvent, AICommandInterfaceI command, AIQueryI query, AICheatI cheat, int logLevel)
    {
        //name selection
        if (aiGroup_.Count == 0)
        {
            for (int i = 0; i < leaders_.Length; i++)
            {
                aiGroup_.Add(leaders_[i]);
            }
        }

        int    r     = random_.nextInt(aiGroup_.Count);
        string pname = aiGroup_[r];

        aiGroup_.RemoveAt(r);

        //instance creation
        return(new ExamplePlayer(position, pname, logpath, logname, hints, aiEvent, command, query, cheat, logLevel));
    }