-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.lua
83 lines (62 loc) · 1.61 KB
/
template.lua
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
72
73
74
75
76
77
78
79
80
81
82
83
---------------------------------------------------------
--
-- template.lua consists of init functions for variables
-- declared in randomino.lua
--
---------------------------------------------------------
local Var = ...
local lowest_weight = 3
Var.WeightMax.init = function()
return math.random(lowest_weight, Var.Config().MaxFigureSize)
end
Var.WeightMin.init = function()
local bottom = lowest_weight - (Var.WeightMax() - lowest_weight)
if bottom < 1 then bottom = 1 end
if Var.Goal() == 1 then bottom = lowest_weight end
return math.random(bottom, Var.WeightMax())
end
Var.Aperture.init = function()
local weight = Var.WeightMax()
local metric = Var.Metric()
local ap_min = {
[0] = {1, 2, 4, 4, 4, 4, 5, 5},
[1] = {1, 2, 3, 3, 3, 3, 4, 4}
}
local ap_max = {
[0] = {1, 2, 5, 5, 5, 6, 6, 6},
[1] = {1, 2, 4, 4, 5, 5, 5, 5}
}
local aperture = 0
if weight == lowest_weight or math.random(0, 1) == 1 then
aperture = math.random(ap_min[metric][weight], ap_max[metric][weight])
end
return aperture
end
Var.GlassWidth.init = function()
return 2 * Var.FigureSize()
end
Var.GlassHeight.init = function()
local k = 2
if Var.Goal() == 1 then
k = 5
end
return k * Var.FigureSize()
end
Var.DiscardFullRows.init = function()
if Var.Goal() == 1 then
return 1
end
end
Var.FillLevel.init = function()
if Var.Goal() == 1 then
return 2 * Var.FigureSize()
end
return 0
end
Var.FillRatio.init = function()
local ratio = Var.GlassWidth() - 1 - (Var.WeightMax() - lowest_weight)
if Var.SingleLayer() > 0 then
ratio = ratio // 2
end
return ratio
end