We are using the same definition of non-linearity. Of course KING_SAFETY_WEIGHT can be tuned and its contribution to the score is linear, but presumably there are parameters that are implied in the definition of king safety. For instance, I count an attack by a knight as 2, by a bishop as 2, by a rook as 3 and an attack by a queen as 5. I add these contributions for one side, compute the square and that is the term that is scaled by something like your KING_SAFETY_WEIGHT. But I would like to be able to adjust the numbers involved in the definition of the term (2, 2, 3 and 5) as well.Daniel Shawul wrote:Note that we are talking about linearity with regard to the parameters. In other words, no two parameters should mulitply or divide (they can sum & subtract) or be used as a test condition to apply another evaluation term. With this definition, i can see my evaluation function to be totally linear. For example, for king safety, I use the number of attacks from pieces, calculate the phase etc and multiply by KING_SAFETY_WEIGHT. Now since the phase is determined by number of pieces (not sum value of pieces), number of attacks by presence of a piece (not its value), it is still linear.AlvaroBegue wrote:Mine certainly isn't. I am not sure how you express in a linear function that endgames with opposite-color bishops are drawish, or that you need to coordinate several pieces to mount an effective attack on the king. Those things are naturally non linear.Daniel Shawul wrote:A third point :
Since most evaluation functions are linear[...]
The opposite color bishops case should also be a property of the position and be linear in the paramters. I am calculating the gradient of the eval with respect to the parameters for each position, so if you don't change the position the gradient should remain the same. With the stochastic sampling, you are sampling different positions so the mean of the gradients will be different from iteration to iteration. But if you consider all positions, you only need to compute it once. Computing and storing the Hessian is probably an overkill especially with large number of parameters.
Can you give an eval term that is non-linear by this definition ?
The drawishness of opposite-color bishops is implemented as a final step in the evaluation function, after the linear combination of terms has already been computed, and it consists of a scaling factor that is applied if certain conditions apply. If I wanted to tune this scaling factor at the same time as any of the other parameters, I wouldn't be looking at a linear function.