mirror of
https://github.com/exoticorn/upkr.git
synced 2026-01-20 19:46:42 +01:00
Compare commits
2 Commits
dictionary
...
old-prob-u
| Author | SHA1 | Date | |
|---|---|---|---|
| 22582d43a8 | |||
| f467b6a454 |
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
configs = [
|
configs = [
|
||||||
[:master, '-b'],
|
[:master, '-b'],
|
||||||
[:z80, '-b']
|
[:z80, '-b'],
|
||||||
|
[:z80, ['-b', '-r']],
|
||||||
|
['old-prob-update', '-b']
|
||||||
]
|
]
|
||||||
|
|
||||||
files = Dir[ARGV[0] + '/*'].select {|f| !(f =~ /\.txt$/) }
|
files = Dir[ARGV[0] + '/*'].select {|f| !(f =~ /\.txt$/) }
|
||||||
@@ -34,8 +36,8 @@ for config in configs
|
|||||||
config_results = []
|
config_results = []
|
||||||
results << config_results
|
results << config_results
|
||||||
for file in files
|
for file in files
|
||||||
if system('cargo', 'run', '--release', 'pack', '-l', '9', config[1], file, '/tmp/out.upk') &&
|
if system(*['cargo', 'run', '--release', 'pack', '-l', '9', config[1], file, '/tmp/out.upk'].flatten) &&
|
||||||
system('cargo', 'run', '--release', 'unpack', config[1], '/tmp/out.upk', '/tmp/out.bin') &&
|
system(*['cargo', 'run', '--release', 'unpack', config[1], '/tmp/out.upk', '/tmp/out.bin'].flatten) &&
|
||||||
File.read(file) == File.read('/tmp/out.bin')
|
File.read(file) == File.read('/tmp/out.bin')
|
||||||
size = File.size('/tmp/out.upk')
|
size = File.size('/tmp/out.upk')
|
||||||
config_results << size
|
config_results << size
|
||||||
|
|||||||
@@ -33,13 +33,12 @@ impl<'a> Context<'a> {
|
|||||||
|
|
||||||
pub fn update(&mut self, bit: bool) {
|
pub fn update(&mut self, bit: bool) {
|
||||||
let old = self.state.contexts[self.index];
|
let old = self.state.contexts[self.index];
|
||||||
let offset = if !bit {
|
if bit {
|
||||||
ONE_PROB as i32 >> UPDATE_RATE
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
self.state.contexts[self.index] =
|
self.state.contexts[self.index] =
|
||||||
(offset + old as i32 - ((old as i32 + UPDATE_ADD) >> UPDATE_RATE)) as u8;
|
old - ((old as i32 + UPDATE_ADD) >> UPDATE_RATE) as u8;
|
||||||
|
} else {
|
||||||
|
self.state.contexts[self.index] =
|
||||||
|
old + (((ONE_PROB as i32 - old as i32) + UPDATE_ADD) >> UPDATE_RATE) as u8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user