RunningImageMeanAndStandardDeviationCL::RunningImageMeanAndStandardDeviationCL(const uvec2& layerDimension, const size2_t& workgroupSize)
    : pingPongIndex_(0)
    , workGroupSize_(workgroupSize)
    , kernel_(nullptr) {
    standardDeviation_[0] = Layer(layerDimension, DataVec4Float32::get());
    standardDeviation_[1] = Layer(layerDimension, DataVec4Float32::get());
    mean_[0] = Layer(layerDimension, DataVec4Float32::get());
    mean_[1] = Layer(layerDimension, DataVec4Float32::get());
    kernel_ = addKernel("statistics/runningmeanandstandarddeviationkernel.cl", "runningMeanAndStandardDeviationKernel");
}
Ejemplo n.º 2
0
void Scanmatcher::initializeNdt(pose_t &pose, points2_t &points) {
  // initialize layers
  layer_.clear();
  points_=std::move(points);
  layer_.push_back(Layer(&points_, 8, max_range_));
  for (size_t i = 1; i < layers_count_; ++i) {
    layer_.push_back(Layer(&points_, static_cast<size_t>(std::pow(8, i)), max_range_));
  }

  pose_ = std::move(pose);
  
  initialized_ = true;
}
Ejemplo n.º 3
0
Net::Net(const std::vector<int>& topology) {
	
	// Create 'topology.size' layers
	size_t numLayers = topology.size();
	
	// For all news layers
	for (size_t layerNum = 0; layerNum < numLayers; ++layerNum) {
		
		// Add a new layer
		layers.push_back(Layer());
		
		// Get the size of the next layer, used to create neurons that have numOuputs Connections
		size_t numOutputs = layerNum == topology.size() - 1 ? 0 : topology[layerNum + 1];


		// We have a new layer, now fill it with neurons, and
		// add a bias neuron in each layer.
		for (size_t neuronNum = 0; neuronNum <= topology[layerNum]; ++neuronNum) {
			// Add Neuronof neuroNums size
			layers.back().push_back(Neuron(numOutputs, neuronNum));
		}

		// Force the bias node's output to 1.0 (it was the last neuron pushed in this layer):
		layers.back().back().setOutputVal(1.0);
	}
}
Ejemplo n.º 4
0
void aRTstatictable::Create(SEXP options)
{
	string id   = GET_STRING_ELEMENT  (options, aRTstrId);
	int length  = GET_INTEGER_ELEMENT (options, "length");
	bool genids = GET_BOOL_ELEMENT    (options, "generateids");

	TeAttributeList attList;
	TeAttribute at;
			
    at.rep_.type_         = TeSTRING;
    at.rep_.numChar_      = length;
    at.rep_.name_         = id;
    at.rep_.isPrimaryKey_ = true;

    attList.push_back(at);

	TeTable attTable(TableName, attList, id, id, TeAttrStatic);

	PrintSilent("Creating static table \'%s\' on layer \'%s\' ... ", TableName.c_str(), LayerName.c_str());
	if( !Layer()->createAttributeTable(attTable) )
	{
		stringstream err;
		err << "Could not create the table:"
			<< Database->errorMessage() << endl;
		error( StreamToChar(err) );
	}
	PrintSilentYes;

	if(genids) CreateLinkIds(id);
}
Ejemplo n.º 5
0
void DBGridIF::DiscreteStats() {
    DBInt recordID, layerID;
    DBFloat area, sumArea = 0.0;
    DBPosition pos;
    DBObjTableField *areaFLD = ItemTable->Field(DBrNGridArea);
    DBObjTableField *percentFLD = ItemTable->Field(DBrNGridPercent);
    DBObjRecord *layerRec, *record;

    for (recordID = 0; recordID < ItemTable->ItemNum(); ++recordID) {
        record = ItemTable->Item(recordID);
        areaFLD->Float(record, 0.0);
        percentFLD->Float(record, 0.0);
    }
    for (layerID = 0; layerID < LayerNum(); ++layerID) {
        layerRec = Layer(layerID);
        for (pos.Row = 0; pos.Row < RowNum(); ++pos.Row)
            for (pos.Col = 0; pos.Col < ColNum(); ++pos.Col)
                if ((record = GridItem(layerRec, pos)) != (DBObjRecord *) NULL) {
                    area = CellArea(pos);
                    sumArea += area;
                    areaFLD->Float(record, areaFLD->Float(record) + area);
                }
    }
    for (recordID = 0; recordID < ItemTable->ItemNum(); ++recordID) {
        record = ItemTable->Item(recordID);
        percentFLD->Float(record, areaFLD->Float(record) * 100.0 / sumArea);
    }
}
Ejemplo n.º 6
0
/**
 * \brief Returns control to the hero after its hookshot movement.
 *
 * This function is called when the hero has finished the hookshot movement.
 * It checks the validity of the destination position.
 */
