9
votes
Accepted
7
votes
Logic for shuffling sliding puzzle
Object-oriented design
There is more data being passed around than should be necessary with an object-oriented design.
You have ran (a ...
6
votes
Accepted
Game of Fifteen - A Sliding Puzzle Game
The GOOD, there are no MAGIC numbers, good job! The naming conventions of the constants and enums follow
the current coding standards. The code is quite readable which suggests it is maintainable.
...
6
votes
Npuzzle solver using A* with Manhattan + Linear Conflict (Updated Code)
Don't put implementation in header files
You moved all of your code into header files. That's not what they are for. It is better to have only the declarations of the classes and functions in the .h ...
6
votes
Accepted
Simple N Puzzle console game
I think you're real close to the ask of the problem. I have two main bits for you to change up:
Your Tile class has no way of setting the tile value. Change so ...
5
votes
Accepted
SlidingNumberTile Program Efficiency
Boolean comparisons
Instead of:
if (isBoardSolved(pB, truths) == true) { ... }
else if (isBoardSolved(pB, truths) == false) { ... }
The natural way to write is:...
5
votes
A* search on 4x4 sliding tile puzzle scales poorly
You're doing the same mistake that everyone who posts that their A* is slow is doing.
You're using the wrong data structure for your open and closed structure. The closed should be a set, usually ...
5
votes
Accepted
Optimizing the code for 8-puzzle in Python
Initial thoughts:
Why optimize your code when there are 362 880 possibilities, the best way to optimize is to reduce the number of possibilities. The complexity here is O(n²!) meaning that it quickly ...
4
votes
4
votes
Logic for shuffling sliding puzzle
(Disclaimer: I'm not a Java-expert).
Moving the tile
You intentionally left this one as a black box, to keep it out of scope, I think, but I'd still like to comment.
...
4
votes
Accepted
8-Puzzle using A* and Manhattan Distance
Don't import things you don't use.
You can safely remove dt and sys.
Don't overwrite builtins. ...
4
votes
Accepted
Simple 8 Puzzle - ASCII - follow up
I see a number of things that may help you improve your code.
Don't use system("cls")
There are two reasons not to use ...
4
votes
Accepted
Sliding tiles solver in Python
Whether the code is well designed or not -- is hard to tell without using it. But I have several points:
It's good that you have small functions/methods which do one thing and do well. It's good that ...
4
votes
Accepted
Revised - Game of Fifteen
Functions that do not modify the referenced data should be made const to indicate that in fact, the code does not change things. It also allows some optimizations, ...
4
votes
Game of Fifteen - A Sliding Puzzle Game
Bug - Valid Move
Your valid_move method has this comment in it.
...
4
votes
Accepted
Storing configurations of states to a database - Breadth First Search
Prefer interfaces to implementations
public static ArrayList<State> findNeighbours(State currentState) {
Consider
...
4
votes
Accepted
Game of 15 - A* search
I'll focus on the readability part of your code:
Don't import modules you're not using. (import itertools)
Don't import modules in the middle of your code. All the ...
4
votes
A function that moves a tile in the game of fifteen
Reading past array bounds
Each of your four checks has the possibility of reading past array bounds. Very bad things can happen when that happens. I will illustrate with an example:
Let ...
4
votes
Accepted
A function that moves a tile in the game of fifteen
As suggested in this answer, storing the board as a one-dimensional array would make the logic much simpler. For one thing, the location of the space could be represented as a single ...
4
votes
N-puzzle solver using A* with Manhattan + Linear Conflict
Platform-dependent code
There's no need to bring in <Windows.h> - with a couple of small changes, this can be portable C++, accessible to everyone:
...
4
votes
Accepted
N-puzzle solver using A* with Manhattan + Linear Conflict
Bugs:
A lot of memory is allocated (foo = new Container) and never deallocated (delete foo).
N-puzzle implementations usually ...
4
votes
Accepted
Npuzzle solver using A* with Manhattan + Linear Conflict (Updated Code)
Good job refactoring. It looks much neater without the globals / Manager class. Good effort with cleaning up allocated memory, but we can do better (see below). The ...
4
votes
Optimizing the code for 8-puzzle in Python
Here are a couple of points:
You need to move your documentation and your comments into docstrings:
...
4
votes
Accepted
N-puzzle solver using A* search
Advice 1: l_moves
The name l_moves is ain't good at all. Consider numberOfMoves.
Since it ...
4
votes
Accepted
State space search for sliding tile puzzle
The initial approach definitely has a number of "bottlenecks" and space for optimizations.
Let me present and explain the crucial points:
starting with good naming: don't give Python identifiers/...
4
votes
Accepted
Solving 15Puzzle with Julia
That was a fun exercise to work on! I completely refactored the code; the basic complexity issue Marc mentions still holds.
I recommend this blog post for the cartesian indexing tricks.
...
4
votes
Simple N Puzzle console game
I have a few scattered observations.
Your Tile.Value is a field rather than a property. If using a public access modifier, you ...
3
votes
8puzzle solver using A*
Your A* is incorrectly implemented
You are using the total number of moves explored as the priority for each search node. See here:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
sliding-tile-puzzle × 56python × 17
a-star × 15
c++ × 13
algorithm × 12
java × 11
performance × 11
time-limit-exceeded × 8
python-3.x × 6
game × 5
pathfinding × 5
breadth-first-search × 5
javascript × 4
beginner × 4
c × 4
c# × 3
ai × 3
object-oriented × 2
array × 2
c++11 × 2
console × 2
numpy × 2
homework × 2
canvas × 2
depth-first-search × 2