Esempio n. 1
0
        private bool Advance()
        {
            List<LevelObservation> obs = new List<LevelObservation>();

            for (int x = leftCameraBound; x < leftCameraBound + width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    GamePosition pos = new GamePosition(x, y);
                    if (level.Blocks.ContainsKey(pos))
                        obs.Add(new LevelObservation(pos, true));
                    else
                        obs.Add(new LevelObservation(pos, false));
                }
            }

            leftPressed = false;
            rightPressed = false;
            upPressed = false;

            network.ApplyObservations(obs.ToArray());
            network.FireOutputs();

            level.MovePlayer(leftPressed, rightPressed, upPressed);

            if (level.PlayerPosition.X > tempX)
                tempCounter = 0;
            else
                tempCounter++;

            MarkControlActive(pnlLeft, leftPressed);
            MarkControlActive(pnlRight, rightPressed);
            MarkControlActive(pnlUp, upPressed);

            if (tempCounter > 30)
            {
                LogSafe("Death by boredom, x-pos: " + level.PlayerPosition.X);
                return false;
            }

            if (level.PlayerPosition.Y < 0)
            {
                LogSafe("Death by falling, x-pos: " + level.PlayerPosition.X);
                return false;
            }

            return true;
        }
Esempio n. 2
0
 public Player(GamePosition pos)
     : base(pos)
 {
 }
Esempio n. 3
0
 public Actor(GamePosition pos)
 {
     position = pos;
 }
Esempio n. 4
0
 private bool IsBlockAt(GamePosition pos)
 {
     return Blocks.ContainsKey(pos);
 }
Esempio n. 5
0
        public void Draw(Graphics target, int leftCameraBound, int screenWidth, int screenHeight, int blockWidth, int blockHeight)
        {
            target.Clear(Color.Black);

            // Draw blocks
            for (int x = leftCameraBound; x < leftCameraBound + screenWidth; x++)
            {
                for (int y = 0; y < screenHeight; y++)
                {
                    GamePosition pos = new GamePosition(x, y);
                    if (Blocks.ContainsKey(pos))
                    {
                        target.DrawRectangle(Pens.Green, (x * blockWidth), ((screenHeight - y - 1) * blockHeight), blockWidth, blockHeight);
                    }
                }
            }

            // Draw player
            target.DrawEllipse(Pens.Green, (player.Position.X * blockWidth), ((screenHeight - player.Position.Y - 1) * blockHeight), blockWidth, blockHeight);
        }
Esempio n. 6
0
 public Block(BlockType blockType, GamePosition position)
 {
     type = blockType;
     pos = position;
 }
Esempio n. 7
0
 public LevelObservation(GamePosition position, bool hasBlock)
 {
     this.position = position;
     this.hasBlock = hasBlock;
 }
Esempio n. 8
0
 public LevelInputNeuron(GamePosition position, bool block)
     : base()
 {
     this.screenPosition = position;
     blockIsThere = block;
 }
Esempio n. 9
0
 private GamePosition ScreenToWorldPosition(GamePosition screenPos)
 {
     return screenPos; //TODO
 }