Project

General

Profile

Download (3.33 KB) Statistics
| Branch: | Revision:

distorted-objectlib / src / main / java / org / distorted / objectlib / tablebases / TablebasesMITM.java @ 00947987

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2023 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.objectlib.tablebases;
11

    
12
///////////////////////////////////////////////////////////////////////////////////////////////////
13

    
14
public abstract class TablebasesMITM extends TablebasesAbstract
15
{
16
  private PruningTable mTable;
17

    
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
  public TablebasesMITM()
21
    {
22
    super();
23
    }
24

    
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26

    
27
  private String createAdjusted(int num)
28
    {
29
    if( num<10  ) return "   "+num;
30
    if( num<100 ) return  "  "+num;
31
    if( num<1000) return   " "+num;
32

    
33
    return Integer.toString(num);
34
    }
35

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

    
38
  private int numBytesForIndices(int total)
39
    {
40
    int bytes = 0;
41

    
42
    while(total!=0)
43
      {
44
      total>>=8;
45
      bytes++;
46
      }
47

    
48
    return bytes;
49
    }
50

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

    
53
  public void probe(int level, int numBits)
54
    {
55
    /*
56
    int numPos = 0;
57
    int numsInBucket = (1<<numBits);
58
    int numBuckets = (mSize+numsInBucket-1)/numsInBucket;
59
    int[] bucket = new int[numBuckets];
60

    
61
    for(int i=0; i<mSize; i++)
62
      if( mTablebase.retrieveUnpacked(i)==level )
63
        {
64
        numPos++;
65
        int currBucket = i/numsInBucket;
66
        bucket[currBucket]++;
67
        }
68

    
69
    int totalBytesForTable = 0;
70
    int maxObjectsInBucket = 0;
71

    
72
    for(int i=0; i<numBuckets; i++)
73
      {
74
      int numBytes = (bucket[i]*numBits+7)/8;
75
      totalBytesForTable+=numBytes;
76
      if( bucket[i]>maxObjectsInBucket ) maxObjectsInBucket = bucket[i];
77
      }
78

    
79
    int totalBytesForBuckets = numBuckets*numBytesForIndices(totalBytesForTable);
80
    int constantModeBytes = (maxObjectsInBucket*numBits+7)/8;
81

    
82
    android.util.Log.e("D","bits: "+numBits+" header: 4 buckets: "+totalBytesForBuckets+" table: "+totalBytesForTable+
83
                            " total: "+(4+totalBytesForBuckets+totalBytesForTable)+
84
                            " max : "+maxObjectsInBucket+" total constant: "+(numBuckets*constantModeBytes+4));
85
    */
86
    }
87

    
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

    
90
  public void pack(int level, int numBits)
91
    {
92
    //mTable = new PruningTable(mTablebase,level,numBits);
93
    }
94

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

    
97
  public int[][] solution(int index, int[] extra)
98
    {
99
    return null;
100
    }
101
}
(9-9/12)