예제 #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;
        }
예제 #2
0
파일: Player.cs 프로젝트: TheAsuro/Asuro_AI
 public Player(GamePosition pos)
     : base(pos)
 {
 }
예제 #3
0
파일: Player.cs 프로젝트: TheAsuro/Asuro_AI
 public Actor(GamePosition pos)
 {
     position = pos;
 }
예제 #4
0
파일: Level.cs 프로젝트: TheAsuro/Asuro_AI
 private bool IsBlockAt(GamePosition pos)
 {
     return Blocks.ContainsKey(pos);
 }
예제 #5
0
파일: Level.cs 프로젝트: TheAsuro/Asuro_AI
        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);
        }
예제 #6
0
파일: Level.cs 프로젝트: TheAsuro/Asuro_AI
 public Block(BlockType blockType, GamePosition position)
 {
     type = blockType;
     pos = position;
 }
예제 #7
0
 public LevelObservation(GamePosition position, bool hasBlock)
 {
     this.position = position;
     this.hasBlock = hasBlock;
 }
예제 #8
0
 public LevelInputNeuron(GamePosition position, bool block)
     : base()
 {
     this.screenPosition = position;
     blockIsThere = block;
 }
예제 #9
0
 private GamePosition ScreenToWorldPosition(GamePosition screenPos)
 {
     return screenPos; //TODO
 }