void Hero::HookshotState::finish_movement() {

  Hero& hero = get_hero();
  const Rectangle& hero_position = hero.get_bounding_box();
  Layer layer = hero.get_layer();
  Map& map = get_map();
  MapEntities& entities = get_entities();

  if (layer == LAYER_LOW || !map.has_empty_ground(layer, hero_position)) {
    // the hero is totally on the same layer: no problem
    hero.start_state_from_ground();
  }
  else {
    // a part of the hero is on empty tiles: this is often illegal, especially
    // if there are jumpers; allow this only if tiles on
    // the lower layer are not obstacles, and go to this layer
    layer = Layer(layer - 1);
    if (!map.test_collision_with_obstacles(layer, hero_position, hero)) {
      Sound::play("hero_lands");
      entities.set_entity_layer(hero, layer);
      hero.start_state_from_ground();
    }
    else {
      // illegal position: get back to the start point
      // TODO: get back to the closest valid point from the destination instead
      Sound::play("hero_hurt");
      hero.set_state(new BackToSolidGroundState(hero, false, 0, true));
    }
  }
}
Ejemplo n.º 7
0
void XMLWriter::Scene(QDomElement& body){
    for(int i=0; i<mpMng->mList.count(); i++){
        auto scene = doc.createElement("Scene"+QString::number(i+1));
        scene.setAttribute("id",mpMng->mList[i]->ID());
        body.appendChild(scene);
        Layer(scene,i);
    }
}
Ejemplo n.º 8
0
Layer
EditorMap::get_layer(int i)
{
  if (i >= 0 && i < static_cast<int>(impl->layers.size()))
    return impl->layers[i];
  else
    return Layer();
}
Ejemplo n.º 9
0
Net::Net(vector<int> &topology){

	for(int i = 0; i < topology.size(); i++){
		if(i==0){
			m_topology.push_back(Layer(topology[i], 'i'));		// Creates input layer
		}
		else if(i==topology.size()-1){

			m_topology.push_back(Layer(topology[i], 'o'));		// Creates output layer
		}
		else{

			m_topology.push_back(Layer(topology[i], 'h'));		// Creates hidden layer

		}
	}
};
Ejemplo n.º 10
0
Background::Background(sf::Vector2u targetSize) {
	_pivot = sf::Vector2f(targetSize.x/2.0,targetSize.y/2.0);
	_test.setTexture(Resources::textureTest);

    layers.push_back(Layer(10));
    layers.push_back(Layer(10));
    layers.push_back(Layer(10));

    layers[0].setFactor(0.0);
    layers[1].setFactor(0.3);
    layers[2].setFactor(2.5);

    layers[0].setTexture(Resources::layer0,3);
    layers[1].setTexture(Resources::layer2,5);
    layers[2].setTexture(Resources::layer1,5);

}
Ejemplo n.º 11
0
void UILayerManager::PushTopLayer(UILayer* pkLayer, const UIUserDataPtr& spUserData)
{
	if(pkLayer)
	{
		addChild(pkLayer, 3);
		m_kTopLayerStack.PushBack(Layer(pkLayer, spUserData));
		pkLayer->SetActive(true, spUserData);
	}
}
Ejemplo n.º 12
0
Network::Network(vector<int> arch)
{
	for (unsigned int i=1; i < arch.size(); ++i)
	{
        layers.push_back(Layer(arch[i],arch[i-1]));
	}
	
	printout();
}
Ejemplo n.º 13
0
/**
 * @brief Creates an instance from an input stream.
 *
 * The input stream must respect the syntax of this entity type.
 *
 * @param game the game that will contain the entity created
 * @param is an input stream
 * @param layer the layer
 * @param x x coordinate of the entity
 * @param y y coordinate of the entity
 * @return the instance created
 */
