public void encodePercept(symbol_list_t symlist, UInt64 observation, UInt64 reward) { symlist.clear(); encode(symlist, (int)observation, m_obs_bits); encode(symlist, (int)reward, m_rew_bits); }
// generate a specified number of random symbols distributed according to // the context tree statistics and update the context tree with the newly // generated bits public void genRandomSymbolsAndUpdate(Random rng, symbol_list_t symbols, UInt64 bits) { // TODONE: implement symbols.clear(); //Random rng = new Random(); for (UInt64 i = 0; i < bits; i++) { // flip a biased coin for each bit double prediction = predict(false); bool rand_sym = rng.NextDouble() < prediction ? false : true; symbols.push_back(rand_sym); update(rand_sym); // TODO: optimise this loop } }
void getContext(symbol_list_t context) { // if (!m_context_functor.empty()) // { // m_context_functor(context); // return; // } context.clear(); // history_t::const_reverse_iterator ri = m_history.rbegin(); int ri = m_history.mem.Count - 1; for (UInt64 c = 0; ri >= 0 && c < m_depth; --ri, c++) { context.push_back((bool)m_history.mem[(int)ri]); } }
// encoding/decoding actions and percepts to/from symbol lists void encodeAction(symbol_list_t symlist, action_t action) { symlist.clear(); encode(symlist, (int)action, m_actions_bits); }