示例#1
0
        //int numOfUnits = 0;
        //IUnitDef[] unitList;
        //IUnitDef solarcollectordef;


        public void InitAI(IAICallback aicallback, int team)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");

            this.aicallback = aicallback;
            try{
                this.Team = team;
                logfile   = LogFile.GetInstance().Init(Path.Combine(AIDirectoryPath, "csharpai_team" + team + ".log"));
                logfile.WriteLine("C# AI started v" + AIVersion + ", team " + team + " ref " + reference + " map " + aicallback.GetMapName() + " mod " + aicallback.GetModName());
                logfile.WriteLine("RL Date/time: " + DateTime.Now.ToString());

                if (File.Exists(AIDirectoryPath + "/debug.flg"))    // if this file exists, activate debug mode; saves manually changing this for releases
                {
                    logfile.WriteLine("Toggling debug on");
                    DebugOn = true;
                }

                if (DebugOn)
                {
                    //new Testing.RunTests().Go();
                }

                InitCache();

                BuildEconomy buildeconomy = new BuildEconomy();

                // UnitController.GetInstance().LoadExistingUnits();  // need this if we're being reloaded in middle of a game, to get already existing units

                SendTextMsg("C# AI initialized v" + AIVersion + ", team " + team);
            }
            catch (Exception e)
            {
                logfile.WriteLine("Exception: " + e.ToString());
                SendTextMsg("Exception: " + e.ToString());
            }
        }
示例#2
0
        public void InitAI( IAICallback aicallback, int team)
        {

            this.aicallback = aicallback;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
            
            try{
                Directory.CreateDirectory(AIDirectoryPath);
                this.Team = team;
                logfile = LogFile.GetInstance().Init( Path.Combine( AIDirectoryPath, "csharpai_team" + team + ".log" ) );
                logfile.WriteLine( "C# AI started v" + AIVersion+ ", team " + team + " ref " + reference + " map " + aicallback.GetMapName() + " mod " + aicallback.GetModName() );
                logfile.WriteLine("RL Date/time: " + DateTime.Now.ToString());

                if( File.Exists( AIDirectoryPath + "/debug.flg" ) ) // if this file exists, activate debug mode; saves manually changing this for releases
                {
                    logfile.WriteLine( "Toggling debug on" );
                    DebugOn = true;
                }
                
                if( DebugOn )
                {
                    //new Testing.RunTests().Go();
                }
                
                InitCache();
                /*
                IUnitDef unitdef = aicallback.GetUnitDefByTypeId(34);
                aicallback.SendTextMsg(unitdef.name,0);
                aicallback.SendTextMsg(unitdef.id.ToString(), 0);
                aicallback.SendTextMsg(unitdef.humanName, 0);
                aicallback.SendTextMsg(unitdef.movedata.moveType.ToString(), 0);
                aicallback.SendTextMsg(unitdef.movedata.maxSlope.ToString(), 0);
                aicallback.GetMetalMap();
                aicallback.GetLosMap();
                aicallback.GetRadarMap();
                aicallback.GetFriendlyUnits();
                aicallback.GetFeatures();
                aicallback.GetEnemyUnitsInRadarAndLos();

                Metal.GetInstance();
                */
                //aicallback.GetElevation(300,300);
                //new SlopeMap().GetSlopeMap();
                //double[,] _SlopeMap = new double[256, 256];
                //LosMap.GetInstance();
                //MovementMaps.GetInstance();
                //BuildMap.GetInstance().Init();

                //return;
                // -- test stuff here --
                logfile.WriteLine("Is game paused? : " + aicallback.IsGamePaused());
                // -- end test stuff --

                BuildEconomy buildeconomy = new BuildEconomy();
                
               // UnitController.GetInstance().LoadExistingUnits();  // need this if we're being reloaded in middle of a game, to get already existing units

                SendTextMsg("C# AI initialized v" + AIVersion + ", team " + team);
           }
           catch( Exception e )
           {
               logfile.WriteLine( "Exception: " + e.ToString() );
               SendTextMsg( "Exception: " + e.ToString() );
           }
        }
