GithubHelp home page GithubHelp logo

v-wong / cubesimrs Goto Github PK

View Code? Open in Web Editor NEW
24.0 3.0 1.0 179 KB

Rust based Rubik's Cube simulation and solving library.

Home Page: https://docs.rs/cubesim/0.0.7/cubesim/

License: MIT License

Rust 100.00%
rubiks-cube rubiks-cube-solver rubiks-cube-simulator rust simulation

cubesimrs's Introduction

Hi There, I'm Vincent!

I'm a software engineer at Atlassian in Sydney, Australia. Before that, I studied applied mathematics and computer science at UNSW. While studying, I took up roles as:

  • Software Engineer Intern at IMC Trading (December 2021 - February 2022).
  • Casual Software Developer at Ventia (September 2019 - November 2021).

My detailed work history can be found on my resume.

Outside of work, I have worked on projects in a variety of languages including:

When not coding, I like to speedcube and have held national championship podiums.

Contact Me

Linkedin Badge Gmail Badge

cubesimrs's People

Contributors

stanleydesu avatar thecjharries avatar v-wong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

stanleydesu

cubesimrs's Issues

Convert GeometricMove's predicate to use unboxed closures

If a move's n value was passed when checking if a sticker satisfies the predicate, the predicate field can become
pub predicate: fn(&Sticker, u32) -> bool>, which is potentially cleaner/faster than the current boxed dyn implementation.

Facelet Cube Bottleneck

The current FaceletCube implementation is not as performant as I would like it to be. Since the results are cached, actual computations are rarely required. I suspect the bottleneck to lie in the actual caching mechanism.

Set MoveVariant's 'Standard' value to 1

Standard,

By setting MoveVariant's 'Standard' value to 1, it improves semantics, as

  • Standard is equivalent to 1 clockwise turn,
  • Double becomes 2 turns,
  • Inverse becomes 3 turns, equivalent to 1 anticlockwise turn

This allows reduction/simplification of summed MoveVariants, and can simplify modify_move (geometric_cube/moves.rs) to

fn modify_move(mv: GeometricMove, variant: MoveVariant) -> GeometricMove {
    GeometricMove { angle: mv.angle * variant as f32, ..mv }
}

Cubes created from FaceletCube::from(faces) are invalid

In cube.rs, the new function initializes as:

            .enumerate()
            .map(|(i, s)| (*s, i as u16))

Effectively adding the number of the position of the original vec inside as extra info.

While on the from function:

            faces: faces.iter().map(|f| (*f, 0)).collect(),

Sets all indices to zero.

As a result, calling cubesim::solve(&cube) will always return None for cubes that are created with the from function instead of new.

This makes impossible to use this library for arbitrary cubes where we don't know the rotations made to get into that position.

Cache pruning tables in Thistlethwaite solver

The pruning tables inside each phase of the Thislethwaite solver are constant and do not vary from call to call. At the moment, the tables are regenerated at each function call. This is inefficient and caching the tables would be preferable.

Change Mask To Use Solved Indices

The mask method in the Cube trait is intended to ignore certain stickers which can be useful for defining solvers of certain states (e.g. cross, first block, etc). The method however currently takes in a slice of indices within the current cube state. It would be much more useful if it were to take a slice of indices with respect to the original solved cube state.

Refactor Geometric Moves

The implementation of geometrics moves currently features a lot of duplicate code. This was originally done as a temporary solution to support arbitrary sized cubes. A more elegant solution with less duplicate code would be preferred here.

Fix tense inconsistencies in doc comments

I see some inconsistencies in tense (present and past) in some doc comments (currently detected in generic_cube.rs).
E.g.

/// Maps over the pieces of the cube, replacing each piece
/// according to the given mask function. 
fn mask(&self, mask: &dyn Fn(i32, Face) -> Face) -> Self;

/// Apply a move to a cube.
/// ...
fn apply_move(&self, mv: Move) -> Self;

Scramble parser improvements

parse_scramble should:

  • trim the provided scramble
  • split by whitespace (use split_whitespace instead of split(' ')
  • return an empty Vec for a string with no moves, as it currently panics on this case

Refactor GeoCube with unsigned integers

The implementation of GeoCube currently features many i32s, where u32s would be more appropriate, such as the size field in the GeoCube struct, and other mentions of size as a parameter.
A better semantically-typed solution would be preferred here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.