MapEntity* Stairs::parse(Game &game, std::istream &is, Layer layer, int x, int y) {

  std::string name;
  int direction, subtype;

  FileTools::read(is, name);
  FileTools::read(is, direction);
  FileTools::read(is, subtype);

  return new Stairs(name, Layer(layer), x, y, direction, Subtype(subtype));
}
Ejemplo n.º 14
0
	ForwardRenderQueue::Layer& ForwardRenderQueue::GetLayer(int i)
	{
		auto it = layers.find(i);
		if (it == layers.end())
			it = layers.insert(std::make_pair(i, Layer())).first;
		
		Layer& layer = it->second;
		layer.clearCount = 0;

		return layer;
	}
Ejemplo n.º 15
0
/**
 * @brief Creates an instance from an input stream.
 *
 * The input stream must respect the syntax of this entity type.
 *
 * @param game the game that will contain the entity created
 * @param is an input stream
 * @param layer the layer
 * @param x x coordinate of the entity
 * @param y y coordinate of the entity
 * @return the instance created
 */
MapEntity* Sensor::parse(Game &game, std::istream &is, Layer layer, int x, int y) {

  std::string name;
  int width, height, subtype;

  FileTools::read(is, width);
  FileTools::read(is, height);
  FileTools::read(is, name);
  FileTools::read(is, subtype);
 
  return new Sensor(name, Layer(layer), x, y, width, height, Subtype(subtype));
}
Ejemplo n.º 16
0
/**
 * @brief Creates an instance from an input stream.
 *
 * The input stream must respect the syntax of this entity type.
 *
 * @param game the game that will contain the entity created
 * @param is an input stream
 * @param layer the layer
 * @param x x coordinate of the entity
 * @param y y coordinate of the entity
 * @return the instance created
 */
MapEntity* DynamicTile::parse(Game &game, std::istream &is, Layer layer, int x, int y) {

  int width, height, tile_pattern_id, enabled;
  std::string name;

  FileTools::read(is, width);
  FileTools::read(is, height);
  FileTools::read(is, name);
  FileTools::read(is, tile_pattern_id);
  FileTools::read(is, enabled);

  return new DynamicTile(name, Layer(layer), x, y, width, height, tile_pattern_id, enabled != 0);
}
Ejemplo n.º 17
0
/**
 * @brief Creates an instance from an input stream.
 *
 * The input stream must respect the syntax of this entity type.
 *
 * @param game the game that will contain the entity created
 * @param is an input stream
 * @param layer the layer
 * @param x x coordinate of the entity
 * @param y y coordinate of the entity
 * @return the instance created
 */
MapEntity* Jumper::parse(Game &game, std::istream &is, Layer layer, int x, int y) {

  int jump_length, width, height, direction;
  std::string name;

  FileTools::read(is, width);
  FileTools::read(is, height);
  FileTools::read(is, name);
  FileTools::read(is, direction);
  FileTools::read(is, jump_length);
 
  return new Jumper(name, Layer(layer), x, y, width, height, direction, jump_length);
}
Ejemplo n.º 18
0
/**
 * @brief Creates an instance from an input stream.
 *
 * The input stream must respect the syntax of this entity type.
 *
 * @param game the game that will contain the entity created
 * @param is an input stream
 * @param layer the layer
 * @param x x coordinate of the entity
 * @param y y coordinate of the entity
 * @return the instance created
 */
