9 votes
Accepted

Solve 8-tile sliding puzzle

Here's the code you want to speed up: ...
Quuxplusone's user avatar
  • 19.3k
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 ...
200_success's user avatar
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. ...
pacmaninbw's user avatar
  • 23.5k
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 ...
G. Sliepen's user avatar
  • 50.3k
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 ...
Jesse C. Slicer's user avatar
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:...
janos's user avatar
  • 111k
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 ...
Emily L.'s user avatar
  • 16.5k
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 ...
Benoît P's user avatar
  • 799
4 votes

Sliding tile puzzle

self documenting code: ...
Martin York's user avatar
  • 94.3k
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. ...
Sjoerd Job Postmus's user avatar
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. ...
Peilonrayz's user avatar
  • 42.7k
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 ...
Edward's user avatar
  • 65.3k
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 ...
warvariuc's user avatar
  • 337
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, ...
chux - Reinstate Monica's user avatar
4 votes

Game of Fifteen - A Sliding Puzzle Game

Bug - Valid Move Your valid_move method has this comment in it. ...
forsvarir's user avatar
  • 11.6k
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 ...
mdfst13's user avatar
  • 21.4k
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 ...
Grajdeanu Alex's user avatar
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 ...
JS1's user avatar
  • 28.5k
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 ...
200_success's user avatar
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: ...
Toby Speight's user avatar
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 ...
user673679's user avatar
  • 11.6k
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 ...
user673679's user avatar
  • 11.6k
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: ...
aghast's user avatar
  • 12.3k
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 ...
coderodde's user avatar
  • 27k
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/...
RomanPerekhrest's user avatar
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. ...
phipsgabler's user avatar
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 ...
Rick Davin's user avatar
  • 6,217
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: ...
Emily L.'s user avatar
  • 16.5k

Only top scored, non community-wiki answers of a minimum length are eligible