Linear Feedback Shift Register
How do I make an linear feedback shift register?
What is a linear feedback shift register? How do you make a linear feedback shift register? This script and codes were developed by Sarah Cartwright on 05 December 2022, Monday.
Linear Feedback Shift Register - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Linear Feedback Shift Register</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <!--<div id="out"></div>-->
This Pen does nothing on its own - it is used in other pens. <script src="js/index.js"></script>
</body>
</html>
Linear Feedback Shift Register - Script Codes CSS Codes
body { padding: 10px; margin: 0px; background: #2e2e2e; color: #909090; font: 12px arial, sans-serif;
}
Linear Feedback Shift Register - Script Codes JS Codes
//Leftmost bit can be UP TO 32 bits..... 0 to 31.
function linearFeedbackShiftRegister(seed, taps, leftmostBitIndex) { var tapDefs = taps.map(function(tap, i) { return 'var tapBit' + i + ' = (value >> ' + tap + ') & 1;' }).join('\n'); var tapXOR = taps.map(function(tap, i) { return 'tapBit' + i; }).join(' ^ '); var body = '' + 'var value = ' + seed + ' >>> 0;\n' + 'return function() { \n' + tapDefs + ' \n' + 'var leftmostBit = ' + tapXOR + '; \n' + 'return (value = ((leftmostBit << ' + leftmostBitIndex + ') | (value >>> 1)) >>> 0); \n' + '} \n'; var fn = new Function(body); return attachRandomNumberAPI(leftmostBitIndex, fn());
}
function attachRandomNumberAPI(leftmostBitIndex, fn) { var max = parseInt(Array(leftmostBitIndex+2).join(1), 2); fn.maxValue = max; for(var runSome=0; runSome < leftmostBitIndex * 50; runSome++) fn(); fn.random = function() { return (fn() / max); } return fn;
}
function tetrisLSFR() { //Tetris seed, 16 bits. Range 0-65535) return linearFeedbackShiftRegister(0x8988, [1, 9], 31);
}
function randomSeededLSFR() { //return linearFeedbackShiftRegister(0x8988, [1, 9], 31); return linearFeedbackShiftRegister(Math.random() * 10000000 >>> 0, [16,15,13,4], 31);
}
// Test.
/*
var o = "";
randGen = randomSeededLSFR();
for(var i = 0; i < 100; i++){ o = o + randGen.random() + "<br>";
}
document.getElementById("out").innerHTML = o;
*/
Developer | Sarah Cartwright |
Username | SarahC |
Uploaded | December 05, 2022 |
Rating | 3 |
Size | 2,197 Kb |
Views | 10,120 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Three.js particles | 7,333 Kb |
OLED Emulator - Faster vertical bytes | 6,075 Kb |
Date Words | 3,352 Kb |
Bullet time - WebGL Fireworks | 15,711 Kb |
Firework types | 3,349 Kb |
Tinted image renderer | 2,176 Kb |
Kindle - Convert image to 4 shade E-ink | 4,747 Kb |
Bullet time - Fireworks | 5,737 Kb |
Canvas view-type arrays | 3,013 Kb |
Blue balls and fireflies. | 4,057 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Mobile first social buttons with no iframe | Alistairtweedie | 3,158 Kb |
Day 11 - Calendar Card | Arnellebalane | 6,984 Kb |
Improved Page Flipping Effect | Usaphp | 5,201 Kb |
RWD- Mostly Fluid Layout Pattern | Marcocastro | 2,312 Kb |
Loading animation | Codeams | 2,408 Kb |
Hmmm... | Rk007 | 4,848 Kb |
CSS3 Form Page Design | Rssatnam | 3,613 Kb |
A Pen by boilzzz | Boilzzz | 2,761 Kb |
Search field | Jamesbarnett | 2,100 Kb |
AngularJS Animated Todo List | Ehaase | 2,975 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!