MapEntity* Chest::parse(Game &game, std::istream &is, Layer layer, int x, int y) {

  std::string name, treasure_name;
  int big_chest, treasure_variant, treasure_savegame_variable;

  FileTools::read(is, name);
  FileTools::read(is, big_chest);
  FileTools::read(is, treasure_name);
  FileTools::read(is, treasure_variant);
  FileTools::read(is, treasure_savegame_variable);

  return new Chest(name, Layer(layer), x, y, (big_chest != 0),
      Treasure(game, treasure_name, treasure_variant, treasure_savegame_variable));
}
Ejemplo n.º 19
0
bool FrameParser::FrameHeader::IsValid(int aPos) const {
  if (aPos >= SIZE) {
    return true;
  }
  if (aPos == frame_header::SYNC1) {
    return Sync1() == 0xFF;
  }
  if (aPos == frame_header::SYNC2_VERSION_LAYER_PROTECTION) {
    return Sync2() == 7 && RawVersion() != 1 && Layer() == 3;
  }
  if (aPos == frame_header::BITRATE_SAMPLERATE_PADDING_PRIVATE) {
    return RawBitrate() != 0xF && RawBitrate() != 0 && RawSampleRate() != 3;
  }
  return true;
}
Ejemplo n.º 20
0
/**
 * @brief Creates an instance from an input stream.
 *
 * The input stream must respect the syntax of this entity type.
 *
 * @param game the game that will contain the entity created
 * @param is an input stream
 * @param layer the layer
 * @param x x coordinate of the entity
 * @param y y coordinate of the entity
 * @return the instance created
 */
MapEntity* Block::parse(Game &game, std::istream &is, Layer layer, int x, int y) {

  int direction, maximum_moves, can_be_pushed, can_be_pulled;
  std::string name, sprite_name;

  FileTools::read(is, name);
  FileTools::read(is, direction);
  FileTools::read(is, sprite_name);
  FileTools::read(is, can_be_pushed);
  FileTools::read(is, can_be_pulled);
  FileTools::read(is, maximum_moves);

  return new Block(name, Layer(layer), x, y, direction, sprite_name,
      bool(can_be_pushed), bool(can_be_pulled), maximum_moves);
}
Ejemplo n.º 21
0
luabind::object LuaProxy::findlayer(const std::string& layername, lua_State *L)
{
    std::wstring tarLayerName = Str2WStr(layername);
	for(int i = 0; i < 100; ++i){
		LayerControl* ctrl = ::Layer::Get(i);
		if(ctrl){
			if(!ctrl->ptLayerName)
				continue;
			std::wstring sourceLayerName(ctrl->ptLayerName);
			if(tarLayerName == sourceLayerName){
				return luabind::object(L, Layer(i));
			}
		}
	}
	return luabind::object();
}
Ejemplo n.º 22
0
Net::Net(const std::vector<unsigned int> &_topology)
{
	uint numLayers = _topology.size();

	for (uint layerNum = 0; layerNum < numLayers; ++layerNum)
	{
		//creaitng a layer
		m_layers.push_back(Layer());

		for (uint neuronNum = 0; neuronNum <= _topology[layerNum]; ++neuronNum)
		{
			m_layers.back().push_back(Neuron());
			std::cout << "New Neuron created." << std::endl;
		}
	}
}
Ejemplo n.º 23
0
/**
 * \brief Starts this state.
 * \param previous_state the previous state
 */
void Hero::StairsState::start(const State* previous_state) {

  State::start(previous_state);

  // movement
  int speed = stairs.is_inside_floor() ? 40 : 24;
  std::string path = stairs.get_path(way);
  std::shared_ptr<PathMovement> movement = std::make_shared<PathMovement>(
      path, speed, false, true, false
  );

  // sprites and sound
  HeroSprites& sprites = get_sprites();
  if (carried_item == nullptr) {
    sprites.set_animation_walking_normal();
  }
  else {
    sprites.set_lifted_item(carried_item);
    sprites.set_animation_walking_carrying();
  }
  sprites.set_animation_direction((path[0] - '0') / 2);
  get_keys_effect().set_action_key_effect(KeysEffect::ACTION_KEY_NONE);

  Hero& hero = get_hero();
  if (stairs.is_inside_floor()) {
    if (way == Stairs::NORMAL_WAY) {
      // Towards an upper layer: change the layer now
      Layer layer = stairs.get_layer();
      Debug::check_assertion(layer != LAYER_HIGH, "Invalid stairs layer");
      get_entities().set_entity_layer(hero, Layer(layer + 1));
    }
  }
  else {
    sprites.set_clipping_rectangle(stairs.get_clipping_rectangle(way));
    if (way == Stairs::REVERSE_WAY) {
      Point dxy = movement->get_xy_change();
      int fix_y = 8;
      if (path[path.size() - 1] == '2') {
        fix_y *= -1;
      }
      hero.set_xy(hero.get_x() - dxy.x, hero.get_y() - dxy.y + fix_y);
    }
  }
  hero.set_movement(movement);
}
Ejemplo n.º 24
0
/**
 * @brief Creates an instance from an input stream.
 *
 * The input stream must respect the syntax of this entity type.
 *
 * @param game the game that will contain the entity created
 * @param is an input stream
 * @param layer the layer
 * @param x x coordinate of the entity
 * @param y y coordinate of the entity
 * @return the instance created
 */
