//public void ResetTable() //{ // Array.Clear(table, 0, size); //} public static void Serialize(TranspositionTable tabla) { try { using (BinaryWriter bw = new BinaryWriter(new FileStream("table.bin", FileMode.Create))) { TableData td; for (int i = 0; i < size; i++) { td = tabla.table[i]; if (td != null) { bw.Write(td.current); bw.Write(td.mask); bw.Write(td.value); bw.Write(td.depth); } } } } catch (Exception e) { Console.WriteLine(e.Message); } }
public Computer(int id) : base(id) { moveOrder = new int[col]; if (transpTable == null) { transpTable = new TranspositionTable(); } for (int k = 0; k < col; k++) { moveOrder[k] = col / 2 + (1 - 2 * (k % 2)) * (k + 1) / 2; } }
public static TranspositionTable Deserialize() { TranspositionTable newTable = new TranspositionTable(); try { using (BinaryReader br = new BinaryReader(new FileStream("table.bin", FileMode.Open))) { while (true) //posto ne znamo koliko ce puta da procita, kada dodje do kraja streama, baci exception EndOfStream { newTable.Add(br.ReadUInt64(), br.ReadUInt64(), br.ReadInt16(), br.ReadByte()); } } } catch (EndOfStreamException e) { Console.WriteLine(e.Message); return(newTable); } catch (Exception e) { Console.WriteLine(e.Message); return(new TranspositionTable()); } }