コード例 #1
0
        private float FreeSpaceChartCosts(TileMap map, int x, int y)
        {
            TileMap.TileType heroOrFree   = TileMap.TileType.Hero | TileMap.TileType.Free;
            bool             isHeroOrFree = (map[x, y].Type & heroOrFree) > 0;

            return(isHeroOrFree ? 1 : -1);
        }
コード例 #2
0
        public RaiderBot(Knowledge knowledge) : base(knowledge)
        {
            float zeroThreatDistance = 1 + (World.Map.Width / 4);

            TileMap.TileType heroOrFree = TileMap.TileType.Hero | TileMap.TileType.Free;
            World.Chart("threat", World.TypeFilter(TileMap.TileType.Hero, World.Hero.ID), World.DefaultCost);
            World.Chart("mines", World.TypeFilter(TileMap.TileType.GoldMine, World.Hero.ID), World.CostByChart("threat", zeroThreatDistance, 50));
            World.Chart("taverns", World.TypeFilter(TileMap.TileType.Tavern), World.CostByChart("threat", zeroThreatDistance, 50));
            World.Chart("beer_dist", World.TypeFilter(TileMap.TileType.Tavern), node => (node.Type & heroOrFree) > 0 ? 1 : -1);
            World.Chart("free_space", World.TypeFilter(~heroOrFree), FreeSpaceChartCosts);
            World.Chart("escape_routes", SeedSafeSpaces, World.CostByChart("threat", zeroThreatDistance, 20));

            Add(new StayAction(this)
            {
                Weight = 0f
            });
            Add(new DrinkingAction(this)
            {
                Weight = 2.0f
            });
            Add(new MiningAction(this));
            Add(new CombatAction(this));
            Add(new EscapeAction(this)
            {
                Weight = 1.0f
            });
        }
コード例 #3
0
 public void ChangeType(int type)
 {
     this.type = type;
     TileMap.TileType tt = parent.types[type];
     spriteRenderer.sprite = tt.sprite == null ? spriteRenderer.sprite : tt.sprite;
     name += " : " + tt.name;
 }
コード例 #4
0
        public GruntBot(Knowledge knowledge) : base(knowledge)
        {
            float zeroThreatDistance = 1 + (World.Map.Width / 4);

            World.Chart("threat", World.TypeFilter(TileMap.TileType.Hero, World.Hero.ID), World.DefaultCost);
            World.Chart("mines", World.TypeFilter(TileMap.TileType.GoldMine, World.Hero.ID), World.CostByChart("threat", zeroThreatDistance, 50));
            World.Chart("taverns", World.TypeFilter(TileMap.TileType.Tavern), World.CostByChart("threat", zeroThreatDistance, 50));
            TileMap.TileType heroOrFree = TileMap.TileType.Hero | TileMap.TileType.Free;
            World.Chart("beer_dist", World.TypeFilter(TileMap.TileType.Tavern), node => (node.Type & heroOrFree) > 0 ? 1 : -1);
            Register(StateIDs.Drinking, new DrinkingState(this));
            Register(StateIDs.Mining, new MiningState(this));
            Register(StateIDs.Combat, new CombatState(this));
            Enter(StateIDs.Mining);
        }
コード例 #5
0
ファイル: Knowledge.cs プロジェクト: lithander/V7mBot
 public Predicate <TileMap.Tile> TypeFilter(TileMap.TileType typeMask, int heroID)
 {
     return(tile => (tile.Type & typeMask) > 0 && tile.Owner != heroID);
 }
コード例 #6
0
ファイル: Knowledge.cs プロジェクト: lithander/V7mBot
        //PREDICATES

        public Predicate <TileMap.Tile> TypeFilter(TileMap.TileType typeMask)
        {
            return(tile => (tile.Type & typeMask) > 0);
        }