GithubHelp home page GithubHelp logo

eric7237cire / rgb_delivery Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5.16 MB

A Solver for RGB Express. Uses Rust, WebAssembly, WebWorkers, TypeScript, and Angular

Rust 79.53% JavaScript 0.99% TypeScript 12.40% HTML 3.80% CSS 2.23% Batchfile 0.59% Dockerfile 0.46%
rust webassembly typescript angular7 typings webpack

rgb_delivery's Introduction

Build Status

Rust πŸ¦€ πŸ•ΈοΈ A grid solver for RGB Express Rust

RGB Express is an excellent strategy Android game. It helps to download & play before looking at the solver.

Basically you have to get each van (V) pick up a block (B) and return it to the target warehouse (T). The van and warehouse must be the same color. Each van can hold 3 blocks, the 'poppers', if active, will pop the top block off the Van. Poppers are activated before starting the level.

Component/tech flow:

WASM => Web Worker <=> Angular 7

Thus Angular has no knowledge of the WebAssembly, using only WebWorker messages, but it does use the typings generated. Thus if a new attribute/etc. is added to the public classes/interfaces (exposed by Serde), the typescript transpilation will show errors.

The Algorithm

Just a brute force search with some pruning done with connected components calculated with the Union Find / Disjoint Set datastructure.

Components

grid-editor

Angular 7 front end, grid editor & runs the search.

Screenshot

Language: TypeScript

web_worker

Code based on a public repo.

Packages the WASM using a stand alone webpack as a Web worker. Too much of a PITA to get angular cli to play nicely.

Build as a local only npm module, exposing a browser asset and the typings.

Language: TypeScript

To setup, see the Travis Configuration

rgb-solver

WASM Source. Unit tests run in x86 (or linux on travis)

Language: Rust

To setup, see the The Watch Bat File

wasm-typescript-definition

Code based on a public repo of same name.

Modified to produce better *.d.ts types for typescript. Most useful is generating union types which match nicely with Rusts variant enums.

TypeScript has nice support for discriminated unions which let you do a checked switch on the attribute type.

Built automatically when rgb-solver is built.

Example:

Typing generated:

export type Road = {
    ...
};

export type Bridge = {
    ...
};

//derive struct
export type Warehouse = {
    ...
};

export type TileEnum = TileRoad | TileWarehouse | TileBridge | Empty

export type TileEnum = TileRoad | TileWarehouse | TileBridge | Empty
export type TileRoad = {type: "TileRoad"} & Road
export type TileWarehouse = {type: "TileWarehouse"} & Warehouse
export type TileBridge = {type: "TileBridge"} & Bridge
export type Empty = {type: "Empty" }
export type TileEnum_type = "TileRoad" | "TileWarehouse" | "TileBridge" | "Empty"

Rust:

#[derive(Clone, Serialize, Deserialize, Debug, TypescriptDefinition, Hash, Eq, PartialEq)]
#[serde(tag = "type")]
pub enum TileEnum {
    TileRoad(Road),
    TileWarehouse (Warehouse),
    TileBridge(Bridge),
    Empty
}

Deploying to git hub pages

Done by travis, see the Travis Configuration

rgb_delivery's People

Contributors

eric7237cire avatar

Watchers

 avatar

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.