🦀 🕸️ A grid solver for RGB Express
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.
Just a brute force search with some pruning done with connected components calculated with the Union Find / Disjoint Set datastructure.
Angular 7 front end, grid editor & runs the search.
Language: TypeScript
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
WASM Source. Unit tests run in x86 (or linux on travis)
Language: Rust
To setup, see the The Watch Bat File
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