1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | module Fork struct Zobrist INSTANCE = new getter pieces : Array(Array(Array(UInt64))) getter side : UInt64 getter castle : Array(UInt64) getter en_passant : Array(UInt64) def initialize rand = Random.new @pieces = WHITE.upto(BLACK).map do PAWN.upto(KING).map do A1.upto(H8).map do rand.rand(UInt64::MAX) end.to_a end.to_a end.to_a @side = rand.rand(UInt64::MAX) @castle = 0.upto(0xF).map do rand.rand(UInt64::MAX) end.to_a @en_passant = 0.upto(7).map do rand.rand(UInt64::MAX) end.to_a end end end |