Slight improvement
This commit is contained in:
@@ -8,10 +8,8 @@ type Code struct {
|
||||
var codes = [256]Code{
|
||||
{Value: 0b0000, Bits: 4},
|
||||
{Value: 0b0001, Bits: 4},
|
||||
{Value: 0b00100, Bits: 5},
|
||||
{Value: 0b00101, Bits: 5},
|
||||
{Value: 0b00110, Bits: 5},
|
||||
{Value: 0b00111, Bits: 5},
|
||||
{Value: 0b0010, Bits: 4},
|
||||
{Value: 0b0011, Bits: 4},
|
||||
{Value: 0b01000, Bits: 5},
|
||||
{Value: 0b01001, Bits: 5},
|
||||
{Value: 0b01010, Bits: 5},
|
||||
@@ -262,6 +260,8 @@ var codes = [256]Code{
|
||||
{Value: 0b1111111011, Bits: 10},
|
||||
{Value: 0b1111111100, Bits: 10},
|
||||
{Value: 0b1111111101, Bits: 10},
|
||||
{Value: 0b1111111110, Bits: 10},
|
||||
{Value: 0b1111111111, Bits: 10},
|
||||
}
|
||||
|
||||
func CodeForIndex(index int) Code {
|
||||
|
||||
@@ -24,26 +24,16 @@ func main() {
|
||||
chat := seeds.ChatState()
|
||||
log.Printf("chat=%d [%s]", totalLength(chat, samples), chat)
|
||||
|
||||
chatOpt := optimize(chat, samples)
|
||||
if chatOpt == nil {
|
||||
log.Printf("\toptimal from further additions")
|
||||
} else {
|
||||
log.Printf("\tnot optimal [%s]", chatOpt)
|
||||
}
|
||||
|
||||
opt := optimize(state.NewState(), samples)
|
||||
log.Printf("opt=%d [%s]", totalLength(opt, samples), opt)
|
||||
}
|
||||
|
||||
func optimize(st *state.State, samples [][]byte) *state.State {
|
||||
var best *state.State
|
||||
|
||||
for true {
|
||||
better := optimize2(st, samples)
|
||||
if better == nil {
|
||||
return best
|
||||
return st
|
||||
}
|
||||
best = better
|
||||
st = better
|
||||
log.Printf("\titer=%d [%s]", totalLength(st, samples), st)
|
||||
}
|
||||
|
||||
@@ -5,19 +5,22 @@ import (
|
||||
)
|
||||
|
||||
var chatState = newStateFromSeed([][]byte{
|
||||
/* 01 */ []byte("',.0:?CIbgjkpvxz\xea"),
|
||||
/* 02 */ []byte("\nfw"),
|
||||
/* 03 */ []byte("cdmuy"),
|
||||
/* 01 */ []byte("',.?CIbcfjkpvxz\xea"),
|
||||
/* 02 */ []byte("dgwy"),
|
||||
/* 03 */ []byte("\nmru"),
|
||||
/* 04 */ []byte("l"),
|
||||
/* 05 */ []byte("r"),
|
||||
/* 06 */ []byte("t"),
|
||||
/* 07 */ []byte("ahos"),
|
||||
/* 08 */ []byte("in"),
|
||||
/* 05 */ []byte("hns"),
|
||||
/* 06 */ []byte("a"),
|
||||
/* 07 */ []byte(""),
|
||||
/* 08 */ []byte("i"),
|
||||
/* 09 */ []byte(""),
|
||||
/* 10 */ []byte(""),
|
||||
/* 11 */ []byte(" "),
|
||||
/* 10 */ []byte(" "),
|
||||
/* 11 */ []byte(""),
|
||||
/* 12 */ []byte(""),
|
||||
/* 13 */ []byte("e"),
|
||||
/* 13 */ []byte(""),
|
||||
/* 14 */ []byte("et"),
|
||||
/* 15 */ []byte(""),
|
||||
/* 16 */ []byte("o"),
|
||||
})
|
||||
|
||||
func ChatState() *state.State {
|
||||
|
||||
Reference in New Issue
Block a user