Beispiel #1
0
 public void CallMain()
 {
     var ans = ExecuteAi(this.code, 0, new PacmanEnvironmentFrame(EncodeCurrentState(), null), 0);
     this.currentState = ans.Item1;
     this.stepFunction = ans.Item2;
 }
Beispiel #2
0
 public PacmanEnvironmentFrame(
     PacmanValue arg1,
     PacmanValue arg2)
 {
     Parent = null;
     IsValid = true;
     Values = new List<PacmanValue>() { arg1, arg2 };
 }
Beispiel #3
0
 public static PacmanValue Cons(PacmanValue item1, PacmanValue item2)
 {
     return new PacmanValue(PacmanTag.Cons) { Item1 = item1, Item2 = item2 };
 }
Beispiel #4
0
        protected override int TickImpl()
        {
            var ans = ExecuteAi(this.code, this.stepFunction.IntValue, new PacmanEnvironmentFrame(this.currentState, EncodeCurrentState()), this.ScheduledTick);
            if (!Enum.IsDefined(typeof(Direction), ans.Item2.IntValue))
            {
                throw new Exception(); // TODO
            }
            this.currentState = ans.Item1;
            this.Direction = (Direction)ans.Item2.IntValue;

            var newPosition = this.CurrentPosition.Move(this.Direction);
            if (this.Map[newPosition] != MapCell.Wall)
            {
                this.CurrentPosition = newPosition;
                Program.LogMove(this.ScheduledTick, @"\\", this.CurrentPosition);
            }

            return foods.Contains(this.Map[this.CurrentPosition]) ? 137 : 127;
        }