示例#1
0
        bool TryMove()
        {
            CalMap();
            List <Pt> pts = GetBestWay();

            if (pts.Count < 2)
            {
                return(false);
            }
            Pt move = pts[pts.Count - 2];

            if (move.x > me.pos.x)
            {
                go.MoveEast();
            }
            else if (move.x < me.pos.x)
            {
                go.MoveWest();
            }
            else if (move.y < me.pos.y)
            {
                go.MoveSouth();
            }
            else if (move.y > me.pos.y)
            {
                go.MoveNorth();
            }
            else
            {
                return(false);
            }
            return(true);
        }
示例#2
0
        /// <summary>
        /// 第一次则返回true
        /// </summary>
        /// <param name="pt"></param>
        /// <param name="from"></param>
        /// <param name="add"></param>
        /// <returns></returns>
        bool NewComing(Pt pt, Pt from, int add)
        {
            if (cmap[pt.x, pt.y] == MIN_VALVE)
            {
                //防止炸弹感染自己位置
                if (from.x == me.pos.x && from.y == me.pos.y)
                {
                    SetCmap(pt, GetCmap(from) + add);
                    //不要问我其他,我只能说修复bug贼难受(这里是防止过度青睐炸弹!)
                    AddFinal_Addition(pt, map_addition[from.x, from.y]);
                }
                else
                {
                    SetCmap(pt, GetCmap(from) + add + map_addition[from.x, from.y]);
                }
                SetFromMap(pt, from);
                allWays.Add(pt);
                return(true);
            }

            //更新指向(最短路径)
            if (GetCmap(pt) < GetCmap(from) + add + map_addition[from.x, from.y])
            {
                SetCmap(pt, GetCmap(from) + add + map_addition[from.x, from.y]);
                SetFromMap(pt, from);
                return(true);
            }
            return(false);
        }
示例#3
0
        void SetBoxEffect(Pt a, int add, bool force = false, bool remember = true)
        {
            if (mapEffected[a.x, a.y] && !force)
            {
                return;
            }
            if (remember)
            {
                mapEffected[a.x, a.y] = true;
            }
            Pt pt = a;

            pt.x += 1;
            if (MapAvailable(pt))
            {
                AddFinal_Addition(pt, add);
            }
            pt.x -= 2;
            if (MapAvailable(pt))
            {
                AddFinal_Addition(pt, add);
            }
            pt.x += 1;
            pt.y += 1;
            if (MapAvailable(pt))
            {
                AddFinal_Addition(pt, add);
            }
            pt.y -= 2;
            if (MapAvailable(pt))
            {
                AddFinal_Addition(pt, add);
            }
        }
示例#4
0
 bool MapAvailable(Pt pt)
 {
     if (pt.x < 0 || pt.x > 13 || pt.y < 0 || pt.y > 13)
     {
         return(false);
     }
     return(true);
 }
示例#5
0
        /// <summary>
        /// 返回一系列点,最后一个点为第一步
        /// </summary>
        /// <returns></returns>
        List <Pt> GetBestWay()
        {
            List <Pt> pts  = new List <Pt>();
            Pt        best = Pt.start;
            int       max  = MIN_VALVE;

            for (int i = 0; i < cmap.GetLength(0); i++)
            {
                for (int j = 0; j < cmap.GetLength(1); j++)
                {
                    Print("地图", (cmap[i, j] + final_addition[i, j] + willness[i, j] + map_addition[i, j] + final_DangerAddition[i, j]).ToString() + " ");//cmap[i, j] + final_addition[i, j]

                    if (cmap[i, j] + final_addition[i, j] + willness[i, j] + map_addition[i, j] + final_DangerAddition[i, j] > max)
                    {
                        max  = cmap[i, j] + final_addition[i, j] + willness[i, j] + map_addition[i, j] + final_DangerAddition[i, j];
                        best = new Pt(i, j);
                    }
                }
                Print("地图", "\n");
            }

            Print("地图", "\n");


            //这里是重点调试的数据!·····················注意!

            //if (willness[best.x, best.y] > 400)
            //    willness[best.x, best.y] = 0;
            //else
            //    willness[best.x, best.y] += r.Next(110,220);
            willness[best.x, best.y] = 110;


            while (true)
            {
                if (best.x == Pt.start.x && best.y == Pt.start.y)
                {
                    break;
                }
                pts.Add(best);
                Print("", best.x + "," + best.y + " ");
                best = fromMap[best.x, best.y];
            }

            Print("", "myPos:" + me.pos.x + "," + me.pos.y + "\t\ttime:" + go.GetRemainingTime() + "\n\n\n");


            return(pts);
        }
