Improvements
try to make it run on Android (still unsuccessful)
This commit is contained in:
@@ -1,59 +1,57 @@
|
|||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.android.library)
|
|
||||||
alias(libs.plugins.kotlin.multiplatform)
|
alias(libs.plugins.kotlin.multiplatform)
|
||||||
alias(libs.plugins.compose.compiler)
|
alias(libs.plugins.android.library)
|
||||||
alias(libs.plugins.compose)
|
alias(libs.plugins.compose)
|
||||||
|
alias(libs.plugins.compose.compiler)
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
jvm {
|
jvmToolchain(libs.versions.jdk.get().toInt())
|
||||||
tasks.withType<KotlinJvmCompile>().configureEach {
|
|
||||||
compilerOptions {
|
|
||||||
jvmTarget.set(JvmTarget.JVM_17)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
androidTarget {
|
jvm("desktop")
|
||||||
tasks.withType<KotlinJvmCompile>().configureEach {
|
androidTarget()
|
||||||
compilerOptions {
|
|
||||||
jvmTarget.set(JvmTarget.JVM_11)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
android.apply {
|
// @OptIn(ExperimentalWasmDsl::class)
|
||||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
// wasmJs {
|
||||||
namespace = "ch.dissem.yaep.common.ui"
|
// moduleName = "yaep-commonUI"
|
||||||
compileOptions {
|
// browser()
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
// binaries.executable()
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
commonMain {
|
val androidMain by getting
|
||||||
dependencies {
|
val commonTest by getting
|
||||||
api(projects.domain)
|
|
||||||
|
|
||||||
implementation(compose.components.resources)
|
commonMain.dependencies {
|
||||||
implementation(compose.runtime)
|
api(projects.domain)
|
||||||
implementation(compose.foundation)
|
|
||||||
implementation(compose.material3)
|
implementation(compose.components.resources)
|
||||||
implementation(compose.ui)
|
implementation(compose.runtime)
|
||||||
implementation(compose.components.uiToolingPreview)
|
implementation(compose.foundation)
|
||||||
|
implementation(compose.material3)
|
||||||
|
implementation(compose.ui)
|
||||||
|
implementation(compose.components.uiToolingPreview)
|
||||||
// implementation(libs.compose.ui.text.googlefonts)
|
// implementation(libs.compose.ui.text.googlefonts)
|
||||||
}
|
|
||||||
|
implementation(libs.logging)
|
||||||
}
|
}
|
||||||
val commonTest by getting {
|
androidMain.dependencies {
|
||||||
dependencies {
|
implementation(libs.androidx.compose.foundation)
|
||||||
implementation(libs.kotlin.test)
|
|
||||||
implementation(libs.atrium)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commonTest.dependencies {
|
||||||
|
implementation(libs.kotlin.test)
|
||||||
|
implementation(libs.atrium)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||||
|
namespace = "ch.dissem.yaep.common.ui"
|
||||||
|
|
||||||
|
buildFeatures {
|
||||||
|
compose = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,39 +1,29 @@
|
|||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.kotlin.multiplatform)
|
alias(libs.plugins.kotlin.multiplatform)
|
||||||
alias(libs.plugins.android.library)
|
alias(libs.plugins.android.library)
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
jvm{
|
jvmToolchain(libs.versions.jdk.get().toInt())
|
||||||
tasks.withType<KotlinJvmCompile>().configureEach {
|
|
||||||
compilerOptions {
|
|
||||||
jvmTarget.set(JvmTarget.JVM_17)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
androidTarget{
|
jvm()
|
||||||
tasks.withType<KotlinJvmCompile>().configureEach {
|
androidTarget()
|
||||||
compilerOptions {
|
|
||||||
jvmTarget.set(JvmTarget.JVM_11)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
android.apply {
|
// @OptIn(ExperimentalWasmDsl::class)
|
||||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
// wasmJs {
|
||||||
namespace = "ch.dissem.yaep.domain"
|
// moduleName = "yaep-commonUI"
|
||||||
compileOptions {
|
// browser()
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
// binaries.executable()
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
val commonTest by getting {
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.logging)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
commonTest {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.kotlin.test)
|
implementation(libs.kotlin.test)
|
||||||
implementation(libs.atrium)
|
implementation(libs.atrium)
|
||||||
@@ -41,3 +31,8 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||||
|
namespace = "ch.dissem.yaep.domain"
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import ch.tutteli.atrium.api.fluent.en_GB.toBeGreaterThan
|
|||||||
import ch.tutteli.atrium.api.fluent.en_GB.toBeLessThan
|
import ch.tutteli.atrium.api.fluent.en_GB.toBeLessThan
|
||||||
import ch.tutteli.atrium.api.fluent.en_GB.toEqual
|
import ch.tutteli.atrium.api.fluent.en_GB.toEqual
|
||||||
import ch.tutteli.atrium.api.verbs.expect
|
import ch.tutteli.atrium.api.verbs.expect
|
||||||
|
import co.touchlab.kermit.Logger
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
import kotlin.time.measureTime
|
import kotlin.time.measureTime
|
||||||
@@ -17,7 +18,7 @@ class GameTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `ensure generated games are solvable`() {
|
fun `ensure generated games are solvable`() {
|
||||||
val tries = 2000
|
val tries = 1000
|
||||||
var fastest = 500.milliseconds
|
var fastest = 500.milliseconds
|
||||||
var slowest = 0.milliseconds
|
var slowest = 0.milliseconds
|
||||||
var total = 0.milliseconds
|
var total = 0.milliseconds
|
||||||
@@ -29,10 +30,10 @@ class GameTest {
|
|||||||
val time = measureTime {
|
val time = measureTime {
|
||||||
game = generateGame()
|
game = generateGame()
|
||||||
}
|
}
|
||||||
println("Generated game #$i in ${time.inWholeMilliseconds}ms")
|
Logger.i { "Generated game #$i in ${time.inWholeMilliseconds}ms" }
|
||||||
val solvable = solve(game.grid, game.clues)
|
val solvable = solve(game.grid, game.clues)
|
||||||
if (solvable != SOLVABLE) {
|
if (solvable != SOLVABLE) {
|
||||||
println("Puzzle:\n$game")
|
Logger.i { "Puzzle:\n$game" }
|
||||||
}
|
}
|
||||||
expect(solvable).toEqual(SOLVABLE)
|
expect(solvable).toEqual(SOLVABLE)
|
||||||
expect(time).toBeLessThan(500.milliseconds)
|
expect(time).toBeLessThan(500.milliseconds)
|
||||||
@@ -43,22 +44,22 @@ class GameTest {
|
|||||||
slowest = time
|
slowest = time
|
||||||
}
|
}
|
||||||
total += time
|
total += time
|
||||||
if (game.clues.size > most){
|
if (game.clues.size > most) {
|
||||||
most = game.clues.size
|
most = game.clues.size
|
||||||
}
|
}
|
||||||
if (game.clues.size < least){
|
if (game.clues.size < least) {
|
||||||
least = game.clues.size
|
least = game.clues.size
|
||||||
}
|
}
|
||||||
totalClues += game.clues.size
|
totalClues += game.clues.size
|
||||||
}
|
}
|
||||||
|
|
||||||
println("Slowest: $slowest")
|
Logger.i { "Slowest: $slowest" }
|
||||||
println("Fastest: $fastest")
|
Logger.i { "Fastest: $fastest" }
|
||||||
println("Average: ${total / tries}")
|
Logger.i { "Average: ${total / tries}" }
|
||||||
println("Clues:")
|
Logger.i { "Clues:" }
|
||||||
println("Most: $most")
|
Logger.i { "Most: $most" }
|
||||||
println("Least: $least")
|
Logger.i { "Least: $least" }
|
||||||
println("Average: ${totalClues / tries}")
|
Logger.i { "Average: ${totalClues / tries}" }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -75,8 +76,8 @@ class GameTest {
|
|||||||
feature(Collection<Clue>::size).toBeLessThan(30)
|
feature(Collection<Clue>::size).toBeLessThan(30)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println("Clues: ${game.clues.size}")
|
Logger.i{"Clues: ${game.clues.size}"}
|
||||||
println("Time: $time")
|
Logger.i{"Time: $time"}
|
||||||
expect(solve(game.grid, game.clues)).toEqual(SOLVABLE)
|
expect(solve(game.grid, game.clues)).toEqual(SOLVABLE)
|
||||||
expect(time).toBeLessThan(500.milliseconds)
|
expect(time).toBeLessThan(500.milliseconds)
|
||||||
}
|
}
|
||||||
@@ -130,7 +131,8 @@ class GameTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `ensure specific game is solvable`() {
|
fun `ensure specific game is solvable`() {
|
||||||
val game = Game.parse("""
|
val game = Game.parse(
|
||||||
|
"""
|
||||||
👩🏿⚕️👨🏽🎤👩🏿⚕️ 👩🏾🚀🧑🏿🏫
|
👩🏿⚕️👨🏽🎤👩🏿⚕️ 👩🏾🚀🧑🏿🏫
|
||||||
🐜🐕 🐐 🐐
|
🐜🐕 🐐 🐐
|
||||||
🍉🥭🍐🍇🍍
|
🍉🥭🍐🍇🍍
|
||||||
@@ -162,7 +164,8 @@ class GameTest {
|
|||||||
* ROCK_STAR and UNITED_KINGDOM are in the same column
|
* ROCK_STAR and UNITED_KINGDOM are in the same column
|
||||||
* ROCK_STAR is next to DOUGHNUT
|
* ROCK_STAR is next to DOUGHNUT
|
||||||
* PINEAPPLE is between the neighbours TEACHER and GRAPES to both sides
|
* PINEAPPLE is between the neighbours TEACHER and GRAPES to both sides
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
expect(solve(game.grid, game.clues)).toEqual(SOLVABLE)
|
expect(solve(game.grid, game.clues)).toEqual(SOLVABLE)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,25 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "8.5.2"
|
agp = "8.3.2"
|
||||||
|
jdk = "11"
|
||||||
android-compileSdk = "34"
|
android-compileSdk = "34"
|
||||||
android-minSdk = "24"
|
android-minSdk = "24"
|
||||||
android-targetSdk = "34"
|
android-targetSdk = "34"
|
||||||
androidx-activityCompose = "1.9.1"
|
androidx-activityCompose = "1.9.1"
|
||||||
androidx-compose = "1.6.8"
|
androidx-compose = "1.6.7"
|
||||||
compose-plugin = "1.6.11"
|
compose-plugin = "1.6.11"
|
||||||
kotlin = "2.0.0"
|
kotlin = "2.0.0"
|
||||||
kotlinVersion = "2.0.0"
|
|
||||||
coreKtx = "1.13.1"
|
coreKtx = "1.13.1"
|
||||||
|
atrium = "1.2.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
|
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
|
||||||
androidx-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "androidx-compose" }
|
androidx-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "androidx-compose" }
|
||||||
|
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "androidx-compose" }
|
||||||
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
|
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
|
||||||
atrium = { module = "ch.tutteli.atrium:atrium-fluent", version = "1.2.0" }
|
atrium = { module = "ch.tutteli.atrium:atrium-fluent", version.ref = "atrium" }
|
||||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
atrium-js = { module = "ch.tutteli.atrium:atrium-fluent-js", version.ref = "atrium" }
|
||||||
|
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
|
||||||
|
logging = { module = "co.touchlab:kermit", version = "2.0.4" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
|
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
|
||||||
@@ -25,4 +29,4 @@ kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref
|
|||||||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||||
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||||
compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
|
compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
|
||||||
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" }
|
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
|||||||
Reference in New Issue
Block a user