Skip to content

Commit

Permalink
fix:修复了7个bug,解析mvf,函数名3BV改为bbbv
Browse files Browse the repository at this point in the history
  • Loading branch information
eee555 committed Mar 2, 2023
1 parent 6f7f88c commit 865013d
Show file tree
Hide file tree
Showing 13 changed files with 593 additions and 125 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ node_modules
*.evf
*.onnx
*.ini
*.mvf
6 changes: 3 additions & 3 deletions base/src/algorithms.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::utils::{
cal3BV, cal3BV_exp, cal_table_minenum_enum, cal_table_minenum_recursion, chunk_matrixes,
cal_bbbv, cal_bbbv_exp, cal_table_minenum_enum, cal_table_minenum_recursion, chunk_matrixes,
combine, enuOneStep, enum_comb, find_a_border_cell, laymine, laymine_op, legalize_board,
refresh_board, refresh_matrix, refresh_matrixs, refresh_matrixses, unsolvable_structure,
BigNumber, C_query, C,
Expand Down Expand Up @@ -718,7 +718,7 @@ pub fn laymine_solvable_thread(
}
}
let Board_ = laymine_op(row, column, mine_num, x0, y0);
Num3BV = cal3BV(&Board_);
Num3BV = cal_bbbv(&Board_);
tx_.send((Board_, false)).unwrap();
});
handles.push(handle);
Expand Down Expand Up @@ -1105,7 +1105,7 @@ fn laymine_study_exp(x0: usize, y0: usize, n: usize) -> [usize; 382] {
}
}
}
bv_record[cal3BV_exp(&Board)] += 1;
bv_record[cal_bbbv_exp(&Board)] += 1;
}
bv_record
}
Expand Down
14 changes: 13 additions & 1 deletion base/src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ impl GameBoard {
/// 静态局面的包装类。
/// - 用途:筛选局面时,复杂的条件下,用于避免指标重复计算。
/// - 局限:hizi缺少算法。
/// 用Board类估算一亿局高级里有几个8的python代码如下:
/// ``` python3
/// import ms_toollib as ms
/// cell8_num = 0
/// for i in range(100000000):
/// # 在第一行第一列起手,做标准埋雷
/// board = ms.laymine(row=16, column=30, mine_num=99, x0=0, y0=0)
/// # 包一下,准备计算属性
/// wrap_board = ms.Board(board)
/// cell8_num += wrap_board.cell8
/// print(f'数字8出现次数:{cell8_num}')
/// ```
#[derive(Clone)]
pub struct Board {
pub board: Vec<Vec<i32>>,
Expand Down Expand Up @@ -189,7 +201,7 @@ impl Board {
has_cal_cells: false,
}
}
pub fn get_3BV(&mut self) -> usize {
pub fn get_bbbv(&mut self) -> usize {
if self.has_cal_bbbv {
return self.bbbv;
}
Expand Down
4 changes: 2 additions & 2 deletions base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// cargo yank --vers 0.0.1
mod utils;
pub use utils::{
cal3BV, cal_op, cal_isl, cal_table_minenum_recursion, combine, laymine, laymine_op, refresh_board,
cal_bbbv, cal_op, cal_isl, cal_table_minenum_recursion, combine, laymine, laymine_op, refresh_board,
refresh_matrix, refresh_matrixs, refresh_matrixses, unsolvable_structure, enuOneStep, is_good_chording,
cal_cell_nums
};
Expand All @@ -53,7 +53,7 @@ pub use board::{GameBoard, Board};

mod videos;
pub use videos::{
AvfVideo, RmvVideo, EvfVideo, BaseVideo, MinesweeperBoard, GameBoardState, MouseState
AvfVideo, RmvVideo, EvfVideo, MvfVideo, BaseVideo, MinesweeperBoard, GameBoardState, MouseState
};

#[cfg(any(feature = "py", feature = "rs"))]
Expand Down
36 changes: 18 additions & 18 deletions base/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,45 +566,45 @@ pub fn cal3BVonIsland(Board: &Vec<Vec<i32>>) -> usize {
}

/// 计算局面的3BV
pub fn cal3BV(Board: &Vec<Vec<i32>>) -> usize {
cal3BVonIsland(&Board) + cal_op(Board.clone())
pub fn cal_bbbv(board: &Vec<Vec<i32>>) -> usize {
cal3BVonIsland(&board) + cal_op(board.clone())
}

/// 依据左击位置刷新局面
/// - 注意:兼容18标记符和12标记符
pub fn refresh_board(
Board: &Vec<Vec<i32>>,
BoardofGame: &mut Vec<Vec<i32>>,
mut ClickedPoses: Vec<(usize, usize)>,
board: &Vec<Vec<i32>>,
boardofGame: &mut Vec<Vec<i32>>,
mut clicked_poses: Vec<(usize, usize)>,
) {
// println!("{:?}", ClickedPoses);
let row = Board.len();
let column = Board[0].len();
let row = board.len();
let column = board[0].len();
let mut loss_flag = false;
while let Some(top) = ClickedPoses.pop() {
while let Some(top) = clicked_poses.pop() {
let (i, j) = top;
if Board[i][j] > 0 {
BoardofGame[i][j] = Board[i][j];
} else if Board[i][j] == 0 {
BoardofGame[i][j] = 0;
if board[i][j] > 0 {
boardofGame[i][j] = board[i][j];
} else if board[i][j] == 0 {
boardofGame[i][j] = 0;
for m in max(1, i) - 1..min(row, i + 2) {
for n in max(1, j) - 1..min(column, j + 2) {
if (i != m || j != n) && (BoardofGame[m][n] == 10 || BoardofGame[m][n] == 12) {
ClickedPoses.push((m, n));
if (i != m || j != n) && (boardofGame[m][n] == 10 || boardofGame[m][n] == 12) {
clicked_poses.push((m, n));
}
}
}
} else {
BoardofGame[i][j] = 15; // 标红雷,此处是雷,且踩到了
boardofGame[i][j] = 15; // 标红雷,此处是雷,且踩到了
loss_flag = true;
}
}
// 标叉雷
if loss_flag {
for i in 0..row {
for j in 0..column {
if BoardofGame[i][j] == 11 && Board[i][j] != -1 {
BoardofGame[i][j] = 14; // 叉雷,即标错的雷
if boardofGame[i][j] == 11 && board[i][j] != -1 {
boardofGame[i][j] = 14; // 叉雷,即标错的雷
}
}
}
Expand Down Expand Up @@ -1384,7 +1384,7 @@ pub fn unsolvable_structure(BoardCheck: &Vec<Vec<i32>>) -> bool {
}

// 专用于高级局面的3BV快速计算
pub fn cal3BV_exp(Board: &Vec<Vec<i32>>) -> usize {
pub fn cal_bbbv_exp(Board: &Vec<Vec<i32>>) -> usize {
let mut board = Board.clone();
let mut op_id = 0;
let mut op_list = [false; 200];
Expand Down
7 changes: 4 additions & 3 deletions base/src/videos/avf_video.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::MouseState;
use crate::miscellaneous::s_to_ms;
use crate::utils::{cal_board_numbers};
// use crate::MouseState;
// use crate::miscellaneous::s_to_ms;
// use crate::utils::{cal_board_numbers};
use std::cmp::{max, min};
use crate::videos::base_video::{BaseVideo, ErrReadVideoReason, VideoActionStateRecorder};

Expand Down Expand Up @@ -223,6 +223,7 @@ impl AvfVideo {
_ => self.data.player_designator.push(v as u8),
}
}
self.data.software = "Arbiter".as_bytes().to_vec();
// for i in 0..1000 {
// for j in 0..8 {
// print!("{:?},", self.get_char().unwrap() as u8);
Expand Down
Loading

0 comments on commit 865013d

Please sign in to comment.