Solving the N-Queens Problem - The Easiest Algorithm

  Рет қаралды 7,587

OttoBotCode

OttoBotCode

Күн бұрын

Пікірлер: 24
@rodrigomarchi9755
@rodrigomarchi9755 Жыл бұрын
This video was very well-made. You earned a new sub.
@OttoBotCode
@OttoBotCode Жыл бұрын
Thanks! I appreciate it ☺
@icangicung20
@icangicung20 2 жыл бұрын
this video is super interesting!!
@OttoBotCode
@OttoBotCode 2 жыл бұрын
Thanks! 😊
@electron7373
@electron7373 Жыл бұрын
Excellent explanation and the graphics really helped.
@OttoBotCode
@OttoBotCode Жыл бұрын
Thank you 😀
@JoeCoup1
@JoeCoup1 Ай бұрын
This a great video :)
@abdulhamedeid935
@abdulhamedeid935 9 ай бұрын
in the fastest way how did you know the number of conflicts if we have how many queens in each column, diagonal
@rejeanbazinet3844
@rejeanbazinet3844 Жыл бұрын
very good video, chess search algorithm will be a nice too, ex. minimax versus other algorithm or mix of them.
@richardmartinez2524
@richardmartinez2524 Жыл бұрын
Buena tarde. No ha aplicado para ganar el premio del Instituto Clay?.
@user-gb7nu9xl1y
@user-gb7nu9xl1y Жыл бұрын
This might be a dumb question, but if possible can you give a tip in how to generate all possible children in a random order?
@OttoBotCode
@OttoBotCode Жыл бұрын
That's a great question! When the program starts, you can generate a list containing all moves. Each move can be stored as a pair (r, c) where r is a row index and c is column index. The move (r, c) says "move the queen in row r to column c". For each step in the algorithm, you shuffle the list of moves and then generate the resulting states one by one. This approach will give you a truly random state generation order, but there is a problem with it. There are O(N^2) moves, so shuffling at every step is slow. Instead, I decided to use two arrays called rowOrder and colOrder. Both arrays contain the N integers from 0 to N-1 (in some random order). To generate the states, I loop over rowOrder, and for each row, try all columns in colOrder. This move ordering is not completely random, but it is much faster to shuffle these two arrays at every step. Hope this makes sense! 😀
@itsjustcory8487
@itsjustcory8487 2 жыл бұрын
What kind of algorithm is this? ive been learning about some hill climbing and best first searches in university lectures about ai and i wanted to know how you would describe it
@OttoBotCode
@OttoBotCode 2 жыл бұрын
Exactly! This is a hill climbing algorithm. The algorithm starts at a random state and repeatedly improves upon it (or climbs the hill 😉). It does so by picking the best state it can reach by moving a single queen. There are many variations on hill climbing algorithms. In the end of the video we look at a technique which can sometimes be used to get better results. Thanks for watching 😃
@LarsAndersenFrihed
@LarsAndersenFrihed Жыл бұрын
Really nice video. Godt arbejde.
@OttoBotCode
@OttoBotCode Жыл бұрын
Mange tak!
@megistone
@megistone Жыл бұрын
Hello, I liked ur video, is this A* algorithm? Can u please share the code if it's can be shared
@OttoBotCode
@OttoBotCode Жыл бұрын
Glad you like it 😀 It's not A*, it is a hill climbing algorithm. I can't share the code with you at the moment, sorry. Definitely read up on hill climbing algorithms - they are pretty simple to understand and implement. Best of luck and thanks for your comment 😊
@megistone
@megistone Жыл бұрын
@@OttoBotCode np u too)
@richardmartinez2524
@richardmartinez2524 Жыл бұрын
Excelente trabajo.
@manuellopezanido
@manuellopezanido 2 жыл бұрын
Isn't this video solving the N=NP problem?
@OttoBotCode
@OttoBotCode 2 жыл бұрын
Unfortunately not 😉. The algorithm used here appears to be quite efficient in practice but there is no theoretical guarantee about it's running time! Thanks for watching 😀
@geegee3702
@geegee3702 Жыл бұрын
the N=NP is not about how many complexity you add to the problem i think, i mean, in this 1000 queens example is not important if its 1000, 1million or infinite queens, or the time you need every complet solution, the N=NP problem target is another thing related to this process, is easy to check the results but harder to produce that results, if the times it takes for check for every solution is the same than the time it takes to find that solution, thats it i think
@bensalemmohamedabderrahman5649
@bensalemmohamedabderrahman5649 Жыл бұрын
the np problem is related to finding all possible configurations , not finding one .
This Unbeatable Tic-Tac-Toe AI Is Rude! (MiniMax Algorithm)
13:54
OttoBotCode
Рет қаралды 2,5 М.
N-queens problem (Backtracking) - Inside code
14:13
Inside code
Рет қаралды 7 М.
The Joker wanted to stand at the front, but unexpectedly was beaten up by Officer Rabbit
00:12
HAH Chaos in the Bathroom 🚽✨ Smart Tools for the Throne 😜
00:49
123 GO! Kevin
Рет қаралды 16 МЛН
Can you solve this chess puzzle? (8 Queens problem)
10:10
Double D
Рет қаралды 28 М.
hillClimbing 8 queens
14:51
Francisco Iacobelli
Рет қаралды 60 М.
Optimising Code - Computerphile
19:43
Computerphile
Рет қаралды 147 М.
I used to hate QR codes. But they're actually genius
35:13
Veritasium
Рет қаралды 597 М.
10 FORBIDDEN Sorting Algorithms
9:41
Ardens
Рет қаралды 866 М.
Backtracking Explained - Solving N-Queens and Knight's Tour using Python
10:09
15 Years Writing C++ - Advice for new programmers
4:04
SyncMain
Рет қаралды 1,2 МЛН
The N Queens Problem using Backtracking/Recursion - Explained
14:29
Back To Back SWE
Рет қаралды 136 М.
Puzzle 5: Keep Those Queens Apart
52:44
MIT OpenCourseWare
Рет қаралды 15 М.
N-Queens Problem - Backtracking
15:12
CSBreakdown
Рет қаралды 49 М.
The Joker wanted to stand at the front, but unexpectedly was beaten up by Officer Rabbit
00:12