Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
566d72c2d6 | ||
| ad26d22281 | |||
| 352b4e57d7 | |||
|
|
cdd8b45da8 | ||
|
|
6006442f90 | ||
|
|
eebdfdbee2 | ||
|
|
a6aba8801e | ||
|
|
8d1300d7e2 | ||
|
|
d0e6ce81ce | ||
|
|
f3dea86ded | ||
|
|
092ed19104 | ||
|
|
f8894bbdff | ||
|
|
258a8a0da9 | ||
|
|
dca6eac3ba | ||
|
|
5ee797e1f8 |
3
.github/workflows/test.sh
vendored
3
.github/workflows/test.sh
vendored
@@ -30,6 +30,9 @@ echo "$PROJECT_NAME" > "$LOG_FILE"
|
||||
awk '/^running [0-9]+ test[s]?$/,/^$/' full_test_output.log >> "$LOG_FILE"
|
||||
|
||||
# --- APPEND TO GLOBAL LOG (in repo root) ---
|
||||
if [[ $(git rev-parse --abbrev-ref HEAD) == "master" ]]; then
|
||||
echo "master" >> $FINAL_LOG
|
||||
fi
|
||||
cat "$LOG_FILE" >> "$FINAL_LOG"
|
||||
|
||||
# --- SUMMARY ---
|
||||
|
||||
64
.github/workflows/upload_data.yml
vendored
64
.github/workflows/upload_data.yml
vendored
@@ -20,33 +20,71 @@ jobs:
|
||||
echo "$GOOGLE_SERVICE_ACCOUNT_JSON" > service_account.json
|
||||
|
||||
python <<'PYCODE'
|
||||
import gspread, json, time, subprocess
|
||||
import gspread, json, subprocess
|
||||
|
||||
# credentials
|
||||
creds = json.load(open("service_account.json"))
|
||||
gc = gspread.service_account_from_dict(creds)
|
||||
sh = gc.open_by_key("${{ secrets.SPREADSHEET_ID }}")
|
||||
v = subprocess.run(['git','rev-parse','--show-toplevel'], capture_output=True).stdout.decode().strip()
|
||||
print(f"{v}/test_data.log")
|
||||
|
||||
|
||||
def writeRowsToSpreadsheet(data_list, worksheet):
|
||||
existing_rows = len(worksheet.get_all_values())
|
||||
start_row = existing_rows + 3
|
||||
rows_to_append = [row.split() for row in data_list]
|
||||
print(f"{rows_to_append}")
|
||||
|
||||
for i, row in enumerate(rows_to_append):
|
||||
worksheet.insert_row(row, start_row + i)
|
||||
|
||||
|
||||
with open(f"{v}/test_data.log", "r") as f:
|
||||
lines = [line.strip() for line in f if line.strip()]
|
||||
|
||||
isMaster = False
|
||||
project = lines[0].lower()
|
||||
worksheet = sh.worksheet(project)
|
||||
if project == "master":
|
||||
isMaster = True
|
||||
|
||||
engine_data = []
|
||||
server_data = []
|
||||
ui_data = []
|
||||
master_data = []
|
||||
|
||||
# project name
|
||||
data = lines[1:]
|
||||
for entry in lines:
|
||||
if not isMaster and entry == "engine":
|
||||
project = "engine"
|
||||
elif not isMaster and entry == "server":
|
||||
project = "server"
|
||||
elif not isMaster and entry == "ui":
|
||||
project = "ui"
|
||||
|
||||
#blank rows
|
||||
existing_rows = len(worksheet.get_all_values())
|
||||
start_row = existing_rows + 3
|
||||
if project == "engine" and entry != "engine":
|
||||
engine_data.append(entry)
|
||||
elif project == "server" and entry != "server":
|
||||
server_data.append(entry)
|
||||
elif project == "ui" and entry != "ui":
|
||||
ui_data.append(entry)
|
||||
elif project == "master" and entry != "master":
|
||||
master_data.append(entry)
|
||||
|
||||
# Split data into columns (by spaces)
|
||||
rows_to_append = [row.split() for row in data]
|
||||
print("PRINTING FILTERED DATA\n\n")
|
||||
print(f"engine\n{engine_data}")
|
||||
print(f"server\n{server_data}")
|
||||
print(f"ui\n{ui_data}")
|
||||
print("\n\n\n")
|
||||
|
||||
for i, row in enumerate(rows_to_append):
|
||||
worksheet.insert_row(row, start_row + i)
|
||||
if isMaster and len(master_data) != 0:
|
||||
worksheet = sh.worksheet("master")
|
||||
writeRowsToSpreadsheet(master_data, worksheet)
|
||||
exit(0)
|
||||
|
||||
if len(engine_data) != 0:
|
||||
writeRowsToSpreadsheet(engine_data, sh.worksheet("engine"))
|
||||
if len(server_data) != 0:
|
||||
writeRowsToSpreadsheet(server_data, sh.worksheet("server"))
|
||||
if len(ui_data) != 0:
|
||||
writeRowsToSpreadsheet(ui_data, sh.worksheet("ui"))
|
||||
|
||||
print(f"Uploaded {len(rows_to_append)} rows to '{project}' tab.")
|
||||
PYCODE
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
mod attackmaps;
|
||||
mod attackmaps;
|
||||
mod utils;
|
||||
99
engine/src/bitboard/utils.rs
Normal file
99
engine/src/bitboard/utils.rs
Normal file
@@ -0,0 +1,99 @@
|
||||
#[inline(always)]
|
||||
pub fn pop_lsb(value: &mut u64) -> usize {
|
||||
let idx = value.trailing_zeros() as usize;
|
||||
*value &= !(1 << idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn pop_msb(value: &mut u64) -> usize {
|
||||
let idx = 63 - value.leading_zeros() as usize;
|
||||
*value &= !(1 << idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
const RANK_NUMBERS: [char; 8] = ['1', '2', '3', '4', '5', '6', '7', '8'];
|
||||
const FILE_LETTERS: [char; 8] = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
|
||||
pub fn notation_from_square_number(sq: u8) -> String {
|
||||
let row = sq / 8;
|
||||
let col = sq % 8;
|
||||
let mut notation = String::new();
|
||||
|
||||
let row_not = RANK_NUMBERS[row as usize];
|
||||
let col_not = FILE_LETTERS[col as usize];
|
||||
|
||||
notation.push(col_not);
|
||||
notation.push(row_not);
|
||||
return notation;
|
||||
}
|
||||
|
||||
|
||||
// <----- TESTS ----->
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn pop_lsb_test() {
|
||||
|
||||
// test setup
|
||||
let test_values: [u64; 6] = [
|
||||
0x8000_0000_0000_0000,
|
||||
0x4E91_CF05_713E_451B,
|
||||
0xD588_2D58_6962_34B0,
|
||||
0x9581_3335_DCAB_1DD4,
|
||||
0xBEAC_DBE0_903A_AC00,
|
||||
0x01E8_C895_A6F0_0000
|
||||
];
|
||||
let expected_values: [usize; 6] = [63, 0, 4, 2, 10, 20];
|
||||
|
||||
// tests
|
||||
for index in 0..6 {
|
||||
let mut test_value = test_values[index];
|
||||
assert_eq!(pop_lsb(&mut test_value), expected_values[index])
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pop_msb_test() {
|
||||
// test setup
|
||||
let test_values: [u64; 6] = [
|
||||
0x86D6_8EB0_96A8_8D1C,
|
||||
0x0000_0000_0000_0001,
|
||||
0x3809_24AF_A7AE_8129,
|
||||
0x0277_DA36_3B31_86D9,
|
||||
0x0000_C1C3_201C_0DB1,
|
||||
0x0000_0203_0DE4_E944
|
||||
];
|
||||
let expected_values: [usize; 6] = [63, 0, 61, 57, 47, 41];
|
||||
|
||||
// tests
|
||||
for index in 0..6 {
|
||||
let mut test_value = test_values[index];
|
||||
assert_eq!(pop_msb(&mut test_value), expected_values[index])
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn notation_from_square_number_test() {
|
||||
// test setup
|
||||
let square_indices: [u8; 8] = [1, 12, 22, 27, 32, 47, 53, 58];
|
||||
let notations: [String; 8] = [
|
||||
String::from("b1"),
|
||||
String::from("e2"),
|
||||
String::from("g3"),
|
||||
String::from("d4"),
|
||||
String::from("a5"),
|
||||
String::from("h6"),
|
||||
String::from("f7"),
|
||||
String::from("c8")
|
||||
];
|
||||
|
||||
// tests
|
||||
for index in 0..8 {
|
||||
let notation = notation_from_square_number(square_indices[index].clone());
|
||||
assert_eq!(notation, notations[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user