MapEntity* Teletransporter::parse(Game &game, std::istream &is, Layer layer, int x, int y) {
	
  int width, height, subtype, transition_style;
  MapId destination_map_id;
  std::string name, destination_point_name;

  FileTools::read(is, width);
  FileTools::read(is, height);
  FileTools::read(is, name);
  FileTools::read(is, subtype);
  FileTools::read(is, transition_style);
  FileTools::read(is, destination_map_id);
  FileTools::read(is, destination_point_name);

  return new Teletransporter(name, Layer(layer), x, y, width, height,
      Subtype(subtype), Transition::Style(transition_style),
      destination_map_id, destination_point_name);
}
Ejemplo n.º 25
0
void NeuralNetwork::mirror(const Layer& layer)
{
	size_t blocks = getGreatestCommonDivisor(layer.blocks(),
		getGreatestCommonDivisor(getOutputCount(), layer.getInputCount()));

	assertM(getOutputCount() % blocks == 0, "Input count " << getOutputCount()
		<< " not divisible by " << blocks << ".");
	assertM(layer.getInputCount() % blocks == 0, "Output count " << layer.getInputCount()
		<< " not divisivle by " << blocks << ".");

	size_t newInputs  = getOutputCount() / blocks;
	size_t newOutputs = layer.getInputCount()  / blocks;
	
	assert(newInputs  > 0);
	assert(newOutputs > 0);
	
	util::log("NeuralNetwork") << "Mirroring neural network output layer ("
		<< back().blocks() << " blocks, " << back().getInputBlockingFactor()
		<< " inputs, " << back().getOutputBlockingFactor()
		<< " outputs) to (" << blocks << " blocks, " << newInputs
		<< " inputs, " << newOutputs << " outputs)\n";

	addLayer(Layer(blocks, newInputs, newOutputs));
	
	std::default_random_engine engine;

	// TODO: should wire this out of the neural network	
	bool shouldSeedWithTime = util::KnobDatabase::getKnobValue(
		"NeuralNetwork::SeedWithTime", false);
	
	if(shouldSeedWithTime)
	{
		engine.seed(std::time(0));
	}
	else
	{
		engine.seed(0);
	}

	// should be pseudo inverse
	back().initializeRandomly(engine);
}
Ejemplo n.º 26
0
/**
 * \brief Destroys the item after it finishes its thrown movement.
 *
 * How the item breaks depends on the ground where it lands.
 */
void CarriedItem::break_item_on_ground() {

  get_movement()->stop();

  Ground ground = get_ground_below();
  switch (ground) {

    case Ground::EMPTY:
      // Nothing here: fall one layer below.
    {
      int layer = get_layer();
      if (layer == LAYER_LOW) {
        // Cannot fall lower.
        break_item();
      }
      else {
        get_entities().set_entity_layer(*this, Layer(layer - 1));
        break_item_on_ground();  // Do this again on the next layer.
      }
      break;
    }

    case Ground::HOLE:
      Sound::play("jump");
      remove_from_map();
      break;

    case Ground::DEEP_WATER:
    case Ground::LAVA:
      Sound::play("walk_on_water");
      remove_from_map();
      break;

    default:
      // Break the item normally.
      break_item();
      break;
  }

  is_throwing = false;
  is_breaking = true;
}
void Net::setNetwork(std::vector<unsigned> &topology)
{
 //std::cout<<"Made a Network!"<<std::endl;
 numLayers = topology.size();
 for(unsigned int i=0;i<numLayers; ++i)
 {
  layers.push_back(Layer());
 // std::cout<<"Made Layer:"<<i+1<<std::endl;
  for(unsigned int j=0; j<=topology[i]; ++j)
  {
   if(i+1!= topology.size())
    layers.back().push_back(Neuron(topology[i+1], j));
   else
    layers.back().push_back(Neuron(0, j));
  }
 }
 layers.back().back().setOutputVal(0.1);
 //for(unsigned layerNum=0; layerNum<layers.size()-1 ;layerNum++)
 //layers[layerNum].back().setOutputVal(1.0);
}
Ejemplo n.º 28
0
/**
 * @brief Sets the layer of the pickable item that just appeared.
 *
 * This function should be called only when there a current pickable item,
 * i.e. from the event_appear() function.
 *
 * - Argument 1 (integer): layer of the pickable item
 *
 * @param l the Lua context that is calling this function
 */
