summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortheia2022-09-20 11:58:20 -0400
committertheia2022-09-20 11:58:20 -0400
commitce8d06656673984625a0a9626b39efc2137290e6 (patch)
treeefe2d8e847f9f59b1ccec8092c2c08c413874d21
parentc3f16ab54bbe952a658b17558fca8115ed515ae1 (diff)
anonymized and biased logoot
-rw-r--r--README.md6
-rw-r--r--logoot.js13
2 files changed, 12 insertions, 7 deletions
diff --git a/README.md b/README.md
index 4c27ffa..bf80fd5 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,12 @@
# Graffiti for Vanilla Javascript
-This is the base Javascript library that interfaces with the [Graffiti server](https://github.com/csail-graffiti/server).
-We recommend not using this vanilla library itself but instead using framework plugins that are built on top of it like the [Graffiti plugin for Vue.JS](https://github.com/csail-graffiti/graffiti-x-vue).
+This is the base Javascript library that interfaces with the [Graffiti server](https://github.com/digital-graffiti/server).
+We recommend not using this vanilla library itself but instead using framework plugins that are built on top of it like the [Graffiti plugin for Vue.JS](https://github.com/digital-graffiti/graffiti-x-vue).
Example usage:
```javascript
-import Graffiti from "https://csail-graffiti.github.io/graffiti-x-js/graffiti.js"
+import Graffiti from "https://digital-graffiti.github.io/graffiti-x-js/graffiti.js"
// You can initialize a connection to the graffiti server
const graffiti = Graffiti()
diff --git a/logoot.js b/logoot.js
index bcd5f6d..c8c7c02 100644
--- a/logoot.js
+++ b/logoot.js
@@ -21,7 +21,7 @@ export default {
return [this.maxInt+1]
},
- between(a, b) {
+ between(a, b, scale=100) {
// Strip zeros and find common length
const aLength = this.lengthWithoutZeros(a)
const bLength = this.lengthWithoutZeros(b)
@@ -103,9 +103,14 @@ export default {
}
}
- // Finally, sample between the upper and
- // lower bounds
- out.push(Math.floor(Math.random() * (upperBound + 1 - lowerBound)) + lowerBound)
+ // Create a random number in [0,1] but bias it to be small,
+ // so that numbers tend to increase by a small amount.
+ let random = Math.random()
+ random = -Math.log(1-random)/scale
+ random = Math.min(random, 1)
+
+ // Finally, sample between the upper and lower bounds
+ out.push(Math.floor(random * (upperBound + 1 - lowerBound)) + lowerBound)
return out
},