{"id":27050806,"url":"https://github.com/rizquuula/nqueenplay","last_synced_at":"2026-07-03T01:04:23.944Z","repository":{"id":58987297,"uuid":"534600865","full_name":"rizquuula/nqueenplay","owner":"rizquuula","description":"N-Queens puzzle player. This tool will generate randomly or randomly locked puzzle, you may use this as \"a boxing bag\" to practice problem solving algorithm.","archived":false,"fork":false,"pushed_at":"2022-09-21T03:32:30.000Z","size":47,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-19T19:49:32.779Z","etag":null,"topics":["algorithm","n-queens","nqueens","puzzle"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/nquuenplay","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rizquuula.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-09T10:40:41.000Z","updated_at":"2023-03-26T10:47:33.000Z","dependencies_parsed_at":"2022-09-11T23:41:15.417Z","dependency_job_id":null,"html_url":"https://github.com/rizquuula/nqueenplay","commit_stats":null,"previous_names":["eiproject/nqueenplay"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizquuula%2Fnqueenplay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizquuula%2Fnqueenplay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizquuula%2Fnqueenplay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizquuula%2Fnqueenplay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rizquuula","download_url":"https://codeload.github.com/rizquuula/nqueenplay/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247306468,"owners_count":20917323,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","n-queens","nqueens","puzzle"],"created_at":"2025-04-05T08:19:35.591Z","updated_at":"2025-10-27T16:04:58.764Z","avatar_url":"https://github.com/rizquuula.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nqueenplay\n\n```py\n    1   2   3   4   5   6   7   8 \n  ---------------------------------\n8 |   |   | Q |   |   |   |   |   | 8\n  ---------------------------------\n7 |   |   |   |   | Q |   |   |   | 7\n  ---------------------------------\n6 |   |   |   |   |   |   |   | Q | 6\n  ---------------------------------\n5 |   |   |   | Q |   |   |   |   | 5\n  ---------------------------------\n4 | Q |   |   |   |   |   |   |   | 4\n  ---------------------------------\n3 |   |   |   |   |   |   | Q |   | 3\n  ---------------------------------\n2 |   | Q |   |   |   |   |   |   | 2\n  ---------------------------------\n1 |   |   |   |   |   | Q |   |   | 1\n  ---------------------------------\n    1   2   3   4   5   6   7   8 \n```\n\n`nqueenplay` is N-Queens puzzle player. This tool will generate randomly or randomly locked puzzle, you may use this as \"a boxing bag\" to practice problem solving algorithm.\n\n![GitHub](https://img.shields.io/github/license/eiproject/nqueenplay)\n![GitHub repo size](https://img.shields.io/github/repo-size/eiproject/nqueenplay)\n![GitHub contributors](https://img.shields.io/github/contributors/eiproject/nqueenplay)\n\n## Installation\n\nThis python package available on pip installation using\n\n`pip install nqueenplay`\n\n## Requirements\n\nAvailable on Python 3\n\n## Documentation\n\nA to Z explanations to use this tool\n\n### Generate Random Puzzle\n\nTo generate a random puzzle you can do:\n\n```py\nN = 4 # any integer\nnqueens = NQueen(N)\n```\n\nor\n\n```py\nN = 4 # any integer\nnqueens = NQueen(n=N, number_lock=0) # 0 = no lock\n```\n\n### Generate Random Locked Puzzle\n\nRandom locked mean the distribution of queen is randomize, and there is locking mechanism to make sure the queen position won't change for another run. To generate a random locked puzzle you can do:\n\n```py\nN = 4 # any integer\nlock = 1 # any integer\nnqueens = NQueen(n=N, number_lock=lock)\n```\n\n### Get Number of Queens\n\nTo get number of queen:\n\n```py\nN = 4\nnqueens = NQueen(n=N, number_lock=1)\nnumber_of_queen = nqueens.get_number_of_queens()\n```\n\nOutput:\n\n```py\nprint(number_of_queen)\n# 4\n```\n\n### Get Queens Position\n\nTo get queen position:\n\n```py\nN = 4\nnqueens = NQueen(n=N, number_lock=1)\npositions = nqueens.get_queen_positions()\n```\n\nOutput:\n\n```py\nprint(positions)\n# [(1, 1), (2, 4), (3, 3), (4, 2)]\n```\n\nEach tuple is The Queen coordinate, there is 4 attack pairs\n\n### Check Number of Attack Pairs\n\nTo check how many attack pairs in the current board:\n\n```py\nN = 4\nnqueens = NQueen(n=N, number_lock=1)\npairs = nqueens.get_attack_pairs()\n```\n\nOutput:\n\n```py\nprint(pairs) \n# [[(1, 1), (3, 3)], [(2, 4), (3, 3)], [(2, 4), (4, 2)], [(3, 3), (4, 2)]]\n```\n\nEach tuple is The Queen coordinate, there is 4 attack pairs\n\n### Show The Board\n\nTo show the current board:\n\n```py\nN = 4\nnqueens = NQueen(n=N, number_lock=1)\nnqueens.show()\n```\n\noutput:\n\n```py\n    1   2   3   4 \n  -----------------\n4 |   | Q |   |   | 4\n  -----------------\n3 |   |   | Q |   | 3\n  -----------------\n2 |   |   |   | Q | 2\n  -----------------\n1 | Q |   |   |   | 1\n  -----------------\n    1   2   3   4 \n```\n\n### Show The Attack Pairs\n\nTo show the current board attack pairs:\n\n```py\nN = 4\nnqueens = NQueen(n=N, number_lock=1)\nnqueens.show_attack_pairs()\n```\n\noutput\n\n```py\n# attack_pairs [(1, 3), (2, 3), (2, 4), (3, 4)]\n# Number of attacking pair(s): 4\n```\n\n### Move The Queen\n\nQueen is column locked, so you can only move one queen to a different row\n\n#### Move the queen upside\n\nMove Queen to upside with specific range:\n\n```py\nN = 4\nnqueens = NQueen(n=N, number_lock=1)\nnqueens.show()\nnqueens.move_up(queen_pos=1, movement_length=2)\nnqueens.show()\n```\n\noutput:\n\n```py\n    1   2   3   4 \n  -----------------\n4 |   | Q |   |   | 4\n  -----------------\n3 |   |   | Q |   | 3\n  -----------------\n2 |   |   |   | Q | 2\n  -----------------\n1 | Q |   |   |   | 1\n  -----------------\n    1   2   3   4 \n    1   2   3   4 \n  -----------------\n4 |   | Q |   |   | 4\n  -----------------\n3 | Q |   | Q |   | 3\n  -----------------\n2 |   |   |   | Q | 2\n  -----------------\n1 |   |   |   |   | 1\n  -----------------\n    1   2   3   4 \n```\n\n#### Move the queen downside\n\nMove Queen to downside with specific range:\n\n```py\nN = 4\nnqueens = NQueen(n=N, number_lock=1)\nnqueens.show()\nnqueens.move_down(queen_pos=2, movement_length=2)\nnqueens.show()\n```\n\noutput:\n\n```py\n    1   2   3   4 \n  -----------------\n4 |   | Q |   |   | 4\n  -----------------\n3 |   |   | Q |   | 3\n  -----------------\n2 |   |   |   | Q | 2\n  -----------------\n1 | Q |   |   |   | 1\n  -----------------\n    1   2   3   4 \n    1   2   3   4 \n  -----------------\n4 |   |   |   |   | 4\n  -----------------\n3 |   |   | Q |   | 3\n  -----------------\n2 |   | Q |   | Q | 2\n  -----------------\n1 | Q |   |   |   | 1\n  -----------------\n    1   2   3   4 \n```\n\n#### Move the queen on specific neighbor\n\nMove Queen to a specific neighbor by neighbor row position:\n\n```py\nN = 4\nnqueens = NQueen(n=N, number_lock=1)\nnqueens.show()\nnqueens.move_to(queen_pos=2, target_pos=1)\nnqueens.show()\n```\n\noutput:\n\n```py\n    1   2   3   4 \n  -----------------\n4 |   | Q |   |   | 4\n  -----------------\n3 |   |   | Q |   | 3\n  -----------------\n2 |   |   |   | Q | 2\n  -----------------\n1 | Q |   |   |   | 1\n  -----------------\n    1   2   3   4 \n    1   2   3   4 \n  -----------------\n4 |   |   |   |   | 4\n  -----------------\n3 |   |   | Q |   | 3\n  -----------------\n2 |   |   |   | Q | 2\n  -----------------\n1 | Q | Q |   |   | 1\n  -----------------\n    1   2   3   4 \n```\n\n#### Move the queen to a random placement\n\nMove Queen to random place in the column:\n\n```py\nN = 4\nnqueens = NQueen(n=N, number_lock=1)\nnqueens.show()\nnqueens.move_random(queen_pos=3)\nnqueens.show()\n```\n\noutput:\n\n```py\n    1   2   3   4 \n  -----------------\n4 |   | Q |   |   | 4\n  -----------------\n3 |   |   | Q |   | 3\n  -----------------\n2 |   |   |   | Q | 2\n  -----------------\n1 | Q |   |   |   | 1\n  -----------------\n    1   2   3   4 \n    1   2   3   4 \n  -----------------\n4 |   | Q |   |   | 4\n  -----------------\n3 |   |   |   |   | 3\n  -----------------\n2 |   |   | Q | Q | 2\n  -----------------\n1 | Q |   |   |   | 1\n  -----------------\n    1   2   3   4 \n```\n\n## Copyright\n\nFree to use! Under MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizquuula%2Fnqueenplay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frizquuula%2Fnqueenplay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizquuula%2Fnqueenplay/lists"}