sagebati / goban Goto Github PK
View Code? Open in Web Editor NEWLibrary for go move generation and go ruling.
License: MIT License
Library for go move generation and go ruling.
License: MIT License
Hi there,
thank you for your great library. I was just using it in my rust yew project.
I just stumbled upon a situation. Just in some shapes, I get this situation, where after taking 2 stones, the API thinks that it is a ko, even though it's not.
In the screenshot, the transparent stone is the about to be placed stone, that is returning an error.
Would be great if you could have a look at it.
Thank you for your great library!
ps: I have this frontend in: https://github.com/janos-r/yewban
Without the history feature, the legals()
method clone the Goban
to test if a move is actually legal.
The clone()
is a shallow clone and it doesn't deep copy the structure which is nice for performance, so the goban
cloned and the original share their state (and god fully don't add bugs).
But with the feature history enabled, we have an vector of goban
structs and if we derive Clone all their state will be shared across clones, so I used a feature gate to only deep clone when history is enabled to avoid shared state.
The question is, how in the first place, it does work without deep cloning ? and if it works in all cases would it also work for history without cloning ?
Example of code :
The debug assert fails with shallow clone because it doesn't clear all the pointers. But with deep clone we can assume that we cleared all.
///
/// Deletes all the Rc from the go_strings, then merges the two_string
///
fn merge_two_strings(&mut self, first: GoString, other: GoStringPtr) -> GoString {
for &point in other.stones() {
self.go_strings[self.coord_util.to(point)] = Option::None;
}
#[cfg(feature = "history")]
debug_assert!(
Ptr::strong_count(&*other) == 1,
"strong count: {}",
Ptr::strong_count(&*other)
);
first.merge_with((**other).clone())
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.