Hey everyone!

Hey everyone!

So I'm having some difficulty with some work and am looking for any help.

I've got to solve a 2x2x2 rubik's cube in Python by using a 2 way BFS algorithm that I need to create. Now, I understand how a BFS works and the idea behind a 2 way, but I'm having a hard time figuring it out.

If anyone can provide some information or psuedocode, it would be greatly appreciated!

Other urls found in this thread:

discuss.leetcode.com/topic/43953/clean-two-way-bfs-in-python
discuss.leetcode.com/topic/29303/two-end-bfs-in-java-31ms
twitter.com/AnonBabble

bump

Aren't there a dozen algorithms for cubes?

this is literally a programming assignment for you to LEARN this shit.
you wont learn anything if you just copy it from someone else.

also it's easy as SHIT to get pseudocode for all kinds of search algorithms, and certainly for breadth first search, which is like one of the most straightforward search algorithms in existance.

Not for two-way

>wanting everything regurgitated for direct copy'n'paste
discuss.leetcode.com/topic/43953/clean-two-way-bfs-in-python
discuss.leetcode.com/topic/29303/two-end-bfs-in-java-31ms

Seems helpful

the cost should be the sum of the number of squares with the same color on each face. then just make your search function pick the leaf node with the highest cost every time it has to pick another node.

t. drunk

lol

>tfw can solve 3x3x3 but need to brute-force 2x2x2.

You can solve a 2x2 using the same algorithms. It's just nothing but corners.

Hey OP, let's not be retarded over here.
Nodes represent cube positions. Start at initial cube config. Edges are changes, i.e. 90 deg turns.
From the current distinct position, add all 12 possible changes to your Q, mark this position as explored, and move on. At every step, check if the cube is complete. Eventually you will arrive at your finished cube. Remember, if you ever encounter a configuration you've already discovered, don't enter it again!

The above algorithm works, but can be made better. Try thinking of a smart way to store your configs, such that not only you can identify if two configs are the exact same, but also is they are simple reflections of one another (i.e. one is the other, but upside down or something)

Only works half the time because of parity.

Other way. The algorithms you use for a 2n+1 cube can be used in a 2n+3 cube. Similarly, algos used in 2n cubes can be used in 2n + 2 cubes. But this only ever goes up, never down.

I'm like 99.9% sure you can't get parity on a 2x2. I've solved mine hundreds of times and it never happened. Parity happens because of the extra edge cubies, not the corners.

Speedcuber here;
You're correct that you can't get parity on a 2x2. However, conceptually speaking it doesn't happen due to the extra edges, but rather because of the additional central pieces.
If you're using a 4x4 with a sticker (or logo) on just one of the centre white pieces, you'll see it will actually change positions after solves. This is where the parity cases actually form.

It's actually quite cool. In a "solved" cube, every face has a continuous colour to it. However, this is not the real definition of a solved cube. Every cubie has a designated position for a cube to be solved. In a cube with multiple central pieces, it's impossible to see whether these cubies are oriented correctly.

I wish cube maths was done on actually solved cubes. I prefer solving cubes with drawings on the faces, so you have to solve the centers too.

I have a few cubes with anime girls drawn on them. Getting the actual rotation of centre pieces correct is insanely hard.

Just use the beginners method. Fuck """""""""speed cubing""""""""". Only one goal of the cube is solving it, doesn't matter how

Are you the speedcuber?
I solve them slowly and it's pretty easy this way. You can solve 5 centers as you're solving the cube, then you just have to memorize one algorithm to turn the last center piece 180ยบ.

I am, but I don't know of an alg to flip the rotation of the centre piece. Any link?

What? I never have to use an algorithm for this. You just do T perms and J perms to solve it, and a few corner swaps at the end. The other 5 centers you can just rotate

Gotchya. I figured it out, ty. Didn't know I could do that.

Yeah. After playing for a few mins, you can cut out the corner swaps and do J>T>U perms for 90* centre piece rotations. Thank you again, this is going to make things easier

you're gonna need 2-way data binding

while True:
solveCube()

But you couldn't use the beginners method because a cube with images is a supercube, which needs different algorithms

Wjoops, I'm a tard and didn't read the post.

Try doing a super cube on a 5x5 tho :P A lot more complex then one algo for the last center

Gotta use the two-way BFS