-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dice.cpp
51 lines (46 loc) · 833 Bytes
/
Dice.cpp
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
/*
3
1 0 4
2
5
*/
int dice[6][6] ={ // [top][front] -> right
{-1, 2, 4, 1, 3,-1},
{ 3,-1, 0, 5,-1, 2},
{ 1, 5,-1,-1, 0, 4},
{ 4, 0,-1,-1, 5, 1},
{ 2,-1, 5, 0,-1, 3},
{-1, 3, 1, 4, 2,-1}
};
/*
2
1 0 4
3
5
*/
int dice[6][6] ={ // [top][front] -> right
{-1, 3, 1, 4, 2,-1},
{ 2,-1, 5, 0,-1, 3},
{ 4, 0,-1,-1, 5, 1},
{ 1, 5,-1,-1, 0, 4},
{ 3,-1, 0, 5,-1, 2},
{-1, 2, 4, 1, 3,-1}
};
/* 以下の座標系で動かすときのdx,dy,df
┼─→ y
│
↓
x
[k] 1
↑
3 ← → 2
↓
0
*/
const int dx[] = {1,-1,0,0}, dy[]={0,0,1,-1};
function<pair<int,int>(int,int)> df[] = { // return <top,front>
[&](int t, int f){return mp(5-f, t);},
[&](int t, int f){return mp(f, 5-t);},
[&](int t, int f){return mp(5-dice[t][f], f);},
[&](int t, int f){return mp(dice[t][f], f);}
};