Exemplo n.º 1
0
        public VlasovPlayer(
            int position,
            Dictionary <string, string> caMap,
            CEncodedObjectInputBufferI bin,
            string logpath,
            string logname,
            AIEventInterfaceI aiEvent,
            AICommandInterfaceI command,
            AIQueryI query,
            AICheatI cheat,
            int logLevel)
            : base(
                position,
                logpath,
                logname,
                caMap,
                bin,
                aiEvent,
                command,
                query,
                cheat,
                logLevel)
        {
            elogger_ = new CSubLog("ExamplePlayer:" + Convert.ToString(position), realLog_);
            elogger_.info("D Logger Log Open: " + logpath + " " + logname);
            elogger_.info("Position " + Convert.ToSingle(position) + " waking up.");

            testAttribute_ = EncodeUtil.parseInt(caMap[TEST_ATTR]);

            hints_ = new CDLLHints(bin);
        }
Exemplo n.º 2
0
        public static CUnit decodeCUnit(CEncodedObjectInputBufferI bin, AIQueryI query)
        {
            bin.nextTag(TAG);
            Dictionary <string, string> A = bin.getAttributes();
            var ret = new CUnit(A, bin, query);

            bin.endTag(TAG);
            return(ret);
        }
Exemplo n.º 3
0
    public override AIPlayer reloadAIPlayer(int position, CEncodedObjectInputBufferI bin,
                                            string logpath, string logname,
                                            AIEventInterfaceI aiEvent, AICommandInterfaceI command,
                                            AIQueryI query, AICheatI cheat, int logLevel)
    {
        Dictionary <string, string> caMap = bin.getAttributes();

        return(new VlasovPlayer(position, caMap, bin, logpath, logname, aiEvent, command, query,
                                cheat, logLevel));
    }
Exemplo n.º 4
0
        //////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////
        protected AIPlayer(int position, string path, string logname, AIEventInterfaceI aiEvent, AICommandInterfaceI command, AIQueryI query, AICheatI cheat, int logLevel)
        {
            position_ = position;
            realLog_  = new CLog(path, logname, logLevel);
            alogger_  = new CSubLog("AIPlayer" + Convert.ToString(position_), realLog_);
            alogger_.info("A Logger Log Open: " + path + " " + logname);

            aiEvent_ = aiEvent;
            command_ = command;
            query_   = query;
            cheat_   = cheat;
        }
Exemplo n.º 5
0
        public VlasovPlayer(int position, string pname, string logpath, string logname,
                            CDLLHints hints, AIEventInterfaceI aiEvent,
                            AICommandInterfaceI command, AIQueryI query, AICheatI cheat,
                            int logLevel) : base(position, logpath, logname, aiEvent, command,
                                                 query, cheat, logLevel)
        {
            elogger_ = new CSubLog("Vlasov Player:" + Convert.ToString(position), realLog_);
            elogger_.info("D Logger Log Open: " + logpath + " " + logname);
            elogger_.info(pname + " waking up");

            hints_ = hints.copy();

            pname_ = pname;
        }
Exemplo n.º 6
0
    public override AIPlayer createAIPlayer(int position, string logpath, string logname,
                                            CDLLHints hints, AIEventInterfaceI aiEvent,
                                            AICommandInterfaceI command, AIQueryI query,
                                            AICheatI cheat, int logLevel)
    {
        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);

        return(new VlasovPlayer(position, pname, logpath, logname, hints, aiEvent, command, query,
                                cheat, logLevel));
    }
Exemplo n.º 7
0
        // ReSharper disable UnusedParameter.Local
        protected AIPlayer(
            int position,
            string path,
            string logname,
            Dictionary <string, string> caMap,
            CEncodedObjectInputBufferI bin,
            AIEventInterfaceI aiEvent,
            AICommandInterfaceI command,
            AIQueryI query,
            AICheatI cheat,
            int logLevel)
        // ReSharper restore UnusedParameter.Local
        {
            position_ = position;
            realLog_  = new CLog(path, logname, logLevel);
            alogger_  = new CSubLog("AIPlayer:" + Convert.ToString(position_), realLog_);

            aiEvent_ = aiEvent;
            command_ = command;
            query_   = query;
            cheat_   = cheat;
        }
Exemplo n.º 8
0
 private CProducerUnit(Dictionary <string, string> A, CEncodedObjectInputBufferI bin, AIQueryI query)
     : base(A, bin, query)
 {
     producing_             = A[PRODUCING];
     specialty_             = A[SPECIALTY];
     turnsToCompletion_     = EncodeUtil.parseInt(A[TURNSTOCOMPLETE]);
     efficiency_            = EncodeUtil.parseInt(A[EFFICIENCY]);
     supplyStore_           = EncodeUtil.parseUInt(A[SUPPLYSTORE]);
     minStore_              = EncodeUtil.parseUInt(A[MINSTORE]);
     scrapVal_              = EncodeUtil.parseUInt(A[SCRAPVAL]);
     consumeSupplyForDrain_ = EncodeUtil.fromBoolString(A[CONSUMESUPPFORDRAIN]);
     consumePriority_       = EncodeUtil.parseInt(A[CONSUMEPRIORITY]);
     autoDrainSupply_       = EncodeUtil.fromBoolString(A[AUTODRAIN]);
     isCapital_             = EncodeUtil.fromBoolString(A[CAPITAL]);
     isImportant_           = EncodeUtil.fromBoolString(A[IMPORTANT]);
 }