示例#6
0
        //找到最近的玩家
        Player GetNearstPlayer()
        {
            Player best = null;
            float  len  = 999999;

            others.ForEach(x =>
            {
                if (!x.dead && Pt.Len(x.pos, me.pos) < len)
                {
                    best = x;
                    len  = Pt.Len(x.pos, me.pos);
                }
            });
            return(best);
        }
示例#7
0
        void CalMap(Pt pt, Pt from)
        {
            if (!MapAvailable(pt))
            {
                return;
            }

            // 地图信息    -1圈外 0可用 1可炸 2墙 3有炸弹
            switch (GetMap(pt))
            {
            case 0:

                if (!NewComing(pt, from, move_bonus))
                {
                    return;
                }

                //查看走这步是不是个坑
                if (nearst_enemy_len < 3)
                {
                    CheckNoWayDanger(pt, (int)(-(4 * bonus_box)));
                }

                //继续走
                CalMap(new Pt(pt.x - 1, pt.y), pt);
                CalMap(new Pt(pt.x + 1, pt.y), pt);
                CalMap(new Pt(pt.x, pt.y + 1), pt);
                CalMap(new Pt(pt.x, pt.y - 1), pt);

                break;

            case 1:
                SetBoxEffect(pt, bonus_box);
                break;

            case 2:
                break;

            case 3:
                //SetBombEffect(pt, -bonus_box);
                break;
            }
        }
