Exemplo n.º 1
0
        private static Tile?PlayerMoveTile(Tile player, AgentAction action, MutableMap map, out bool spawnBomb)
        {
            spawnBomb = true;
            switch (action)
            {
            case AgentAction.BombDown:
                return(map.GetDown(player));

            case AgentAction.BombLeft:
                return(map.GetLeft(player));

            case AgentAction.BombRight:
                return(map.GetRight(player));

            case AgentAction.BombUp:
                return(map.GetUp(player));
            }

            spawnBomb = false;
            return(action switch
            {
                AgentAction.GoDown => map.GetDown(player),
                AgentAction.GoLeft => map.GetLeft(player),
                AgentAction.GoRight => map.GetRight(player),
                AgentAction.GoUp => map.GetUp(player),
                _ => player
            });
Exemplo n.º 2
0
        public static Map GetNewState(Map map, AgentAction action)
        {
            var result = new MutableMap(map.Size, new Dictionary <VectorInt2, Tile>(map));
            var player = result.PlayerTile;

            if (player != default && action != AgentAction.DoNothing)
            {
                var newTile = PlayerMoveTile(player, action, result, out var bombing);

                if (newTile != null && newTile.Value.IsWalkable)
                {
                    result[newTile.Value.Position] = new Tile(newTile.Value.Position, TileTypes.Player);
                    if (bombing)
                    {
                        result[player.Position] = new Tile(player.Position, TileTypes.Bomb4);
                    }
                    else
                    {
                        result[player.Position] = new Tile(player.Position, TileTypes.Empty);
                    }
                }
            }

            var gonnaBlast = result.BlastZones
                             .Where(x => x.Value == 1)
                             .Select(x => x.Key.Position);

            foreach (var tilePos in gonnaBlast)
            {
                result[tilePos] = new Tile(tilePos, TileTypes.Empty);
            }

            //Console.WriteLine(result.PlayerTile);
            return(result.ToImmutableMap());
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void verifyConstraintOn(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList nodeIds, org.neo4j.storageengine.api.NodePropertyAccessor nodePropertyAccessor, org.neo4j.storageengine.api.schema.StoreIndexDescriptor descriptor) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        private static void VerifyConstraintOn(LongArrayList nodeIds, NodePropertyAccessor nodePropertyAccessor, StoreIndexDescriptor descriptor)
        {
            MutableMap <Value, long> points = Maps.mutable.empty();
            MutableLongIterator      iter   = nodeIds.longIterator();

            try
            {
                while (iter.hasNext())
                {
                    long  id    = iter.next();
                    Value value = nodePropertyAccessor.GetNodePropertyValue(id, descriptor.Schema().PropertyId);
                    long? other = points.getIfAbsentPut(value, id);
                    if (other.Value != id)
                    {
                        throw new IndexEntryConflictException(other.Value, id, value);
                    }
                }
            }
            catch (EntityNotFoundException e)
            {
                throw new Exception("Failed to validate uniqueness constraint", e);
            }
        }