Ejemplo n.º 1
0
        private WorldsGenerator(World world, int width)
        {
            var meleeLookupRadius    = width / 10;
            var horsemanLookupRadius = width / 6;
            var archerLookupRadius   = width / 2;

            var meleeFightStrategy = new MeleeFightStrategy(world);
            var fireStrategy       = new FireStrategy(world);

            IStrategy up   = new DefaultMoveStrategy(1, 0, world);
            IStrategy down = new DefaultMoveStrategy(-1, 0, world);

            _meleeStrategiesUp   = new StrategySet(meleeFightStrategy, new MoveToEnemyStrategy(world, meleeLookupRadius), up);
            _meleeStrategiesDown = new StrategySet(meleeFightStrategy, new MoveToEnemyStrategy(world, meleeLookupRadius), down);

            IStrategy horseUp   = new HorseMoveStrategy(1, 0, world);
            IStrategy horseDown = new HorseMoveStrategy(-1, 0, world);

            _strategiesHorseUp   = new StrategySet(meleeFightStrategy, new MoveToEnemyStrategy(world, horsemanLookupRadius), horseUp);
            _strategiesHorseDown = new StrategySet(meleeFightStrategy, new MoveToEnemyStrategy(world, horsemanLookupRadius), horseDown);

            _archerStrategiesUp   = new StrategySet(fireStrategy, meleeFightStrategy, new MoveToEnemyStrategy(world, archerLookupRadius), up);
            _archerStrategiesDown = new StrategySet(fireStrategy, meleeFightStrategy, new MoveToEnemyStrategy(world, archerLookupRadius), down);

            _world = world;
        }
Ejemplo n.º 2
0
        /// <returns>a dictionary indicating for each node whether a winning strategy exists for even</returns>
        public Dictionary<Vertex, bool> Solve(LiftingStrategy liftStrat)
        {
            liftStrat.Initialize(this.pg);
            var rho = new StrategySet();
            foreach (var v in pg.V)
                rho[v] = new DTuple(d);

            // calculate fixpoint
            var workBatch = liftStrat.GetBatch();
            while (workBatch != null && workBatch.Count() > 0) {
                // lifting strategy determines which order in which to lift vertices
                foreach (var v in workBatch) {
                    // repeatedly lift vertex v
                    DTuple old;
                    int numIteration = 0;
                    do {
                        if (numIteration++ > 0)
                            liftStrat.Progress(); // tell strategy we made progress
                        old = rho[v];
                        Lift(v, rho);
                    } while (rho[v] > old);
                }
                // continue with next batch
                workBatch = liftStrat.GetBatch();
            }

            var ret = new Dictionary<Vertex, bool>();
            foreach (var entry in rho) ret[entry.Key] = entry.Value != MTop;
            return ret;
        }
Ejemplo n.º 3
0
 public DTuple Prog(StrategySet rho, Vertex v, Vertex w)
 {
     var rho_w = rho[w];
     var ret = new DTuple(rho_w.Count);
     if (v.PriorityEven) {
         // return the least m >= (up to p(v)) rho
         // easily constructed by copying values up to p(v) and padding with 0
         if (rho_w.IsTop) ret = MTop;
         else for (int i = 0; i < v.Priority; i++)
                 ret[i] = rho_w[i];
     }
     else {
         // return the least m > (up to p(v)) rho[w]
         // constructed by taking the first elem before p(v) that can be incremented, MTop otherwise
         for (int i = v.Priority; i >= 0; i--) {
             if (rho_w[i] < MMaxEven[i]) {
                 ret[i] = rho_w[i] + 1;
                 // leave stuff in front same as rho_w
                 for (int j = 0; j < i; j++)
                     ret[j] = rho_w[j];
                 // and set remainder to 0
                 for (int j = i + 1; j < d; j++)
                     ret[j] = 0;
                 break;
             }
             else if (i == 0) // nothing could be incremented
                 ret = MTop;
             else // copy this val, try to incr. next
                 ret[i] = rho_w[i];
         }
     }
     return ret;
 }
Ejemplo n.º 4
0
 protected UnitBase(Team team, StrategySet strategies, int y, int x)
 {
     Team        = team;
     _strategies = strategies;
     Y           = y;
     X           = x;
     Health      = MaxHealth;
 }
Ejemplo n.º 5
0
    protected void Button30_Click(object sender, EventArgs e)
    {
        StrategySet set = new StrategySet();

        IGradeStrategy strategy = StrategyFactory.GetGradeStrategy(this.DropDownList1.SelectedValue);

        strategy.Value = this.DropDownList2.SelectedValue;


        this.Label4.Text = strategy.BuildQuery();

        CustomerGrade cg = new CustomerGrade();

        cg.CompanyID  = 2;
        cg.GradeLevel = UserLevel.D;
        cg.GradeLimit = strategy.BuildQuery();
        CustomerGradeManager.Create(cg);
    }
 public HorseMan(Team team, StrategySet strategies, int y, int x) : base(team, strategies, y, x)
 {
 }
Ejemplo n.º 7
0
    protected void Button31_Click(object sender, EventArgs e)
    {
        StrategySet set = new StrategySet();

        set.ReFill(@"RegionID = BeiJING AND IndustryID = JSJ AND BrandID = 'AMD' ");
    }
    private void prepStrategyCards(StrategySet set, StrategyCard[] replacements)
    {
        //Prepare set
        prepStrategyCards (set);

        foreach (StrategyCard replacementCard in replacements) {
            strategyCards[replacementCard.Initiative] = replacementCard;
        }
    }
    private void prepStrategyCards(StrategySet set)
    {
        foreach (StrategyCard strategyCard in strats.Values){
            if (strategyCard.Set == set) {
                strategyCards[strategyCard.Initiative] = strategyCard;
            }
        }

        if (strategyCards.Values.Count < 8) {
            //Set is incomplete (Fall of the Empire). Fill in with original strategy cards
            foreach (StrategyCard strategyCard in strats.Values){
                if (strategyCard.Set == StrategySet.Vanilla && !strategyCards.ContainsKey (strategyCard.Initiative)) {
                    strategyCards[strategyCard.Initiative] = strategyCard;
                }
            }
        }

        strategyCardsDebug = new StrategyCard[8];
    }
 public SwordsMan(Team team, StrategySet strategies, int y, int x)
     : base(team, strategies, y, x)
 {
 }
Ejemplo n.º 11
0
 private void Lift(Vertex v, StrategySet rho)
 {
     var ps = v.Adj.Select(w => Prog(rho, v, w)).OrderBy(d => d);
     rho[v] = v.OwnerEven ? ps.First() : ps.Last();
 }
 public string StrategySetToString(StrategySet strategySet)
 {
     return strategySetTo [strategySet];
 }
Ejemplo n.º 13
0
 public Archer(Team team, StrategySet strategies, int y, int x)
     : base(team, strategies, y, x)
 {
 }