示例#8
0
        /// <summary>
        /// 是否直线连同
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        bool IsPassiable(Pt from, Pt to)
        {
            if (from.y == to.y)
            {
                if (from.x > to.x)
                {
                    Pt temp = from;
                    from = to;
                    to   = temp;
                }

                for (int i = from.x + 1; i < to.x; i++)
                {
                    if (!MapAvailable(new Pt(i, from.y)) || (GetMap(new Pt(i, from.y)) != 0 && GetMap(new Pt(i, from.y)) != 3))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            else if (from.x == to.x)
            {
                if (from.y > to.y)
                {
                    Pt temp = from;
                    from = to;
                    to   = temp;
                }

                for (int i = from.y + 1; i < to.y; i++)
                {
                    if (!MapAvailable(new Pt(from.x, i)) || GetMap(new Pt(from.x, i)) != 0)
                    {
                        return(false);
                    }
                }
                return(true);
            }
            return(false);
        }
示例#9
0
        void CheckNoWayDanger(Pt a, int add)
        {
            if (mapEffected[a.x, a.y])
            {
                return;
            }
            int count = 0;

            mapEffected[a.x, a.y] = true;
            Pt pt = a;

            pt.x += 1;
            if (MapAvailable(pt))
            {
                if (GetMap(pt) != 0)
                {
                    count++;
                }
            }
            else
            {
                count++;
            }

            pt.x -= 2;
            if (MapAvailable(pt))
            {
                if (GetMap(pt) != 0)
                {
                    count++;
                }
            }
            else
            {
                count++;
            }
            pt.x += 1;
            pt.y += 1;
            if (MapAvailable(pt))
            {
                if (GetMap(pt) != 0)
                {
                    count++;
                }
            }
            else
            {
                count++;
            }
            pt.y -= 2;
            if (MapAvailable(pt))
            {
                if (GetMap(pt) != 0)
                {
                    count++;
                }
            }
            else
            {
                count++;
            }

            pt.y += 1;
            if (count >= 3)
            {
                final_DangerAddition[pt.x, pt.y] += add;
            }
        }
示例#10
0
 bool IsAnyBoomerHere()
 {
     return(others.Exists(x => Pt.Len(x.pos, me.pos) <= 2 && x.bomb_cd > 0));
 }
示例#11
0
        /// <summary>
        /// 人工智能的崛起,根据环境只适应变化,并主动迭代升级
        /// </summary>
        void RefreshSetting()
        {
            Player aim = GetNearstPlayer();

            nearst_enemy_len = Pt.Len(aim.pos, me.pos);
            //1000为平常
            if (nearst_enemy_len < 8)
            {
                enemy_bonus = 500 + (8 - (int)nearst_enemy_len) * 250;   //max:2500
            }
            if (GetBoxCount() < 7 || go.GetRemainingTime() < 30)
            {
                //enemy_bonus += (10 - GetBoxCount()) * 200;  //max:2000
                if (GetBoxCount() < 10)
                {
                    bonus_box = 1500 + (10 - GetBoxCount()) * 50;
                }
            }


            if (others.Exists(x => x.hp - me.hp >= 20) && me.hp < 50)
            {
                enemy_bonus += -1000 - (50 - me.hp) * 60;  //max:-4000
            }
            //保重身体
            if (me.hp < 20 && go.GetRemainingTime() > 10 && GetBoxCount() > 4)
            {
                enemy_bonus += -2000;
            }


            if (me.shoot_cd > 0)
            {
                enemy_bonus += -(int)(me.shoot_cd * 500);
            }
            if (me.bomb_cd == 0)
            {
                enemy_bonus += -2000;
            }



            //移动消耗动态变化
            if (go.CanBomb())
            {
                move_bonus = -250;
            }
            else
            {
                move_bonus = -200;
            }

            //不要挨近我!
            if (disgust > 4000)
            {
                disgust = 4000;
            }
            if (disgust > 0)
            {
                disgust -= 15;
            }
            if (disgust < 0)
            {
                disgust = 0;
            }
            //1s---->+1500
            if (nearst_enemy_len < 1)
            {
                disgust += 45;
            }

            enemy_bonus -= disgust;
        }
示例#12
0
 int GetCmap(Pt pt)
 {
     return(cmap[pt.x, pt.y]);
 }
示例#13
0
 public static float Len(Pt a, Pt b)
 {
     return((float)Math.Pow((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y), 0.5));
 }
示例#14
0
 void SetCmap(Pt pt, int num)
 {
     cmap[pt.x, pt.y] = num;
 }
示例#15
0
 void SetFromMap(Pt pt, Pt from)
 {
     fromMap[pt.x, pt.y] = from;
 }
示例#16
0
        void SetBombEffect2(Pt a, int add)
        {
            if (mapEffected[a.x, a.y])
            {
                return;
            }
            mapEffected[a.x, a.y] = true;
            Pt pt = a;

            if (MapAvailable(pt))
            {
                map_addition[pt.x, pt.y] += 4 * add;
                AddFinal_Addition(pt, 4 * add);
            }

            pt.x += 1;
            if (MapAvailable(pt))
            {
                map_addition[pt.x, pt.y] += 4 * add;
                AddFinal_Addition(pt, 4 * add);
                //将炸弹附近的箱子视为空白
                if (GetMap(pt) == 1)
                {
                    if (mapEffected[pt.x, pt.y])
                    {
                        SetBoxEffect(pt, -bonus_box, true);
                    }
                    else
                    {
                        mapEffected[pt.x, pt.y] = true;
                    }
                }
            }
            pt.x -= 2;
            if (MapAvailable(pt))
            {
                map_addition[pt.x, pt.y] += 4 * add;
                AddFinal_Addition(pt, 4 * add);
                if (GetMap(pt) == 1)
                {
                    if (mapEffected[pt.x, pt.y])
                    {
                        SetBoxEffect(pt, -bonus_box, true);
                    }
                    else
                    {
                        mapEffected[pt.x, pt.y] = true;
                    }
                }
            }
            pt.x += 1;
            pt.y += 1;
            if (MapAvailable(pt))
            {
                map_addition[pt.x, pt.y] += 4 * add;
                AddFinal_Addition(pt, 4 * add);
                if (GetMap(pt) == 1)
                {
                    if (mapEffected[pt.x, pt.y])
                    {
                        SetBoxEffect(pt, -bonus_box, true);
                    }
                    else
                    {
                        mapEffected[pt.x, pt.y] = true;
                    }
                }
            }
            pt.y -= 2;
            if (MapAvailable(pt))
            {
                map_addition[pt.x, pt.y] += 4 * add;
                AddFinal_Addition(pt, 4 * add);
                if (GetMap(pt) == 1)
                {
                    if (mapEffected[pt.x, pt.y])
                    {
                        SetBoxEffect(pt, -bonus_box, true);
                    }
                    else
                    {
                        mapEffected[pt.x, pt.y] = true;
                    }
                }
            }

            ////斜角
            //pt.x += 1;
            //if (MapAvailable(pt))
            //{
            //    map_addition[pt.x, pt.y] += add / 10;
            //    AddFinal_Addition(pt, add / 10);
            //}
            //pt.x -= 2;
            //if (MapAvailable(pt))
            //{
            //    map_addition[pt.x, pt.y] += add / 10;
            //    AddFinal_Addition(pt, add / 10);
            //}
            //pt.y += 2;
            //if (MapAvailable(pt))
            //{
            //    map_addition[pt.x, pt.y] += add / 10;
            //    AddFinal_Addition(pt, add / 10);
            //}
            //pt.x += 2;
            //if (MapAvailable(pt))
            //{
            //    map_addition[pt.x, pt.y] += add / 10;
            //    AddFinal_Addition(pt, add / 10);
            //}
        }
示例#17
0
 void AddFinal_Addition(Pt pt, int num)
 {
     final_addition[pt.x, pt.y] += num;
 }
示例#18
0
 int GetMap(Pt pt)
 {
     return(map[pt.x, pt.y]);
 }
示例#19
0
        /// <summary>
        /// 避免自残
        /// </summary>
        void AvoidSuicide()
        {
            if (allWays.Count == 3)
            {
                allWays.ForEach(x =>
                {
                    Pt pt     = x;
                    int count = 0;
                    pt.x     += 1;
                    if (MapAvailable(pt) && GetMap(pt) == 0)
                    {
                        count++;
                    }
                    pt.x -= 2;
                    if (MapAvailable(pt) && GetMap(pt) == 0)
                    {
                        count++;
                    }
                    pt.x += 1;
                    pt.y += 1;
                    if (MapAvailable(pt) && GetMap(pt) == 0)
                    {
                        count++;
                    }
                    pt.y -= 2;
                    if (MapAvailable(pt) && GetMap(pt) == 0)
                    {
                        count++;
                    }

                    pt.y += 1;
                    if (count >= 2)
                    {
                        AddFinal_Addition(pt, -bonus_box * 4);
                    }
                });
            }
            else if (allWays.Count == 4)
            {
                allWays.ForEach(x =>
                {
                    Pt pt     = x;
                    int count = 0;
                    pt.x     += 1;
                    if (MapAvailable(pt) && GetMap(pt) == 0)
                    {
                        count++;
                    }
                    pt.x -= 2;
                    if (MapAvailable(pt) && GetMap(pt) == 0)
                    {
                        count++;
                    }
                    pt.x += 1;
                    pt.y += 1;
                    if (MapAvailable(pt) && GetMap(pt) == 0)
                    {
                        count++;
                    }
                    pt.y -= 2;
                    if (MapAvailable(pt) && GetMap(pt) == 0)
                    {
                        count++;
                    }

                    pt.y += 1;
                    if (count >= 3)
                    {
                        AddFinal_Addition(pt, -bonus_box * 4);
                    }
                });
            }
        }