{"id":15295154,"url":"https://github.com/thanadolps/bitboard_xo","last_synced_at":"2025-03-24T18:44:07.166Z","repository":{"id":57511996,"uuid":"224198302","full_name":"thanadolps/bitboard_xo","owner":"thanadolps","description":"XO game implemented in rust with minimum memory usage","archived":false,"fork":false,"pushed_at":"2020-01-30T14:34:31.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T21:43:47.342Z","etag":null,"topics":["bitboard","rust","rust-crate","rust-lang","tic-tac-toe","tictactoe-game"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thanadolps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-26T13:26:14.000Z","updated_at":"2020-01-30T14:34:33.000Z","dependencies_parsed_at":"2022-08-31T06:40:54.880Z","dependency_job_id":null,"html_url":"https://github.com/thanadolps/bitboard_xo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanadolps%2Fbitboard_xo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanadolps%2Fbitboard_xo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanadolps%2Fbitboard_xo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanadolps%2Fbitboard_xo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thanadolps","download_url":"https://codeload.github.com/thanadolps/bitboard_xo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245330907,"owners_count":20597865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitboard","rust","rust-crate","rust-lang","tic-tac-toe","tictactoe-game"],"created_at":"2024-09-30T17:08:49.742Z","updated_at":"2025-03-24T18:44:07.053Z","avatar_url":"https://github.com/thanadolps.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/thanadolps/bitboard_xo.svg?branch=master)](https://travis-ci.org/thanadolps/bitboard_xo)\n[![Crates.io](https://img.shields.io/crates/v/bitboard_xo)](https://crates.io/crates/bitboard_xo)\n\n# bitboard_xo\n\nA XO (aka tic-tac-toe/noughts and crosses) library\nwith focus on minimum memory usage without compromising performance.\n\nMinimum memory usage is achieve using [bitboard],\n a common data structure in chess, adapted to fit XO game.\n\nThe current sizeof XO type is 32 bit, smaller than a pointer in most machine.\n\n## Examples\n```rust\nuse bitboard_xo::*;\n\nuse std::error::Error;\nuse std::io::{stdin, stdout, Write};\n\n/// try read a u8 from console\nfn read_u8() -\u003e Result\u003cu32, Box\u003cdyn Error\u003e\u003e {\n    let mut user_input = String::new();\n    stdin().read_line(\u0026mut user_input)?;\n    Ok(user_input.trim().parse()?)\n}\n\n/// prompt user for input to get xo position\nfn get_xo_pos() -\u003e XOPos {\n    fn try_get_xo_pos() -\u003e Result\u003cXOPos, Box\u003cdyn Error\u003e\u003e {\n        // prompt user and read row from console\n        print!(\"Input row : \");\n        stdout().flush()?;\n        let row = read_u8()?;\n\n        // prompt user and read col from console\n        print!(\"Input col : \");\n        stdout().flush()?;\n        let col = read_u8()?;\n\n        // parse row, col into XOPos\n        Ok(XOPos::row_col(row, col)?)\n    };\n\n    loop {\n        match try_get_xo_pos() {\n            Ok(xo_pos) =\u003e break xo_pos,\n            Err(err) =\u003e println!(\"{}\", err),\n        }\n    }\n}\n\nfn main() -\u003e Result\u003c(), XOError\u003e {\n    // create new XO game\n    let mut game = XO::new();\n\n    loop {\n        println!(\"{}\", game);\n        // get position from user's input\n        let input_xo_pos = get_xo_pos();\n\n        // play at that position and match the returned game state\n        match game.play(input_xo_pos) {\n            // game end\n            Ok(Some(game_result)) =\u003e {\n                println!(\"{}\", game);\n                println!(\"game result =\u003e {:?}\", game_result);\n                break;\n            }\n            // game continue\n            Ok(None) =\u003e println!(\"game continue...\"),\n            // some game error occurred\n            Err(xo_err) =\u003e println!(\"Error: {}\", xo_err),\n        }\n    }\n\n    Ok(())\n}\n```\n[bitboard]: https://en.wikipedia.org/wiki/Bitboard\n\nLicense: MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanadolps%2Fbitboard_xo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthanadolps%2Fbitboard_xo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanadolps%2Fbitboard_xo/lists"}