Beispiel #1
0
        public bool Crashing(Car car, int carnum, out CheckLine line, out double _reward)
        {
            if (activation == null)
            {
                throw new Exception("활성화되지 않은 라인!");
            }

            Line left, right;

            car.car_vertex(out left, out right);
            bool   b            = false;
            PointF crashedPoint = new PointF();

            if (left.CrossLIne(this, ref crashedPoint))
            {
                b = true;
            }
            else if (right.CrossLIne(this, ref crashedPoint))
            {
                b = true;
            }


            if (b)
            {
                activation[carnum]          = false;
                nextLine.activation[carnum] = true;
                line    = nextLine;
                _reward = reward;
                return(true);
            }
            else
            {
                _reward = 0;
                line    = this;
                return(false);
            }
        }
Beispiel #2
0
 public CheckLine()
 {
     nextLine = this;
 }
Beispiel #3
0
 /// <summary>
 /// 다음번 선과 링크
 /// </summary>
 /// <param name="next">다음번 라인</param>
 public void Link(CheckLine next)
 {
     nextLine = next;
 }
Beispiel #4
0
        void makeCheckLines()
        {
            int half = TrackHeight / 2;

            //센터라인 양끝과 중앙, 반원형 1/3, 2/3 지점에 체크라인
            CheckLine make(CheckLine frontline, PointF p1, PointF p2, bool plus)
            {
                int size = TrackSize;

                if (!plus)
                {
                    size = -TrackSize;
                }

                CheckLine c0 = new CheckLine();

                c0.setPoint1((p1.X + p2.X) / 2, p1.Y);
                c0.setPoint2((p1.X + p2.X) / 2, p1.Y + size);
                frontline.Link(c0);
                c0.setreward(Bonusreward);

                CheckLine c1 = new CheckLine();

                c1.setPoint1(p2);
                c1.setPoint2(p2.X, p2.Y + size);
                c0.Link(c1);

                Linelist.Add(c0);
                Linelist.Add(c1);

                return(c1);
            }

            CheckLine make_round(CheckLine frontline, PointF center, int startdegree, int enddegree)
            {
                double radian_1 = m.to_radian * (startdegree + (enddegree - startdegree) / 3);
                double radian_2 = m.to_radian * (startdegree + (enddegree - startdegree) / 3 * 2);

                CheckLine c0 = new CheckLine();

                c0.setPoint1((int)(center.X + Math.Sin(radian_1) * half),
                             (int)(center.Y + Math.Cos(radian_1) * half));
                c0.setPoint2((int)(center.X + Math.Sin(radian_1) * (half + TrackSize)),
                             (int)(center.Y + Math.Cos(radian_1) * (half + TrackSize)));
                frontline.Link(c0);

                CheckLine c1 = new CheckLine();

                c1.setPoint1((int)(center.X + Math.Sin(radian_2) * half),
                             (int)(center.Y + Math.Cos(radian_2) * half));
                c1.setPoint2((int)(center.X + Math.Sin(radian_2) * (half + TrackSize)),
                             (int)(center.Y + Math.Cos(radian_2) * (half + TrackSize)));
                c0.Link(c1);

                Linelist.Add(c0);
                Linelist.Add(c1);

                return(c1);
            }

            CheckLine lastline = new CheckLine();

            lastline.setPoint1(CenterLine.point1.X, CenterLine.point1.Y + half);
            lastline.setPoint2(CenterLine.point1.X, CenterLine.point1.Y + half + TrackSize);



            firstgoal = make(lastline, new PointF(CenterLine.point1.X, CenterLine.point1.Y + half),
                             new PointF(CenterLine.point2.X, CenterLine.point2.Y + half), true);

            CheckLine line2 = make_round(firstgoal, CenterLine.point2, 0, 180);
            CheckLine line3 = new CheckLine();

            line3.setPoint1(CenterLine.point2.X, CenterLine.point2.Y - half);
            line3.setPoint2(CenterLine.point2.X, CenterLine.point2.Y - half - TrackSize);
            line2.Link(line3);
            Linelist.Add(line3);

            CheckLine line4 = make(line3, new PointF(CenterLine.point2.X, CenterLine.point2.Y - half),
                                   new PointF(CenterLine.point1.X, CenterLine.point1.Y - half), false);

            CheckLine line5 = make_round(line4, CenterLine.point1, 180, 360);

            line5.Link(lastline);

            for (int i = 0; i < carnum; i++)
            {
            }
            //firstgoal.Activate();
            //currentgoal = firstgoal;

            Linelist.Add(lastline);

            foreach (CheckLine c in Linelist)
            {
                c.Show();
            }
        }