Esempio n. 1
0
        public void PerformHeadMove(Direction d)
        {
            Debug.Assert(Alive);

            Debug.Assert(world.fields[Head.Y, Head.X].occupant == FastWorld.Occupant.Snake);
            Debug.Assert(world.fields[Head.Y, Head.X].id == index);

            // Write direction we left field in to old head position
            world.fields[Head.Y, Head.X] = world.fields[Head.Y, Head.X].WithModifiedDirection(d);

            Head = Head.Advanced(d);

            // Assert that the tile we are moving into is actually empty at this point
            Debug.Assert(world.fields[Head.Y, Head.X].occupant == FastWorld.Occupant.Empty);

            world.fields[Head.Y, Head.X] = new FastWorld.Field(FastWorld.Occupant.Snake, index, d);

            ++Length;
        }