As far as I see it (correct me if I'm wrong):
- isplaceok is the argument for placing the queens, checking if the places don't intervene.
- addqueen adds the queen at the spot to a column, then isplaceok checks if the spot is available, from n to N until N+1 queens have been placed.
Update: Edited 2nd part, sorry for that.
As far as I see it (correct me if I'm wrong):
- isplaceok is the argument for placing the queens, checking if the places don't intervene.
- addqueen adds the queen at the spot to a column, then isplaceok checks if the spot is available, from n to N until N+1 queens have been placed.
Update: Edited 2nd part, sorry for that.
Yeah, I understand that, but how does it compute isplaceok? I fail to understand how it references the index i of table a. When it returns false, does it repeat the function with the next cycle of i? Or does it return false, quit the function and do the next cycle of for c = 1, N?
sooo? is this a game? whats the aim?
As far as I see it (correct me if I'm wrong):
- isplaceok is the argument for placing the queens, checking if the places don't intervene.
- addqueen adds the queen at the spot to a column, then isplaceok checks if the spot is available, from n to N until N+1 queens have been placed.
Update: Edited 2nd part, sorry for that.
Yeah, I understand that, but how does it compute isplaceok? I fail to understand how it references the index i of table a. When it returns false, does it repeat the function with the next cycle of i? Or does it return false, quit the function and do the next cycle of for c = 1, N?
Table a is a table that has a list of colums where in the queens are placed. It then checks for each row whether the position is clear (i, n-1)
That's the step.
If a[ i ] == c1 or diagonal etc., the place can be attacked therefore, no queen can be placed.
It returns false.
No queen placed.
Then moves to placing the queen in a different column (c1 =/= c2)
And a new cycle begins.sooo? is this a game? whats the aim?
@Manuster A riddle/puzzle with queens upon a chess board.
Sorry... I misunderstood the code as well... Let me try it again. There are no rows in this code (besides printing the board).
You start the command with addqueen({},1} with a = {} and n = 1. n being the queen number and c being the columns.
It will start with c = 1, then look through at the board for arguments (in isplaceok).
If result = false it will go to c = 2 and loop the isplaceok again for a different i.
If result = true it will add the column number (c) to the n-th place in table a.Spoiler: show
Hope this helped.
----
You start the command with addqueen({},1} with a = {} and n = 1. n being the queen number and c being the columns.
It will start with c = 1, then look through at the board for arguments (in isplaceok).
If result = false it will loop the isplaceok again for a different i.
If result = true it will add the column number (c) to the n-th place in table a. Then it will do c+1 and repeat the loop again.
----
Aye I see. Anycase, updated my previous post again bc I'm a dumbass coder.
----
You start the command with addqueen({},1} with a = {} and n = 1. n being the queen number and c being the columns.
It will start with c = 1, then look through at the board for arguments (in isplaceok).
If result = false it will loop the isplaceok again for a different i.
If result = true it will add the column number (c) to the n-th place in table a. Then it will do c+1 and repeat the loop again.
----
That should be the answer to your question.
Yeah exactly... Let me correct myself then.
If result = false it will loop the isplaceok again for a different i.
If all i's are used, it will move to the next column (c+1)
If result = true it will add the column number (c) to the n-th place in table a. then, it will move to placing the next queen (n+1), resetting the column count.
Reason this makes sense: you cannot place the queen in the same column, or they can attack each other.