TxChaos 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.//lib//tx_chaos.rb +45 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: af5378b40ecba807ef70f53b79691a0cecef2cc22b8de496d6c28eb205dc36e3
|
|
4
|
+
data.tar.gz: bee91aa1afb0f083142935dbd408d412c61aea6d20b7cec8ef9674f14738e835
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c8f9395a1ca04f1f5d6449647ba52c63dcf17818340668ecf03af8243124b38fcf84b78ad58740e9780b0cb3e1a573a7ae9854f767e0f41334d51e4b1bef7a08
|
|
7
|
+
data.tar.gz: 061dce64cd9541d456eac4f54ec56329c124104a0fcbeab510799c62f79dc59d3f53af73f46e13f2b8d4d22768f1bfde21532f132e4d999d0c53ed3e3fca14ab
|
data/.//lib//tx_chaos.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
class Chaos
|
|
2
|
+
@@continuousness = 1
|
|
3
|
+
@@seed = 0
|
|
4
|
+
def initialize(item = nil, max = nil)
|
|
5
|
+
case item
|
|
6
|
+
when Integer
|
|
7
|
+
if max === Integer
|
|
8
|
+
@array = (item..max).to_a
|
|
9
|
+
elsif max.nil?
|
|
10
|
+
@array = (0..item).to_a
|
|
11
|
+
else
|
|
12
|
+
raise ArgumentError.new("Chaos.new(item, max) accepts max: Integer, nil; you input max: #{max}, which is #{max.class.to_s}")
|
|
13
|
+
end
|
|
14
|
+
when Range
|
|
15
|
+
@array = item.to_a
|
|
16
|
+
when Array
|
|
17
|
+
@array = item
|
|
18
|
+
else
|
|
19
|
+
raise ArgumentError.new("Chaos.new(item) accepts item: Integer, Range, Array; you input item: #{item}, which is #{item.class.to_s}")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
def self.settings(**settings)
|
|
23
|
+
@@continuousness = settings[:cont] unless settings[:cont] == nil
|
|
24
|
+
@@seed = settings[:seed] unless settings[:seed] == nil
|
|
25
|
+
end
|
|
26
|
+
def get
|
|
27
|
+
seed = @@seed/@array.size.to_f
|
|
28
|
+
multiplier = (Math.log(@array.size,2) - @@continuousness).to_i
|
|
29
|
+
multiplier.times{seed = 4*seed*(1-seed)}
|
|
30
|
+
return @array[seed.to_i]
|
|
31
|
+
end
|
|
32
|
+
def that
|
|
33
|
+
intseed = @@seed
|
|
34
|
+
binfseed = intseed/(@array.size.to_f)
|
|
35
|
+
multiplier = (Math.log(@array.size,2) - @@continuousness).to_i
|
|
36
|
+
outseed = 0
|
|
37
|
+
until yield(outseed)
|
|
38
|
+
intseed += 1
|
|
39
|
+
binfseed = intseed/(@array.size.to_f)
|
|
40
|
+
multiplier.times{binfseed = 4*binfseed*(1-binfseed)}
|
|
41
|
+
outseed = (binfseed*(@array.size.to_f)).to_i
|
|
42
|
+
end
|
|
43
|
+
return outseed.to_i
|
|
44
|
+
end
|
|
45
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: TxChaos
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- TymixNow
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-02-20 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Deterministic pseudorandom integer generator, uses the basic 4*x*(1-x)
|
|
14
|
+
chaos algorithm
|
|
15
|
+
email: tymixnow@gmail.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- ".\\lib\\tx_chaos.rb"
|
|
21
|
+
homepage: https://rubygems.org/gems/TxChaos
|
|
22
|
+
licenses:
|
|
23
|
+
- MIT
|
|
24
|
+
metadata: {}
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubygems_version: 3.4.6
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: Deterministic pseudorandom integer generator
|
|
44
|
+
test_files: []
|