The Bot Bikeshed
-
I get a pretty good pi approximation if I remove the Math.floor and + 1...
The floor seems to bias it.
-
Any off-by-one gets compensated as N grows.
$ php -r 'function sqr($n){return $n*$n;} for($n=1;$n<100;$n++){ $c=0; for($i=-$n; $i <= $n; $i++)for($j=-$n;$j<=$n;$j++) $c+=(sqr($i)+sqr($j)<sqr($n)) ? 1 : 0; echo "$n: ", $c/sqr($n), "\n";}' 1: 1 2: 2.25 3: 2.7777777777778 4: 2.8125 5: 2.76 6: 3.0277777777778 7: 2.9591836734694 8: 3.015625 9: 3.0740740740741 10: 3.05 11: 3.0826446280992 12: 3.0347222222222 13: 3.0591715976331 14: 3.1071428571429 15: 3.0977777777778 16: 3.09765625 17: 3.076124567474 18: 3.1018518518519 19: 3.1163434903047 20: 3.1125 21: 3.1043083900227 22: 3.1260330578512 23: 3.117202268431 24: 3.1059027777778 25: 3.1056 26: 3.1198224852071 27: 3.1344307270233 28: 3.1237244897959 29: 3.1117717003567 30: 3.1211111111111 31: 3.1186264308012 32: 3.1298828125 33: 3.1267217630854 34: 3.1254325259516 35: 3.1355102040816 36: 3.1242283950617 37: 3.127100073046 38: 3.1225761772853 39: 3.1328073635766 40: 3.133125 41: 3.1225461035098 42: 3.1298185941043 43: 3.1287182260681 44: 3.1368801652893 45: 3.1353086419753 46: 3.1290170132325 47: 3.1312811226799 48: 3.12890625 49: 3.1324448146606 50: 3.13 51: 3.1376393694733 52: 3.1379437869822 53: 3.1317194731221 54: 3.1347736625514 55: 3.1289256198347 56: 3.1380739795918 57: 3.134810710988 58: 3.134661117717 59: 3.1338695777076 60: 3.1325 61: 3.1359849502822 62: 3.1365764828304 63: 3.1365583270345 64: 3.136962890625 65: 3.1330177514793 66: 3.1379706152433 67: 3.1341055914458 68: 3.1342993079585 69: 3.1390464188196 70: 3.1348979591837 71: 3.1360841102956 72: 3.132137345679 73: 3.1369863013699 74: 3.1375091307524 75: 3.1368888888889 76: 3.1372922437673 77: 3.1372912801484 78: 3.1388888888889 79: 3.1361961224163 80: 3.13578125 81: 3.1380887059899 82: 3.1363771564545 83: 3.1390622731891 84: 3.1361961451247 85: 3.1370242214533 86: 3.1385884261763 87: 3.1387237415775 88: 3.1390754132231 89: 3.1350839540462 90: 3.1398765432099 91: 3.137906049994 92: 3.1381143667297 93: 3.1380506416927 94: 3.1377320054323 95: 3.1393905817175 96: 3.1372612847222 97: 3.1366776490594 98: 3.1387963348605 99: 3.137741046832
-
Possibly you've found the dice to be slightly unfair.
-
I figured out the parser thing. "<" was interpreted as an HTML tag. Try lt for now.
-
@error_bot eval "def loop(i)=>i==0?0:((d21-11)^2+(d21-11)^2)^(1/2) lt 10?1:0+loop(i-1); loop(20)/20"
-
Error: Maximum call stack size exceeded
-
@error_bot eval "def loop(i)=>i==0?0:((d21-11)^2+(d21-11)^2)^(1/2) lt 10?1:0+loop(i-1); loop(20)/20"
eval "def loop(i)=>i==0?0:((d21-11)^2+(d21-11)^2)^(1/2) lt 10?1:0+loop(i-1); loop(20)/20"
eval "def loop(i)=>i==0?0:((d21-11)^2+(d21-11)^2)^(1/2) lt 10?1:0+loop(i-1); loop(20)/20"
eval "def loop(i)=>i==0?0:((d21-11)^2+(d21-11)^2)^(1/2) lt 10?1:0+loop(i-1); loop(20)/20"
-
0.05loop(20) (1) / 20 (0.05) = 0.050.05loop(20) (1) / 20 (0.05) = 0.050.05loop(20) (1) / 20 (0.05) = 0.05Error: Maximum call stack size exceeded
-
-
@error_bot eval "def loop(i)=>i==0?0:(((d21-11)^2+(d21-11)^2)^(1/2) lt 100?1:0)+loop(i-1); loop(20)/20"
-
Error: Maximum call stack size exceeded
-
@PleegWat said in The Bot Bikeshed:
eval "def loop(i)=>i==0?0:(((d21-11)^2+(d21-11)^2)^(1/2) lt 100?1:0)+loop(i-1); loop(20)/20"
eval "def loop(i)=>i==0?0:(((d21-11)^2+(d21-11)^2)^(1/2) lt 100?1:0)+loop(i-1); loop(5)/5"
-
@PleegWat You have to mention the bot...
-
@error_bot eval "def loop(i)=>i==0?0:(((d21-11)^2+(d21-11)^2)^(1/2) lt 100?1:0)+loop(i-1); loop(5)/5"
-
Error: Maximum call stack size exceeded
-
@error I hit the wrong reply button probably.
-
@PleegWat said in The Bot Bikeshed:
i==0?0:(((d21-11)^2+(d21-11)^2)^(1/2) lt 100?1:0)
@error_bot eval 'let i = 0; i==0?0:(((d21-11)^2+(d21-11)^2)^(1/2) lt 100?1:0)'
-
Error: Unknown expression type: ternaryExpression
-
-
-
Missing toString handler... Fixing.
-
@error_bot
eval 'let i = 0; i==0?0:(((d21-11)^2+(d21-11)^2)^(1/2) lt 100?1:0)'
eval 'let i = 1; i==0?0:(((d21-11)^2+(d21-11)^2)^(1/2) lt 100?1:0)'
-
0i (0) == 0 (true) ? 0 : (((d21 - 11) ^ 2 + (d21 - 11) ^ 2) ^ (1 / 2) lt 100 ? 1 : 0) (0) = 01i (1) == 0 (false) ? 0 : (((d21 (3) - 11 (-8)) ^ 2 (64) + (d21 (18) - 11 (7)) (71) ^ 2 (5,041)) ^ (1 / 2 (0.5)) (71) lt 100 (true) ? 1 : 0 (1)) (1) = 1
-
I think perhaps this is an issue of lazy evaluation not closing over context.
Like I don't grab a snapshot of the context before closing over the expression.
Of course that causes other issues, because the ttl is part of the context, so it would be decrementing a snapshot.
-
@error_bot eval "def loop(i)=>i==0?0:(((d21-11)^2+(d21-11)^2)^(1/2) lt 100?1:0)+loop(i-1); loop(5)/5"
-
1loop(5) (5) / 5 (1) = 1
-
Recursion test:
@error_bot eval def fib(n)=>n le 1 ? 1 : fib(n-1) + fib(n-2); fib(0); fib(1); fib(2); fib(3); fib(4); fib(5); fib(6); fib(7)
-
1fib(0) (1) = 11fib(1) (1) = 12fib(2) (2) = 23fib(3) (3) = 35fib(4) (5) = 58fib(5) (8) = 813fib(6) (13) = 1321fib(7) (21) = 21
-
Bugs found today have been
fixedreplaced with new bugs for you to find.
-
-
@Gribnit said in The Bot Bikeshed:
@error_bot said in The Bot Bikeshed:
21
there's no such thing as "21", what the hell?
-
I think I can implement an
in
operator with a little hack, reparsing a call token as an operator. E.g.x in ( 2, 3, 5 )
is true if x is 2, 3, or 5. Alsonin
as!( x in ( 1, 2, 3 ) )
.
-
Reroll dice modifier should probably take a lamdba. Reroll if n lt 3. Reroll if n in (1, 3).
-
@error_bot eval d20 in ( 1, 3, 5, 7, 11, 13, 17, 19 )
-
trued20 (13) in (1, 3, 5, 7, 11, 13, 17, 19) (true) = true
-
@error_bot eval d4 in ( d4, d4, d4, d4, d4, d4 )
-
trued4 (2) in (d4 (1), d4 (2), d4, d4, d4, d4) (true) = true
-
Note that only the first two expressions in the list were evaluated.
-
How about another operator,
until
...d20 until ( n gt 1 )
Edit: no, that would reroll all the dice - and the entire expression.
-
@error said in The Bot Bikeshed:
How about another operator,
until
...d20 until ( n gt 1 )
Edit: no, that would reroll all the dice - and the entire expression.
We can do this with recursion already.
-
@Gribnit said in The Bot Bikeshed:
We can do this with recursion already.
a) why have subtraction? we have addition and negative numbers
b) I don't really expect the D&D players to use UDFs... or error_bot
-
@error said in The Bot Bikeshed:
@Gribnit said in The Bot Bikeshed:
We can do this with recursion already.
a) why have subtraction? we have addition and negative numbers
b) I don't really expect the D&D players to use UDFs... or error_botI've got precedent, Odersky said the same thing, which really twisted Scala up. Which I realized but am still standing by.
-
Reply bomb successful.
-
-
OKreroll
is going to be a oneToManyOperator (likein
andnin
) but it only works if the LHS is a diceExpression.No, it really has to inject itself into the dice calculation.
-
@error_bot eval def withinTen(x,y) => pow(pow(x,2),pow(y,2),.5) ; withinTen(7,7) ; withinTen(8,8) ; withinTen(9,9)
-
66,009,724,686,219,560,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000withinTen(7, 7) (66,009,724,686,219,560,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000) = 66,009,724,686,219,560,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,00039,402,006,196,394,480,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000withinTen(8, 8) (39,402,006,196,394,480,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000) = 39,402,006,196,394,480,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,00038,662,196,978,715,634,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000withinTen(9, 9) (38,662,196,978,715,634,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000) = 38,662,196,978,715,634,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000
-
It's tricky. I'm thinking it's going to be another case of a multiphasic parse. Where first it sees a oneToManyExpression and then it reinterprets it as a diceModifier.
-
@error_bot .5 = 5, huh?
-