Conversation
4eca1de to
9bc9a04
Compare
jcorbin
left a comment
There was a problem hiding this comment.
It's Happening!
I stopped reading somwhere around html.js in alphabetic files-changed order... green ci -> merge and continue...
tho why no more tsc in CI? what even is the current meta on prettier-vs-eslint-vs-justusestricttypescriptrules ?
describe.js
Outdated
| if (node.variable) { | ||
| desc += '(' + node.variable + '+' + node.value + ') ' + S(node.expression); | ||
| } else { | ||
| desc += S(node.expression); | ||
| } | ||
| desc += ' (' + node.branches.join(' ') + ') W(' + node.weights.map(S).join(' ') + ')'; |
There was a problem hiding this comment.
uplift to backtick wen? destructure node wen? how far does that train go to expression crunching down this nascent desc string builder pattern?
There was a problem hiding this comment.
obviously this apples throughout below, not echoing it after this site
There was a problem hiding this comment.
Adding a commit to adopt the prefer-template and apply the autofix.
describe.js
Outdated
| types.set = function set(node) { | ||
| return node.variable + ' ' + S(node.expression); | ||
| types.set = node => { | ||
| return node.variable + ' ' + S(node.expression); |
There was a problem hiding this comment.
all these one-line return bracket-bodies could be erased fwiw
| import fs from 'fs'; | ||
| import verify from './verify.js'; | ||
|
|
||
| function main() { |
There was a problem hiding this comment.
what even is the test framework again here? global test from whence? reporting via console.error below? thoughts? plans? dreams?
There was a problem hiding this comment.
The test framework is that the tests exit non-zero. Obvious room to improve once past the decision paralysis.
| const offset = Math.floor(randomer.random() * weight); | ||
| let passed = 0; | ||
| for (let i = 0; i < weights.length; i++) { | ||
| passed += weights[i]; | ||
| if (offset < passed) { | ||
| return i; | ||
| } | ||
| } | ||
| return null; |
There was a problem hiding this comment.
not for this pr, but this 2-pass sampling algo could be 1-pass; there is no need for the pre-summed weight term; just use pow(random(), 1/weights[i]; I guess the "cost" is you go from 1 random call to N, but now you've got a 1-pass online algo fwiw
There was a problem hiding this comment.
This is a great point and I love the math of it, but also want to avoid floating point because the browsers are constantly whacking behavior divergence moles.
| this.randomer._state0U = random[0]; | ||
| this.randomer._state0L = random[1]; | ||
| this.randomer._state1U = random[2]; | ||
| this.randomer._state1L = random[3]; |
There was a problem hiding this comment.
something something TODO pluggable / modern/ bigint-based prng wen ; and how ; does it need to support restoring legacy state snapshots? whew...
There was a problem hiding this comment.
I’d love to attack this some time!
engine.js
Outdated
| } | ||
|
|
||
| $echo() { | ||
| return this.write('' + evaluate(this.top, this.randomer, this.instruction.expression)); |
There was a problem hiding this comment.
is the '' + coercion still necessary?
There was a problem hiding this comment.
Probably not at runtime, but when deepening the relationship with TypeScript, this will probably continue to at least be a quasi/template literal just to appease the write string param.
No description provided.