Beispiel #1
0
        public Vector2 getBestDirection(Brick[] bricks, Stone[] stones, Tank myplayer, Tank[] tanks, List<CoinPile> coins, List<LifePack> lifes)
        {
            Vector3 greedyDir=getGreedyDirection(bricks, myplayer, coins, lifes);
            Vector3 fightDir = getFightDirection(bricks, stones, myplayer, tanks);
            //if ( fightDir.Z>0)
            //    return new Vector2(0, 0);

            Vector2 move;
            if(greedyDir.Z>=fightDir.Z)
                move= new Vector2(greedyDir.X, greedyDir.Y);
            else
                move= new Vector2(0, 0);
            return move;
        }
Beispiel #2
0
        public Vector3 getFightDirection( Brick[] bricks, Stone[] stones,Tank myplayer, Tank[] tanks)
        {
            int[,] map = new int[gridsize, gridsize];
            for (int i = 0; i < stones.Length; i++)
                map[(int)stones[i].Position.X, (int)stones[i].Position.Y] = 1;
            for (int i = 0; i < bricks.Length; i++)
                map[(int)bricks[i].Position.X, (int)bricks[i].Position.Y] = 1;
            for (int i = 0; i < tanks.Length; i++)
            {
                if (tanks[i] != null)
                    map[(int)tanks[i].Position.X, (int)tanks[i].Position.Y] = 5+i;
            }

            bool shoot = false;
            Vector2 cell = myplayer.Position;
            for (int i = 1; i < 4; i++)
            {
                cell = myplayer.Position + myplayer.Direction * i;
                if (cell.X < 0 || cell.Y < 0 || cell.X >= gridsize || cell.Y >= gridsize)
                    break;
                if (map[(int)cell.X, (int)cell.Y] == 1)
                    break;
                else if (map[(int)cell.X, (int)cell.Y] >= 5)
                {
                    shoot = true;
                    break;
                }
            }
            int profit=0;
            if (shoot)
            {
                Tank t = tanks[map[(int)cell.X, (int)cell.Y]-5];
                if (t.Health>0)
                profit = (int)(t.Coins/t.Health);
            }
            return new Vector3(0, 0, profit);
        }
Beispiel #3
0
        public void init(int griddim, Stone[] stones,Water[] waters )
        {
            Vector2[] stns=new Vector2[stones.Length + waters.Length];
            for (int i = 0; i < stones.Length; i++)
                stns[i]=stones[i].Position;
            for (int i = 0; i < waters.Length; i++)
                stns[stones.Length + i] = waters[i].Position;

            this.gridsize = griddim;
            pathFinder=new AStarSearch(gridsize,stns);
        }