-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.cs
71 lines (55 loc) · 2.47 KB
/
Utils.cs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Runtime.InteropServices;
namespace Cannon_GUI
{
/*
* Set of constants used in the program
*/
public static class Constants
{
//Size of the board in tiles, assume squared board
public const int Size = 10;
//Distance from the boarder of the image, in pixels
public const int BoardOffSet = 30;
//Length size of the tile in the background image, in pixels
public const int TileSize = 70;
//public const int CannonLength = 3;
public static readonly Position Removed = new Position(-1, -1);
public static readonly Position NotPlaced = new Position(10, 10);
public const int AlphabetStart = 65; //65 -> 'A'
public static readonly TimeSpan MaxTime = TimeSpan.FromMinutes(30);
public static readonly TimeSpan MaxIteration = TimeSpan.FromSeconds(5);
public static readonly Move NullMove = new Move(Removed, Removed, MoveType.none);
public static readonly bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
public static string Slash = IsWindows ? "\\" : "/";
//Gtk# does not support svg images on windows °-°
public static string ImgExt = IsWindows ? "png" : "svg";
public const int ClockResolution = 100; //The clock is ticking...
public static int HashKeySize = IsWindows ? 28 : 29; // Size of the primary hash in bits, set to 28 on windows
public static readonly TTEntry NullTTEntry = new TTEntry(TTType.none, NullMove, 0, -1, 0);
public const int HistTableSize = 1000; // about 81 starting positions * 12 destinations for each position
public const int KillerTableSize = 10; // 10 plyes should be enough
public const int Extension = 1; // search deeper with capture moves
}
/*
* Class with static methods used in the program
*/
public static class Utils
{
public static readonly int[] hashBase;
private static readonly Random rnd;
static Utils()
{
rnd = new Random(0);
hashBase = new int[(Constants.Size * Constants.Size) * 3 + 2]; //100 positions * 3 values + 2 player colors
for (int i = 0; i < hashBase.Length; i++)
{
hashBase[i] = rnd.Next();
}
}
public static TileColor SwitchColor(TileColor color)
{
return (color == TileColor.Dark ? TileColor.Light : TileColor.Dark);
}
}
}