Skip to content

Instantly share code, notes, and snippets.

View koozdra's full-sized avatar

Dimitri Tishchenko koozdra

View GitHub Profile
@koozdra
koozdra / psf_q_learning.js
Last active June 18, 2020 05:34
post sign flow q-learning
shuffle_array = arr =>
arr
.map(a => [a, Math.random()])
.sort(([, lr], [, rr]) => lr - rr)
.map(([a]) => a);
user_action_for_state = (state, randy) => {
if (state === 'p' || state === 'ps' || state === 'psa' || state === 'psam') {
if (randy < 0.7) {
return primary_action_names[state[state.length - 1]];
@koozdra
koozdra / key_by_multiple.js
Created August 19, 2020 20:19
key array of objects by multiple keys
a = [ { name: 'bill', group: 'b' },
{ name: 'ann', group: 'a' },
{ name: 'ken', group: 'k' },
{ name: 'alex', group: 'a' } ]
_.reduce((sum, v) => {
const { name, group } = v;
const current = _.getOr([], [group, name])(sum);
return _.set([group, name], [...current, v])(sum);
}, {})(a);