Skip to content

Commit

Permalink
Fix uff
Browse files Browse the repository at this point in the history
  • Loading branch information
Comeza committed May 26, 2024
1 parent 47b691d commit 969c931
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion backend/src/game/uf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ impl UnionFind {
pub fn new(width: usize, height: usize) -> Self {
let n = width * height;
// Set initial liberties substracting the rim
let liberties = (0..n).map(|x| 4 - (x % (width - 1) == 0) as usize - (x / width % (height - 1) == 0) as usize);
let liberties = (0..n).map(|i| {
let x = i % width;
let y = i / height;
return 4
- (x % (width - 1) == 0 && y % (height - 1) == 0) as usize
- (x % (width - 1) == 0 || y % (height - 1) == 0) as usize;
});
UnionFind {
parent: (0..n).collect(),
size: vec![1; n],
Expand Down
4 changes: 2 additions & 2 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn main() -> std::io::Result<()> {
let ws_listener = TcpListener::bind("0.0.0.0:1213")?;
listener.set_nonblocking(true)?;
ws_listener.set_nonblocking(true)?;
let mut game = GameState::new(5);
let mut game = GameState::new(15);
loop {
if let Err(e) = network::accept_new_connections(&listener, &mut game) {
eprintln!("Error while accepting a new connection: {e}");
Expand All @@ -158,6 +158,6 @@ fn main() -> std::io::Result<()> {
game.update_frontend();
game.broadcast_gamestate();

std::thread::sleep(Duration::from_millis(600));
std::thread::sleep(Duration::from_millis(100));
}
}

0 comments on commit 969c931

Please sign in to comment.