Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int linearConflict(node u, node g)
- {
- int cnt=0, tj, tk;
- bool f;
- pp temp[u.n * u.n];
- for(int i = 0; i< u.n; i++)
- {
- for(int j=0 ; j < u.n; j++)
- temp[g.board[i][j]] = {i, j};
- }
- //conflict counting in the rows
- for(int i = 0; i< u.n; i++)
- {
- for(int j = 0; j < u.n - 1; j++)
- {
- tj = u.board[i][j];
- if(tj == 0)
- continue;
- for(int k = j + 1; k < u.n; k++)
- {
- tk = u.board[i][k];
- if(tk == 0)
- continue;
- //check if tj and tk are in goal row, then if tj is in right of tk
- if(temp[tj].first == i && temp[tk].first == i && temp[tj].second > temp[tk].second)
- cnt++;
- }
- }
- }
- //conflict counting in the columns
- for(int i = 0; i< u.n; i++)
- {
- for(int j = 0; j < u.n - 1; j++)
- {
- tj = u.board[j][i];
- if(tj == 0)
- continue;
- for(int k = j + 1; k < u.n; k++)
- {
- tk = u.board[k][i];
- if(tk == 0)
- continue;
- //check if tj and tk are in goal column, then if tj is downwards wrt tk
- if(temp[tj].second == i && temp[tk].second == i && temp[tj].first > temp[tk].first)
- cnt++;
- }
- }
- }
- return cnt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement