-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
84 lines (72 loc) · 1.79 KB
/
config.js
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
84
const constants = require('./constants')
// neural network activation function
/*
Available activation functions:
- leaky-relu
- relu
- sigmoid
*/
const activationFn = 'leaky-relu'
/*
Neural network hidden layers
Every element of the array defines the number of neurons for that layer.
*/
const hiddenLayers = [800, 100]
// neural network learning rate
const learningRate = 0.1
const learnedRewardNum = 5000
/*
Should the network use random moves
If set to false the network might not learn the best actions.
This parameter will be turned off when the network has been trained.
*/
const useRandom = true
/*
Should the network be trained or not. Probably wise to leave it set to "true"
*/
const shouldTrainNetwork = true
/*
Which block should be used for the game
Available block values:
- LBlock
- JBlock
- IBlock
- OBlock
- SBlock
- ZBlock
- TBlock
- false => this means to use all the fixed blocks
*/
const fixedBlock = 'JBlock'
/*
This parameter defines the number of moves when the user thinks the bot has learned.
After the bot has made "learnedMoveCount" actions then the training will stop to see
if it has truly learned how to play.
*/
const learnedMoveCount = 100
function constructNetworkInitialData (input, output) {
const initialData = [{
input: [],
output: [10],
}, {
input: [],
output: [0],
}]
const vectorSize = constants.ai.COLUMN_COUNT * constants.ai.VECTOR_ROW_COUNT
for (let i = 0; i < vectorSize; i++) {
initialData[0].input.push(0)
initialData[1].input.push(1)
}
return initialData
}
module.exports = {
activationFn,
useRandom,
fixedBlock,
learnedMoveCount,
shouldTrainNetwork,
learnedRewardNum,
initialTrainingData: constructNetworkInitialData(),
hiddenLayers,
learningRate,
}