Developing

  • Create your own class library project
  • Add a reference from your project to the provided starter package (.exe)
  • Implement the ICommander interface with your own logic

Example: MyCommander.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CSharpCTFStarter.Objects;
using CSharpCTFStarter.Util;

namespace CSharpCTFStarter
{
    public class MyCommander : ICommander
    {
        private Game _game;

        public string GetName()
        {
            return "MyCommander";
        }

        public void ShutDown()
        {
           
        }

        public void Initialize(Game game)
        {
            _game = game;
        }

        public void Tick()
        {

            foreach (Bot bot in _game.AvailableBots)
            {
                if (bot.CarriedFlag != null)
                {
                    Vector2 flagScorePos = _game.Us.ScoreLocation;
                    bot.Charge(flagScorePos, "Go to home");
                }
                else
                {
                    Vector2 enemyFlagPos = _game.Enemy.Flag.Position;
                    bot.Charge(enemyFlagPos, "Run to enemy flag");
                }
            }

        }
    }
}

Running your commander

  • Edit the properties of your class library project:
    • Debug tab: Start external program: CSharpCTFStarter.exe
  • Run it: it will wait patiently for a server to come online to connect to.

Running the engine

  • Edit the simulate.py file present in the capture the flag sdk folder so that 'game.NetworkCommander' is being run as one of the participants

# By default load these commanders.
defaults = ['examples.Balanced', 'game.NetworkCommander']

  • Run simulate.bat: your bot should connect to it almost immediately.

Last edited Dec 14, 2012 at 9:07 PM by csj, version 5

Comments

xxShark Feb 19, 2013 at 12:49 AM 
never mind.. I figure it out.. reference it in the .net class library.

xxShark Feb 19, 2013 at 12:33 AM 
where do I put the JSON .dll? reference it in my project or does the SDK look in a directory for it?

Bolukan Dec 4, 2012 at 8:27 PM 
Can you provide example code for simulate.bat and how My.CommanderClass shows in your code.