com.github.phisgr.dds.genFun.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dds4j Show documentation
Show all versions of dds4j Show documentation
Wrapper around the Double Dummy Solver C++ Library.
The newest version!
@file:JvmName("Dds")
package com.github.phisgr.dds
import dds.Dds
import java.lang.foreign.MemorySegment
import kotlin.Int
import kotlin.jvm.JvmName
public fun solveBoard(
dl: Deal,
target: Int,
solutions: Int,
mode: Int,
futp: FutureTricks,
threadIndex: Int,
) {
withThread(threadIndex) {
Dds.SolveBoard(dl.memory, target, solutions, mode, futp.memory,
threadIndex).checkErrorCode()
}
}
public fun solveBoardPBN(
dlpbn: DealPBN,
target: Int,
solutions: Int,
mode: Int,
futp: FutureTricks,
thrId: Int,
) {
withThread(thrId) {
Dds.SolveBoardPBN(dlpbn.memory, target, solutions, mode, futp.memory,
thrId).checkErrorCode()
}
}
public fun calcDdTable(tableDeal: DdTableDeal, tablep: DdTableResults) {
withAllThreads {
Dds.CalcDDtable(tableDeal.memory, tablep.memory).checkErrorCode()
}
}
public fun calcDdTablePBN(tableDealPBN: DdTableDealPBN, tablep: DdTableResults) {
withAllThreads {
Dds.CalcDDtablePBN(tableDealPBN.memory, tablep.memory).checkErrorCode()
}
}
public fun calcAllTables(
dealsp: DdTableDeals,
mode: Int,
trumpFilter: CIntArray,
resp: DdTablesRes,
presp: AllParResults,
) {
withAllThreads {
Dds.CalcAllTables(dealsp.memory, mode, trumpFilter.memory, resp.memory,
presp.memory).checkErrorCode()
}
}
public fun calcAllTablesPBN(
dealsp: DdTableDealsPBN,
mode: Int,
trumpFilter: CIntArray,
resp: DdTablesRes,
presp: AllParResults,
) {
withAllThreads {
Dds.CalcAllTablesPBN(dealsp.memory, mode, trumpFilter.memory, resp.memory,
presp.memory).checkErrorCode()
}
}
public fun solveAllBoards(bop: BoardsPBN, solvedp: SolvedBoards) {
withAllThreads {
Dds.SolveAllBoards(bop.memory, solvedp.memory).checkErrorCode()
}
}
public fun solveAllBoardsBin(bop: Boards, solvedp: SolvedBoards) {
withAllThreads {
Dds.SolveAllBoardsBin(bop.memory, solvedp.memory).checkErrorCode()
}
}
public fun solveAllChunks(
bop: BoardsPBN,
solvedp: SolvedBoards,
chunkSize: Int,
) {
withAllThreads {
Dds.SolveAllChunks(bop.memory, solvedp.memory, chunkSize).checkErrorCode()
}
}
public fun solveAllChunksBin(
bop: Boards,
solvedp: SolvedBoards,
chunkSize: Int,
) {
withAllThreads {
Dds.SolveAllChunksBin(bop.memory, solvedp.memory, chunkSize).checkErrorCode()
}
}
public fun solveAllChunksPBN(
bop: BoardsPBN,
solvedp: SolvedBoards,
chunkSize: Int,
) {
withAllThreads {
Dds.SolveAllChunksPBN(bop.memory, solvedp.memory, chunkSize).checkErrorCode()
}
}
public fun par(
tablep: DdTableResults,
presp: ParResults,
vulnerable: Vulnerability,
) {
Dds.Par(tablep.memory, presp.memory, vulnerable.encoded).checkErrorCode()
}
public fun calcPar(
tableDeal: DdTableDeal,
vulnerable: Vulnerability,
tablep: DdTableResults,
presp: ParResults,
) {
withAllThreads {
Dds.CalcPar(tableDeal.memory, vulnerable.encoded, tablep.memory,
presp.memory).checkErrorCode()
}
}
public fun calcParPBN(
tableDealPBN: DdTableDealPBN,
tablep: DdTableResults,
vulnerable: Vulnerability,
presp: ParResults,
) {
withAllThreads {
Dds.CalcParPBN(tableDealPBN.memory, tablep.memory, vulnerable.encoded,
presp.memory).checkErrorCode()
}
}
public fun sidesPar(
tablep: DdTableResults,
sidesRes: ParResultsDealer.Array,
vulnerable: Vulnerability,
) {
Dds.SidesPar(tablep.memory, sidesRes.memory, vulnerable.encoded).checkErrorCode()
}
public fun dealerPar(
tablep: DdTableResults,
presp: ParResultsDealer,
dealer: Direction,
vulnerable: Vulnerability,
) {
Dds.DealerPar(tablep.memory, presp.memory, dealer.encoded, vulnerable.encoded).checkErrorCode()
}
public fun dealerParBin(
tablep: DdTableResults,
presp: ParResultsMaster,
dealer: Direction,
vulnerable: Vulnerability,
) {
Dds.DealerParBin(tablep.memory, presp.memory, dealer.encoded,
vulnerable.encoded).checkErrorCode()
}
public fun sidesParBin(
tablep: DdTableResults,
sidesRes: ParResultsMaster.Array,
vulnerable: Vulnerability,
) {
Dds.SidesParBin(tablep.memory, sidesRes.memory, vulnerable.encoded).checkErrorCode()
}
public fun convertToDealerTextFormat(pres: ParResultsMaster, resp: MemorySegment) {
Dds.ConvertToDealerTextFormat(pres.memory, resp).checkErrorCode()
}
public fun convertToSidesTextFormat(pres: ParResultsMaster.Array, resp: ParTextResults) {
Dds.ConvertToSidesTextFormat(pres.memory, resp.memory).checkErrorCode()
}
public fun analysePlayBin(
dl: Deal,
play: PlayTraceBin,
solved: SolvedPlay,
thrId: Int,
) {
withThread(thrId) {
Dds.AnalysePlayBin(dl.memory, play.memory, solved.memory, thrId).checkErrorCode()
}
}
public fun analysePlayPBN(
dlPBN: DealPBN,
playPBN: PlayTracePBN,
solvedp: SolvedPlay,
thrId: Int,
) {
withThread(thrId) {
Dds.AnalysePlayPBN(dlPBN.memory, playPBN.memory, solvedp.memory, thrId).checkErrorCode()
}
}
public fun analyseAllPlaysBin(
bop: Boards,
plp: PlayTracesBin,
solvedp: SolvedPlays,
chunkSize: Int,
) {
withAllThreads {
Dds.AnalyseAllPlaysBin(bop.memory, plp.memory, solvedp.memory, chunkSize).checkErrorCode()
}
}
public fun analyseAllPlaysPBN(
bopPBN: BoardsPBN,
plpPBN: PlayTracesPBN,
solvedp: SolvedPlays,
chunkSize: Int,
) {
withAllThreads {
Dds.AnalyseAllPlaysPBN(bopPBN.memory, plpPBN.memory, solvedp.memory,
chunkSize).checkErrorCode()
}
}