Example #1
0
RlSemaphore::RlSemaphore(const bfs::path& semname, int index)
{
    std::string filename = semname.native_file_string();
    key_t key = ftok(filename.c_str(), index);
    if (key == -1)
        throw SgException("Semaphore " + filename + " doesn't exist");
    m_id = semget(key, 1, 0644 | IPC_CREAT);
    if (semctl(m_id, 0, SETVAL, 1) == -1)
        throw SgException("Failed to initialise semaphore");
}
Example #2
0
RlSharedMemory::RlSharedMemory(
    const bfs::path& sharename, int index, int bytes)
{
    std::string filename = sharename.native_file_string();
    key_t key = ftok(filename.c_str(), index);
    if (key == -1)
        throw SgException("Shared file " + filename + " doesn't exist");
    m_id = shmget(key, bytes, 0644 | IPC_CREAT);
    if (m_id == -1)
        Error("shmget");
    m_data = (char*) shmat(m_id, 0, 0);
    if (m_data == (char*) -1)
        Error("shmat");
}
Example #3
0
RlEngine::RlEngine(istream& in, ostream& out,
    const bfs::path& programPath, 
    const bfs::path& rlgoDir, 
    const bfs::path& settingsfile,
    const vector<pair<string, string> >& overrides)
:   GoGtpEngine(in, out, 0, programPath.native_file_string().c_str())
{
    m_commands.Register(*this);
    RlForceLink();

    // Create a single player that is used by both sides
    RlAgentPlayer* agentplayer = new RlAgentPlayer(Board());
    m_player = agentplayer;
    GoGtpEngine::SetPlayer(agentplayer);

    SetOverrides(overrides);
    m_setup = InitSettings(settingsfile, rlgoDir, m_player->Board());

    // Set player to use newly created agent
    m_player->SetAgent(m_setup->GetMainAgent());
    m_setup->SetGame(&GetGame());
    m_commands.Setup(m_setup);
}