int Script::item_api_set_layer(lua_State *l) {

    Script *script;
    called_by_script(l, 1, &script);

    int layer = luaL_checkinteger(l, 1);

    // retrieve the pickable item
    const std::string &item_name = script->get_item_properties().get_name();
    Equipment &equipment = script->get_game().get_equipment();
    ItemScript &item_script = equipment.get_item_script(item_name);
    PickableItem *pickable_item = item_script.get_pickable_item();

    Debug::check_assertion(pickable_item != NULL,
                           "Cannot call sol.item.set_layer(): there is no current pickable item");

    MapEntities &entities = script->get_map().get_entities();
    entities.set_entity_layer(pickable_item, Layer(layer));

    return 0;
}
Ejemplo n.º 29
0
Neural::Net::Net(const std::vector<unsigned> &topology)
{
	free();

	for (unsigned layerNum = 0; layerNum < topology.size(); ++layerNum)
	{
		layers.push_back(Layer());
		// numOutputs of layer[i] is the numInputs of layer[i+1]
		// numOutputs of last layer is 0
		unsigned numOutputs = layerNum == topology.size() - 1 ? 0 : topology[layerNum + 1];

		// We have made a new Layer, now fill it with neurons, and add a bias neuron to the layer
		for (unsigned neuronNum = 0; neuronNum <= topology[layerNum]; ++neuronNum)
		{
			layers.back().push_back(Neuron(numOutputs, neuronNum));
		}

		// Force the bias node's output value to 1.0. It's the last neuron created above
		layers.back().back().setOutputValue(1.0);
	}
}
Ejemplo n.º 30
0
Background::Background(int levelNum, int roomNum)
	:nonMovingLayer(*TextureManager::GetInstance().retrieveTexture(
	Global::GetInstance().roomSizes.at("Level"+ std::to_string(levelNum) + "Room" + std::to_string(roomNum)).nonMovinglayer)),
	vel(-300.0f, 99.0f), hitGround(false), timerForStep(-1.0f), goliathStepWait(3.0f)
{
	RoomStruct temp = Global::GetInstance().roomSizes.at("Level"+ std::to_string(levelNum) + "Room" + std::to_string(roomNum));
	for (int i = 0; i < temp.movingLayers.size(); i++)
	{
		if(temp.movingLayers.at(i).scale.x == 0 && temp.movingLayers.at(i).scale.y == 0)
		{
			//sf::Sprite test = sf::Sprite(*TextureManager::GetInstance().retrieveTexture(temp.movingLayers[i].imageName));
			//test.setPosition(temp.movingLayers.at(i).posOffset.x, temp.movingLayers.at(i).posOffset.y);
			//test.setScale(temp.movingLayers.at(i).sizeScale.x, temp.movingLayers.at(i).sizeScale.y);
			nonMovingLayers.push_back(NonMovingLayer(temp, i));
			//nonMovingLayers.push_back(sf::Sprite(*TextureManager::GetInstance().retrieveTexture(temp.movingLayers[i].imageName)));
			//nonMovingLayers[nonMovingLayers.size() - 1].setPosition(temp.movingLayers.at(i).posOffset.x, temp.movingLayers.at(i).posOffset.y);
			//nonMovingLayers[nonMovingLayers.size() - 1].setScale(temp.movingLayers.at(i).sizeScale.x, temp.movingLayers.at(i).sizeScale.y);
		}
		else
			movingLayers.push_back(Layer(temp, i));
	}
	nonMovingLayer.setPosition(temp.posOffset.x, temp.posOffset.y);
}