Exemplo n.º 9
0
 //call by the game to have you reload a player
 public abstract AIPlayer reloadAIPlayer(int position, CEncodedObjectInputBufferI bin, string logpath, string logname, AIEventInterfaceI aiEvent, AICommandInterfaceI command, AIQueryI query, AICheatI cheat, int logLevel);
Exemplo n.º 10
0
 //call by the game to have you create a player
 public abstract AIPlayer createAIPlayer(int position, string logpath, string logname, CDLLHints hints, AIEventInterfaceI aiEvent, AICommandInterfaceI command, AIQueryI query, AICheatI cheat, int logLevel);
Exemplo n.º 11
0
 protected AIPlayerData(int position, string path, string logname, AIEventInterfaceI aiEvent, AICommandInterfaceI command, AIQueryI query, AICheatI cheat, int logLevel)
     : base(position, path, logname, aiEvent, command, query, cheat, logLevel)
 {
     dlogger_ = new CSubLog("PlayerData:" + Convert.ToString(position), realLog_);
     dlogger_.info("D Logger Log Open: " + path + " " + logname);
     random_ = new CMTRandom();
 }
Exemplo n.º 12
0
        ////////////////////////////////////////////////////////////////////
        //Reloading
        protected AIPlayerData(
            int position,
            string path,
            string logname,
            Dictionary <string, string> caMap,
            CEncodedObjectInputBufferI bin,
            AIEventInterfaceI aiEvent,
            AICommandInterfaceI command,
            AIQueryI query,
            AICheatI cheat,
            int logLevel)
            : base(position, path, logname, caMap, bin, aiEvent, command, query, cheat, logLevel)
        {
            dlogger_ = new CSubLog("PlayerData:" + Convert.ToString(position), realLog_);


            curturn_          = EncodeUtil.parseInt(caMap[CUR_TURN]);
            numPlayers_       = EncodeUtil.parseInt(caMap[NUM_PLAYERS]);
            rdWeight_         = EncodeUtil.parseInt(caMap[RD_WEIGHT]);
            unitsBeforeDrain_ = EncodeUtil.parseInt(caMap[UNITS_BEFORE_DRAIN]);

            bin.nextTag(CPlayer.TAGS);
            if (bin.hasChildren())
            {
                bin.firstChild();
                while (!bin.reachedEndTag(CPlayer.TAGS))
                {
                    players_.Add(new CPlayer(bin));
                }
            }
            bin.endTag(CPlayer.TAGS);

            bin.nextTag(SPOTU);
            if (bin.hasChildren())
            {
                bin.firstChild();
                while (!bin.reachedEndTag(SPOTU))
                {
                    CUnit u = CUnit.decodeCUnit(bin, query_);
                    masterObjects_.Add(u.gid_, u);
                    spotMap_.Add(u.gid_, u);
                    spots_.Add(u);
                }
            }
            bin.endTag(SPOTU);


            bin.nextTag(SPOTC);
            if (bin.hasChildren())
            {
                bin.firstChild();
                while (!bin.reachedEndTag(SPOTC))
                {
                    CProducerUnit c = CProducerUnit.decodeCProducerUnit(bin, query_);
                    masterObjects_.Add(c.gid_, c);
                    knownCitiesVec_.Add(c);
                    spotMap_.Add(c.gid_, c);
                    spots_.Add(c);
                }
            }
            bin.endTag(SPOTC);

            bin.nextTag(SPOTP);
            if (bin.hasChildren())
            {
                bin.firstChild();
                while (!bin.reachedEndTag(SPOTP))
                {
                    CProducerUnit p = CProducerUnit.decodeCProducerUnit(bin, query);
                    masterObjects_.Add(p.gid_, p);
                    spotMap_.Add(p.gid_, p);
                    spots_.Add(p);
                }
            }
            bin.endTag(SPOTP);

            bin.nextTag(CITIES);
            if (bin.hasChildren())
            {
                bin.firstChild();
                while (!bin.reachedEndTag(CITIES))
                {
                    CProducerUnit c = CProducerUnit.decodeCProducerUnit(bin, query_);
                    masterObjects_.Add(c.gid_, c);
                    knownCitiesVec_.Add(c);
                    cities_.Add(c);
                    cityMap_.Add(c.gid_, c);
                }
            }
            bin.endTag(CITIES);


            bin.nextTag(UNITS);
            if (bin.hasChildren())
            {
                bin.firstChild();
                while (!bin.reachedEndTag(UNITS))
                {
                    CUnit u = CUnit.decodeCUnit(bin, query_);
                    masterObjects_.Add(u.gid_, u);
                    unitMap_.Add(u.gid_, u);
                    units_.Add(u);
                }
            }
            bin.endTag(UNITS);

            bin.nextTag(PRODUCERS);
            if (bin.hasChildren())
            {
                bin.firstChild();
                while (!bin.reachedEndTag(PRODUCERS))
                {
                    CProducerUnit p = CProducerUnit.decodeCProducerUnit(bin, query_);
                    masterObjects_.Add(p.gid_, p);
                    producers_.Add(p);
                    producerMap_.Add(p.gid_, p);
                    unitMap_.Add(p.gid_, p);
                    units_.Add(p);
                }
            }
            bin.endTag(PRODUCERS);

            bin.nextTag(CSupplyRoute.TAGS);
            if (bin.hasChildren())
            {
                bin.firstChild();
                while (!bin.reachedEndTag(CSupplyRoute.TAGS))
                {
                    var csr = new CSupplyRoute(bin);
                    supplySources_.Add(csr.rid_, csr);
                }
            }
            bin.endTag(CSupplyRoute.TAGS);

            map_     = new AIMap(bin);
            mapUtil_ = map_.mapUtil_;

            gameRules_ = new CGameRules(bin);

            vc_ = new CVictoryConditions(bin);

            bin.nextTag(CProposal.TAGS);
            if (bin.hasChildren())
            {
                bin.firstChild();
                while (!bin.reachedEndTag(CProposal.TAGS))
                {
                    var p = new CProposal(bin);
                    proposals_.Add(p);
                }
            }
            bin.endTag(CProposal.TAGS);

            bin.nextTag(CProductionReportData.TAGS);
            if (bin.hasChildren())
            {
                bin.firstChild();
                while (!bin.reachedEndTag(CProductionReportData.TAGS))
                {
                    var prd = new CProductionReportData(bin);
                    prodReport_.Add(prd);
                }
            }
            bin.endTag(CProductionReportData.TAGS);


            random_ = new CMTRandom(AI_RANDOM_TAG, bin);

            //retrieve flyover
            foUnit_ = null;
            if (caMap.ContainsKey(FOUNIT_ID))
            {
                uint fid = EncodeUtil.parseUInt(caMap[FOUNIT_ID]);
                foUnit_ = masterObjects_[fid];
            }
        }