示例#3
0
        //int numOfUnits = 0;
        //IUnitDef[] unitList;
        //IUnitDef solarcollectordef;
        public void InitAI( IAICallback aicallback, int team)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");

            this.aicallback = aicallback;
            try{
                this.Team = team;
                logfile = LogFile.GetInstance().Init( Path.Combine( AIDirectoryPath, "csharpai_team" + team + ".log" ) );
                logfile.WriteLine( "C# AI started v" + AIVersion+ ", team " + team + " ref " + reference + " map " + aicallback.GetMapName() + " mod " + aicallback.GetModName() );
                logfile.WriteLine("RL Date/time: " + DateTime.Now.ToString());

                if( File.Exists( AIDirectoryPath + "/debug.flg" ) ) // if this file exists, activate debug mode; saves manually changing this for releases
                {
                    logfile.WriteLine( "Toggling debug on" );
                    DebugOn = true;
                }

                if( DebugOn )
                {
                    //new Testing.RunTests().Go();
                }

                InitCache();

                BuildEconomy buildeconomy = new BuildEconomy();

               // UnitController.GetInstance().LoadExistingUnits();  // need this if we're being reloaded in middle of a game, to get already existing units

                SendTextMsg("C# AI initialized v" + AIVersion + ", team " + team);
               }
               catch( Exception e )
               {
               logfile.WriteLine( "Exception: " + e.ToString() );
               SendTextMsg( "Exception: " + e.ToString() );
               }
        }
示例#4
0
        public void InitAI(IAICallback aicallback, int team)
        {
            this.aicallback = aicallback;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");

            try{
                Directory.CreateDirectory(AIDirectoryPath);
                this.Team = team;
                logfile   = LogFile.GetInstance().Init(Path.Combine(AIDirectoryPath, "csharpai_team" + team + ".log"));
                logfile.WriteLine("C# AI started v" + AIVersion + ", team " + team + " ref " + reference + " map " + aicallback.GetMapName() + " mod " + aicallback.GetModName());
                logfile.WriteLine("RL Date/time: " + DateTime.Now.ToString());

                if (File.Exists(AIDirectoryPath + "/debug.flg"))    // if this file exists, activate debug mode; saves manually changing this for releases
                {
                    logfile.WriteLine("Toggling debug on");
                    DebugOn = true;
                }

                if (DebugOn)
                {
                    //new Testing.RunTests().Go();
                }

                InitCache();

                /*
                 * IUnitDef unitdef = aicallback.GetUnitDefByTypeId(34);
                 * aicallback.SendTextMsg(unitdef.name,0);
                 * aicallback.SendTextMsg(unitdef.id.ToString(), 0);
                 * aicallback.SendTextMsg(unitdef.humanName, 0);
                 * aicallback.SendTextMsg(unitdef.movedata.moveType.ToString(), 0);
                 * aicallback.SendTextMsg(unitdef.movedata.maxSlope.ToString(), 0);
                 * aicallback.GetMetalMap();
                 * aicallback.GetLosMap();
                 * aicallback.GetRadarMap();
                 * aicallback.GetFriendlyUnits();
                 * aicallback.GetFeatures();
                 * aicallback.GetEnemyUnitsInRadarAndLos();
                 *
                 * Metal.GetInstance();
                 */
                //aicallback.GetElevation(300,300);
                //new SlopeMap().GetSlopeMap();
                //double[,] _SlopeMap = new double[256, 256];
                //LosMap.GetInstance();
                //MovementMaps.GetInstance();
                //BuildMap.GetInstance().Init();

                //return;
                // -- test stuff here --
                logfile.WriteLine("Is game paused? : " + aicallback.IsGamePaused());
                // -- end test stuff --

                BuildEconomy buildeconomy = new BuildEconomy();

                // UnitController.GetInstance().LoadExistingUnits();  // need this if we're being reloaded in middle of a game, to get already existing units

                SendTextMsg("C# AI initialized v" + AIVersion + ", team " + team);
            }
            catch (Exception e)
            {
                logfile.WriteLine("Exception: " + e.ToString());
                SendTextMsg("Exception: " + e.ToString());
            }
        }