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; }
public Player(GamePosition pos) : base(pos) { }
public Actor(GamePosition pos) { position = pos; }
private bool IsBlockAt(GamePosition pos) { return Blocks.ContainsKey(pos); }
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); }
public Block(BlockType blockType, GamePosition position) { type = blockType; pos = position; }
public LevelObservation(GamePosition position, bool hasBlock) { this.position = position; this.hasBlock = hasBlock; }
public LevelInputNeuron(GamePosition position, bool block) : base() { this.screenPosition = position; blockIsThere = block; }
private GamePosition ScreenToWorldPosition(GamePosition screenPos) { return screenPos; //TODO }