Exemplo n.º 13
0
        protected CUnit(Dictionary <string, string> A, CEncodedObjectInputBufferI bin, AIQueryI query)
        {
            utype_      = A[UTYPE];
            loc_        = CLoc.fromKey(A[LOC]);
            gid_        = EncodeUtil.parseUInt(A[GID]);
            owner_      = EncodeUtil.parseInt(A[OWNER]);
            stackLayer_ = EncodeUtil.parseUInt(A[STACKLAYER]);
            level_      = A[LEVEL];
            landed_     = EncodeUtil.fromBoolString(A[LANDED]);
            inReentry_  = EncodeUtil.fromBoolString(A[INREENTRY]);
            host_       = EncodeUtil.parseUInt(A[HOST]);
            turn_       = EncodeUtil.parseInt(A[TURN]);
            rmvr_       = EncodeUtil.parseInt(A[RMVR]);
            rmvs_       = EncodeUtil.parseInt(A[RMVS]);
            fired_      = EncodeUtil.fromBoolString(A[FIRED]);
            armed_      = EncodeUtil.fromBoolString(A[ARMED]);
            dmg_        = EncodeUtil.parseInt(A[DMG]);
            shortFuel_  = EncodeUtil.fromBoolString(A[SHORTFUEL]);
            sawEnemy_   = EncodeUtil.fromBoolString(A[SAWENEMY]);
            dugIn_      = EncodeUtil.fromBoolString(A[DUGIN]);
            experience_ = EncodeUtil.parseUInt(A[EXPERIENCE]);
            readiness_  = A[READINESS];
            expType_    = A[EXPTYPE];

            name_ = bin.getObjectText(NAME);

            bin.nextTag(CUNITS);
            if (bin.hasChildren())
            {
                bin.firstChild();
                while (!bin.reachedEndTag(CUNITS))
                {
                    bin.nextTag(CUNIT);
                    Dictionary <string, string> D = bin.getAttributes();
                    uint u = EncodeUtil.parseUInt(D[CUNITID]);
                    cunits_.Add(u);
                    bin.endTag(CUNIT);
                }
            }
            bin.endTag(CUNITS);

            ord_ = new COrder(bin);

            entry_ = query.unitQuery(utype_);
        }