Esempio n. 1
0
        public void Draw(Graphics g)
        {
            Brush clr;

            if (state == (byte)OrbStates.TRAVELLING)
            {
                clr = Brushes.White;
                if (Owner != Keys.None && (!HEADS.ContainsKey(Owner) || HEADS[Owner].Died))
                {
                    NewOwner();
                }
            }
            else if (state == (byte)OrbStates.BULLET)
            {
                double c = Math.Pow(Math.Sin(bulletTime / 8), 2) * 2 / 3;
                clr = new SolidBrush(Color.FromArgb((int)(color.R + (255 - color.R) * c), (int)(color.G + (255 - color.G) * c), (int)(color.B + (255 - color.B) * c)));
            }
            else
            {
                clr = new SolidBrush(Color.FromArgb(!isWhite && KingOfTheHill && HEADS[Owner].INVINCIBLE? 128 : 255, color));
            }

            g.FillEllipse(clr, (float)pos.X - this.r, (float)pos.Y - this.r, r * 2, r * 2);
            if (ContrastMode && state.GetHashCode() >= 3)
            {
                g.DrawEllipse(Pens.Black, (float)pos.X - r, (float)pos.Y - r, r * 2, r * 2);
                contrast_color.Set(BoolToInt(Map.InOrbit(pos) && !isBullet));
                g.FillEllipse(new SolidBrush(AnimatableColor.Lurp(Color.Black, Color.White, (float)contrast_color)), (float)pos.X - 3, (float)pos.Y - 3, 6, 6);
            }

            if (!isWhite && HEADS[Owner].isBounty)
            {
                g.DrawEllipse(new Pen(Color.Red, 2f), (float)pos.X - r, (float)pos.Y - r, r * 2, r * 2);
            }

            ///Debug draw ID
            //g.DrawString(this.ID.ToString(), new Font(FONT, 13), Brushes.Black, (PointF) pos);
        }
Esempio n. 2
0
        private void fetch_input()
        {
            //inorbit, rotation, x, y, orbs in tail
            //twelve rays
            //each has distance to first { orbit, blast, orb, orb, player }
            //type: player | blast | orb(w) | orb(p) | wall | orbits
            //65 input nodes total
            if (!HEADS.ContainsKey(Key) || Map.phase != Phases.NONE)
            {
                return;
            }
            Head head = HEADS[Key];

            if (head.Died)
            {
                return;
            }

            ray.Set(head.pos, head.v);

            Input[0].add(BoolToInt(Map.InOrbit(head.pos)));
            Input[1].add(head.v.A / PI);
            Input[2].add(head.pos.X / W * 2 - 1);
            Input[3].add(head.pos.Y / W);
            lock (Orb.OrbLock) Input[4].add(head.tail.length == 0? -1 : 1 / head.tail.length);


            for (int i = 0; i < 12; i++)
            {
                foreach (Circle orbit in Map.Orbits)
                {
                    if (ray.Hit(orbit))
                    {
                        distances.Add(ray.Distance(orbit));
                    }
                }
                if (distances.Count == 0)
                {
                    distances.Add(diagonal);
                }
                Input[5 + 5 * i].add(distances.Min() / diagonal);
                distances.Clear();

                lock (Blast.BlastLock) foreach (Circle blast in Blast.All)
                    {
                        if (ray.Hit(blast))
                        {
                            distances.Add(ray.Distance(blast));
                        }
                    }
                if (distances.Count == 0)
                {
                    distances.Add(diagonal);
                }
                Input[6 + 5 * i].add(distances.Min() / diagonal);
                distances.Clear();

                lock (Orb.OrbLock) {
                    int    color = 760;
                    double d     = diagonal;
                    double d_temp;
                    foreach (Orb orb in Orb.All)
                    {
                        if (orb.state == (byte)OrbStates.TRAVELLING)
                        {
                            d_temp = ray.AutoDistance(orb);
                        }
                        else
                        {
                            d_temp = diagonal;
                        }

                        if (d_temp < d)
                        {
                            d     = d_temp;
                            color = (orb.color.R + orb.color.G + orb.color.B);
                        }
                    }
                    Input[7 + 5 * i].add(d / diagonal);
                    Input[8 + 5 * i].add(color / 760d);
                }

                lock (ActiveLock) foreach (Keys k in ActiveKeys)
                    {
                        if (k != Key && ray.Hit(HEADS[k]))
                        {
                            distances.Add(ray.Distance(HEADS[k]));
                        }
                    }
                if (distances.Count == 0)
                {
                    distances.Add(diagonal);
                }
                Input[9 + 5 * i].add(distances.Min() / diagonal);
                distances.Clear();

                ray.laser.A += deltaA;
            }

            // 66th input neuron
            Input[65].add(1); // Always on
        }