Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ name: "Java CI with Gradle"
permissions:
contents: "read"
jobs:
validation:
name: "Validation"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "gradle/actions/wrapper-validation@v4"
build:
runs-on: "ubuntu-latest"
steps:
Expand All @@ -19,8 +25,6 @@ jobs:
with:
java-version: "11"
distribution: "temurin"
- name: "Validate Gradle wrapper"
uses: "gradle/wrapper-validation-action@v1"
- name: "Build with Gradle"
uses: "gradle/gradle-build-action@v2"
with:
Expand Down
75 changes: 62 additions & 13 deletions Notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
"metadata": {},
"outputs": [],
"source": [
"%use kandy, dataframe\n",
"%useLatestDescriptors\n",
"%use dataframe(v=1.0.0-Beta2)\n",
"%use kandy\n",
"import com.github.nwillc.ksvg.RenderMode\n",
"import java.io.FileWriter\n",
"\n",
Expand All @@ -85,8 +87,6 @@
"metadata": {},
"outputs": [],
"source": [
"%use kandy, dataframe\n",
"\n",
"objectiveLagLogger.buildDataFrame().plot {\n",
" points {\n",
" x(\"Timstamp (seconds)\")\n",
Expand All @@ -109,21 +109,70 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2025-08-14T13:59:42.613501Z",
"start_time": "2025-08-14T13:59:42.485496Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"import org.emulinker.proto.Event.EventTypeCase.*\n",
"import java.io.FileInputStream\n",
"import org.emulinker.proto.GameLog\n",
"\n",
"FileInputStream(\"gamelog_3pall1f.bin\").use { fileInputStream ->\n",
" val log = GameLog.parseFrom(fileInputStream.readBytes())\n",
" println(\"Number of events: ${log.eventsList.size}\")\n",
" log.eventsList.take(20).map { it.eventTypeCase }\n",
"val log: GameLog = FileInputStream(\"gamelog_2p_1f.bin\").use { GameLog.parseFrom(it.readBytes()) }\n",
"val events = log.eventsList\n",
"\n",
"println(\"Game configuration:\")\n",
"events.first { it.eventTypeCase == GAME_START }"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plot `/lagstat` summaries over the session"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import org.emulinker.proto.Event\n",
"import org.jetbrains.kotlinx.dataframe.api.dataFrameOf\n",
"import org.jetbrains.kotlinx.dataframe.api.toDataFrame\n",
"\n",
"val summaries = events.filter { it.eventTypeCase == LAGSTAT_SUMMARY && it.lagstatSummary.gameLagMs < 2000 }\n",
"\n",
"val time = column<Long>(\"Timestamp (ns)\")\n",
"val observedLag = column<Double>(\"Observed lag (ms)\")\n",
"val player1Lag = column<Double>(\"Player 1 attributed lag (ms)\")\n",
"val player2Lag = column<Double>(\"Player 2 attributed lag (ms)\")\n",
"\n",
"val df = dataFrameOf(\n",
" time.name() to summaries.map { it.timestampNs },\n",
" observedLag.name() to summaries.map { it.lagstatSummary.gameLagMs },\n",
" player1Lag.name() to summaries.map { it.lagstatSummary.getPlayerAttributedLags(0).attributedLagMs },\n",
" player2Lag.name() to summaries.map { it.lagstatSummary.getPlayerAttributedLags(1).attributedLagMs }\n",
")\n",
"\n",
"df.plot {\n",
" x(time)\n",
" points {\n",
" y(observedLag) {\n",
" axis.name = \"Lag (ms)\"\n",
" }\n",
" }\n",
" points {\n",
" y(player1Lag)\n",
" color = Color.BLUE\n",
" }\n",
" points {\n",
" y(player2Lag)\n",
" color = Color.RED\n",
" }\n",
" layout {\n",
" title = \"Server-measured lag\"\n",
" subtitle = \"Grey is server, blue is p1, red is p2\"\n",
" }\n",
"}"
]
}
Expand Down
54 changes: 54 additions & 0 deletions PythonNotebook.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "5d816fab",
"metadata": {},
"source": [
"## Read in proto in Python\n",
"\n",
"NOTE: First make sure you run `./gradlew build` which will generate the Python file.\n",
"\n",
"NOTE: This fails at the import line.. Getting this working is left as an exercise to the reader."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ebc30054e5d69323",
"metadata": {},
"outputs": [],
"source": [
"import build.generated.sources.proto.main.python.lag_pb2\n",
"\n",
"log = lag_pb2.GameLog()\n",
"\n",
"with open(\"gamelog_1p_1f.bin\", \"rb\") as f:\n",
" log.ParseFromString(f.read())\n",
"\n",
"log"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
8 changes: 8 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
version: "v2"
lint:
use:
- "STANDARD"
except:
- "PACKAGE_VERSION_SUFFIX"
- "PACKAGE_DIRECTORY_MATCH"
30 changes: 9 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import com.google.protobuf.gradle.id
plugins {
id("com.google.protobuf") version "0.9.5"
id("build.buf") version "0.10.2"
id("com.diffplug.spotless") version "6.25.0"
id("com.diffplug.spotless") version "7.2.1"
application

kotlin("jvm") version "2.0.20"
kotlin("jvm") version "2.2.10"
}

repositories {
Expand All @@ -18,10 +18,10 @@ repositories {
}

dependencies {
api("org.jetbrains.kotlin:kotlin-stdlib:2.0.20")
api("org.jetbrains.kotlin:kotlin-stdlib:2.2.10")

implementation("org.jetbrains.kotlinx:kandy-lets-plot:0.7.0")
implementation("org.jetbrains.kotlinx:kotlin-statistics-jvm:0.3.0")
implementation("org.jetbrains.kotlinx:kandy-lets-plot:0.8.0")
implementation("org.jetbrains.kotlinx:dataframe:1.0.0-Beta2")

implementation("com.github.nwillc.ksvg:ksvg:master-SNAPSHOT")

Expand Down Expand Up @@ -62,30 +62,17 @@ tasks.withType<Test> {

systemProperty(
"flogger.backend_factory",
"org.emulinker.testing.TestLoggingBackendFactory#getInstance"
"org.emulinker.testing.TestLoggingBackendFactory#getInstance",
)
}

// Disable formatting via buf plugin directly. We just need it for the binary.
buf { enforceFormat = false }

tasks.named("bufLint") { enabled = false }
buf { enforceFormat = true }

// Formatting/linting.
spotless {
// Breaks github CI even though it works locally..
// protobuf {
// buf("1.46.0")
// .pathToExe(
//
// configurations.getByName(BUF_BINARY_CONFIGURATION_NAME).getSingleFile().getAbsolutePath()
// )
// target("src/**/*.proto")
// }

kotlin {
target("**/*.kt", "**/*.kts")
targetExclude("build/", ".git/", ".idea/", ".mvn", "src/main/java-templates/")
targetExclude("bin/", "build/", ".git/", ".idea/", ".mvn", "src/main/java-templates/")
ktfmt().googleStyle()
}

Expand All @@ -104,6 +91,7 @@ protobuf {
it.plugins {
// Generates Kotlin DSL builders.
id("kotlin") {}
id("python") {}
}
}
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Sun Sep 01 20:42:20 JST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
49 changes: 33 additions & 16 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading