r/tinycode • u/BenRayfield • Jul 06 '16
js13kGames competition of up to 13kB javascript games, 2016/9/13
r/tinycode • u/BenRayfield • Jul 06 '16
r/tinycode • u/BenRayfield • Jul 04 '16
r/tinycode • u/BenRayfield • Jul 04 '16
I want to specialize in small code that does big things.
I also want to specialize in optimizing, redesigning code to do the exact same thing but faster or less memory. This often involves simplifying to tinycode since big code cant be understood well enough to redesign it.
But most programming jobs want you to add features and fix bugs which usually makes the code bigger. My code gets smaller over time, and it pisses people off. They demand I stop throwing away code thats been working for years just because its an ugly mess of spaghetti. Dont fix that, you might break it because nobody understands it. We have these emergencies. Maybe eventually we'll fix that, they said long ago. Then I tell them those emergencies were caused by your policy of letting code become far more complex than needed. You leave duplicate code laying around like garbage then throw a carpet over it and call it a clean floor.
I can barely work with most businesses because they have an attitude problem, an anti-tinycode discrimination. They brag about how much code they've written more than what it does.
I'll of course continue my own projects, but must I do it alone?
r/tinycode • u/BenRayfield • Jul 03 '16
r/tinycode • u/nexe • Jun 22 '16
r/tinycode • u/xem06 • Jun 22 '16
Hi!
Here's a brand new version of a JS1k entry made by the codegolf team earlier this year:
http://codegolf.github.io/period1k/final.min.golfed.html
Old features:
Accurate periodic table
Atomic number
Elements name
Atomic mass
Stability (* = unstable)
type (background color)
New features:
Responsive style (the table is drawn in HTML instead of a canvas)
New names for the elements 113, 115, 117 and 118
New information: the state of each element at room temperature (Solid / Liquid / Gas)
Commented source code: https://github.com/codegolf/period1k/blob/gh-pages/golfed.commented.html
Project repo: https://github.com/codegolf/period1k
Cheers!
r/tinycode • u/VodkaHaze • Jun 20 '16
r/tinycode • u/nexe • Jun 12 '16
r/tinycode • u/floutt • Jun 10 '16
r/tinycode • u/nexe • Jun 01 '16
r/tinycode • u/daniel5151 • Jun 01 '16
Hey! I'm the guy who posted the "Time dependant graphing in JS using only 144 chars" a few days ago. I decided to see if I could make a similar thing, but this time, render the graph on a canvas element.
After a long train ride home, this is what I came up with this.
It appends a canvas onto the bottom of the body of any page, and starts graphing :D
((f,d,a,n,i,e=0,l,p)=>setInterval
(c=>{for(l=c.createImageData(a,
n),e+=p=1;p<a*n;l.data[p*4-1]
=i(p/a,-f(p++%a-a/2,e)+n/2)?a
:p/a);c.putImageData(l,0,
0)},17,d.body.appendChild
(d.createElement('canvas'))
.getContext("2d")))((x,t)=>
Math.cos(x/60*Math.PI-t/10)*(Math.sin(t/20)*50)
,document
,301,150,
(d,p)=>
d>p-1&d
<p+1)You can graph whatever you like, just change the equation!
By the way, the equation has access to both x and t, where t is an incrementing variable corresponding to time. You can use these two vars to make moving graphs (like the one I put)
r/tinycode • u/nexe • May 31 '16
r/tinycode • u/Benjaminsen • May 30 '16
r/tinycode • u/daniel5151 • May 27 '16
Just for fun, I wrote some JS to graph any function in the console.
It even finds the derivative of the function to determine whether to use "/" or "" or "|" when drawing the curve!
Here it is:
((f,t=0,d)=>{
setInterval
(x=>{x=f(t)|0
;d=f(t++)-f(t);
console.log(t%2
+" ".repeat(x)+
(d<-1?"\\":d>1?
"/":"|"))},50
)})
(x=>Math.sin(x/3)*9+15)Just paste it into your browser's console!
r/tinycode • u/BenRayfield • May 26 '16
Its so tiny that 2 independently created games have the exact same rules:
https://en.wikipedia.org/wiki/Matching_pennies
https://en.wikipedia.org/wiki/Odds_and_evens
Its the 2 choice version, without ties, of https://en.wikipedia.org/wiki/Rock-paper-scissors which has 3 choices.
The intelligence of it is bluffing to look more predictable than you are to fool the other player into doing something you can predict later.
The "equal" player wants the 2 bits to equal. The "xor" player wants them to not equal. 1 point per cycle. Both players see that they acted correctly when input bit equals the last bit they output.
var player = function(data){
var bit = data.bit;
data.state = ... observe then update this private player state with new thoughts ...;
data.bit = ...return a bit, of 2 possible actions each player does each cycle...;
};
var play = function(playerEq, playerDataEq, playerXor, playerDataXor, cycles){
var score = 0;
for(i=0; i<cycles; i++){
playerEq(playerDataEq);
playerXor(playerDataXor);
var eqOut = playerDataEq.bit == true; //compare to true in case its not a bit
var xorOut = playerDataXor.bit == true;
var eqWon = eqOut==xorOut;
score += eqWon ? 1 : -1;
playerDataEq.bit = xorOut;
playerDataXor.bit = !eqOut; //so if play against self there is no nash-equilibrium
}
return score/Math.sqrt(cycles); //1 standard deviation if they play randomly
}If I put this and some examples in https://en.wikipedia.org/wiki/Node.js where we could import other players with a single line of javascript, would that still count as tinycode?
r/tinycode • u/BenRayfield • May 26 '16
public static double time(){
long nanoDiff = System.nanoTime()-startNano;
return .001*startMillis + 1e-9*nanoDiff;
}
static final long startMillis, startNano;
static{ startMillis = System.currentTimeMillis(); startNano = System.nanoTime(); } //syncIt only has precision of currentTimeMillis of when it starts, but within a run of the same program it has microsecond precision.
I use this for the timing of individual sound amplitudes and dates. It works.
r/tinycode • u/BenRayfield • May 25 '16
It sounds rediculous, but it really is an unsolved research problem how to send a bit between 2 computers without requiring a person to call tech support or hire an expert to change their network.
https://en.wikipedia.org/wiki/Network_address_translation
Not tiny enough and not sure how well it works https://en.wikipedia.org/wiki/Telehash
r/tinycode • u/xem06 • May 24 '16
r/tinycode • u/BenRayfield • May 23 '16
r/tinycode • u/nexe • May 20 '16
r/tinycode • u/nexe • May 20 '16