From 6a7d030a56c0ea9b0ff394e3f52a0b8ea9f1d852 Mon Sep 17 00:00:00 2001 From: Stone Tao Date: Sat, 21 Aug 2021 15:26:40 -0400 Subject: [PATCH 1/6] version bump --- package.json | 2 +- src/components/configs.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2624f38..d87a0ad 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lux-viewer-2021", - "version": "2.2.0", + "version": "3.0.0", "description": "", "author": "Lux AI challenge", "main": "index.js", diff --git a/src/components/configs.json b/src/components/configs.json index bf38d5b..f27700c 100644 --- a/src/components/configs.json +++ b/src/components/configs.json @@ -1,3 +1,3 @@ { - "version": "2.2.0" + "version": "3.0.0" } From 2b63f9d47bb000c6a2509aa1a02991df3cc56cd5 Mon Sep 17 00:00:00 2001 From: Stone Tao Date: Sat, 21 Aug 2021 16:11:27 -0400 Subject: [PATCH 2/6] parse kaggle replays with size specified --- src/utils/replays.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/replays.ts b/src/utils/replays.ts index 6d2ea9e..faba0d5 100644 --- a/src/utils/replays.ts +++ b/src/utils/replays.ts @@ -19,6 +19,8 @@ export const parseReplayData = (rawReplayData: any) => { const replay = { allCommands: commands.slice(1), // slice 1 to remove empty first entry that represents the "observation" mapType: rawReplayData.configuration.mapType, + width: rawReplayData.configuration.width, + height: rawReplayData.configuration.height, seed: parseInt(rawReplayData.configuration.seed), teamDetails: [ { From 3e0de5f3d8a25189452f1d54321b45b87d7d6a4b Mon Sep 17 00:00:00 2001 From: Stone Tao Date: Sat, 21 Aug 2021 17:18:24 -0400 Subject: [PATCH 3/6] fix replays --- src/utils/replays.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utils/replays.ts b/src/utils/replays.ts index faba0d5..3f353fe 100644 --- a/src/utils/replays.ts +++ b/src/utils/replays.ts @@ -16,19 +16,21 @@ export const parseReplayData = (rawReplayData: any) => { ); commands.push(turnCommands); }); + let width = rawReplayData.configuration.width; + let height = rawReplayData.configuration.height; const replay = { allCommands: commands.slice(1), // slice 1 to remove empty first entry that represents the "observation" mapType: rawReplayData.configuration.mapType, - width: rawReplayData.configuration.width, - height: rawReplayData.configuration.height, + width: width === -1 ? undefined : width, + height: height === -1 ? undefined : height, seed: parseInt(rawReplayData.configuration.seed), teamDetails: [ { - name: 'team-1', + name: 'team 0', tournamentID: '', }, { - name: 'team-2', + name: 'team 1', tournamentID: '', }, ], From 5fe5b0f8fd0a11ea81cb6180fda197db38990a9f Mon Sep 17 00:00:00 2001 From: Stone Tao Date: Sat, 21 Aug 2021 17:18:32 -0400 Subject: [PATCH 4/6] Update MainScene.ts --- src/scenes/MainScene.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/scenes/MainScene.ts b/src/scenes/MainScene.ts index aae9281..f133d60 100755 --- a/src/scenes/MainScene.ts +++ b/src/scenes/MainScene.ts @@ -774,7 +774,6 @@ class MainScene extends Phaser.Scene { if (!f) { return; } - console.log(`Errors on turn ${turn}`, f.errors); const dayLength = this.luxgame.configs.parameters.DAY_LENGTH; const cycleLength = @@ -1379,6 +1378,8 @@ class MainScene extends Phaser.Scene { lastPointerPosition = null; update(time: number, delta: number) { + // console.log('drawing stuff'); + // console.log(1 / (delta * 1e-3)); const panvelocity = 32 * Math.sqrt(this.overallScale); const wkey = this.input.keyboard.addKey('W'); if (wkey.isDown) { From 98c7971e30f11c58c3fac1ca518d8a590f57b2b2 Mon Sep 17 00:00:00 2001 From: Stone Tao Date: Sun, 22 Aug 2021 13:49:50 -0400 Subject: [PATCH 5/6] show warning if version mismatch --- src/components/Game.tsx | 59 +++++++++++++++++++++++---------------- src/components/styles.css | 10 +++++-- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/components/Game.tsx b/src/components/Game.tsx index a0fa885..91f80cf 100644 --- a/src/components/Game.tsx +++ b/src/components/Game.tsx @@ -1,5 +1,5 @@ import 'phaser'; -import React, { KeyboardEvent, useEffect, useState } from 'react'; +import React, { KeyboardEvent, useEffect, useState, version } from 'react'; import MainScene, { Frame, FrameTileData } from '../scenes/MainScene'; import { createGame } from '../game'; import { @@ -25,6 +25,7 @@ import UploadSVG from '../icons/upload.svg'; import { parseReplayData } from '../utils/replays'; import clientConfigs from './configs.json'; import WarningsPanel from './WarningsPanel'; +// import debug_replay from './replay.json'; export type GameComponentProps = { // replayData?: any; }; @@ -47,6 +48,8 @@ export const GameComponent = () => { const [running, setRunning] = useState(false); const [useKaggleReplay, setUseKaggleReplay] = useState(true); const [playbackSpeed, _setPlaybackSpeed] = useState(1); + const [replayVersion, setReplayVersion] = useState(''); + const [warningMessage, setWarningMessage] = useState(''); const setPlaybackSpeed = (speed: number) => { if (speed >= 0.5 && speed <= 32) { _setPlaybackSpeed(speed); @@ -235,7 +238,6 @@ export const GameComponent = () => { } else if (turn % cycleLength < 5 && turn > 5) { idx = 6 - ((turn % cycleLength) + 2); } - console.log({ canvasWrapper }); canvasWrapper.style.transition = `background-color linear ${ 1 / main.speed }s`; @@ -254,28 +256,24 @@ export const GameComponent = () => { }; /** load game given json replay data */ - const loadGame = (jsonReplayData: any, skipVersionCheck = false) => { - if (!skipVersionCheck) { + const loadGame = (jsonReplayData: any) => { + let versionMisMatch = false; + let versionvals = ['x', 'x']; + setReplayVersion(jsonReplayData.version); + if (jsonReplayData.version !== undefined) { + versionvals = jsonReplayData.version.split('.'); if ( - jsonReplayData.version === undefined || - jsonReplayData.version !== clientConfigs.version + versionvals[0] !== clientConfigs.version[0] || + versionvals[1] !== clientConfigs.version[2] ) { - if (jsonReplayData.version === undefined) { - alert('No version associated with replay data, cannot load'); - return; - } - const versionvals = jsonReplayData.version.split('.'); - if ( - versionvals[0] !== clientConfigs.version[0] || - versionvals[1] !== clientConfigs.version[2] - ) { - alert( - `Replay file works on version ${versionvals[0]}.${versionvals[1]}.x but client is on version ${clientConfigs.version}. The visualizer will most likely not work correctly. Download an older visualizer here to watch the replay: https://github.com/Lux-AI-Challenge/LuxViewer2021/releases` - ); - return; - } + versionMisMatch = true; } } + if (versionMisMatch) { + let warningMessage = `Replay file works on version ${versionvals[0]}.${versionvals[1]}.x but client is on version ${clientConfigs.version}. The visualizer will not be able to parse this replay file. Download an older visualizer with version ${versionvals[0]}.${versionvals[1]}.x here to watch the replay: https://github.com/Lux-AI-Challenge/LuxViewer2021/releases`; + setWarningMessage(warningMessage); + return; + } if (game) { game.destroy(true, false); } @@ -346,7 +344,7 @@ export const GameComponent = () => { console.log('post message:'); console.log(event.data); replay = parseReplayData(replay); - loadGame(replay, true); + loadGame(replay); const el = document.getElementsByTagName('html'); if (window.innerWidth * 0.65 <= 768) { el[0].style.fontSize = '6pt'; @@ -372,7 +370,7 @@ export const GameComponent = () => { } else if (window.innerWidth <= 1280) { el[0].style.fontSize = '8pt'; } - // loadGame(debug_replay); + // loadGame(parseReplayData(debug_replay)); }, []); useEffect(() => { const handleKeyDown = (event: globalThis.KeyboardEvent) => { @@ -447,7 +445,7 @@ export const GameComponent = () => {
- {!isReady && ( + {!isReady && warningMessage === '' && (

Welcome to the Lux AI Season 1 Visualizer

@@ -473,8 +471,21 @@ export const GameComponent = () => {
)} + {warningMessage !== '' && ( +
+

{warningMessage}

+
+ )} +
- Version: + {replayVersion && ( + <> + Replay Version: + {replayVersion} +

+ + )} + Client Version: {clientConfigs.version}
{isReady && ( diff --git a/src/components/styles.css b/src/components/styles.css index a7fc1ab..d83cf4b 100644 --- a/src/components/styles.css +++ b/src/components/styles.css @@ -43,6 +43,10 @@ .Game .upload-icon-no-replay { width: 3rem; } +.Game .upload-no-replay-wrapper > p { + padding-left: 2rem; + padding-right: 2rem; +} .Game .upload-no-replay-wrapper > div > .upload-btn .upload-text { margin-right: 1rem; } @@ -112,8 +116,8 @@ background-color: rgba(50, 61, 52, 0.1); padding: 0.5rem; border-radius: 1rem; - height: 1.5rem; - line-height: 1.5rem; + /* height: 1.5rem; */ + /* line-height: 1.5rem; */ } .Game .debug-sidetext { @@ -139,7 +143,7 @@ .Game .warnings-button { position: absolute; top: 1rem; - right: 10rem; + right: 12rem; background-color: rgba(255, 255, 255, 0.25); border-radius: 1rem; color: white; From da1b3e2125abad6213b44dd164dea5bf32bc9e0c Mon Sep 17 00:00:00 2001 From: stone_tao Date: Mon, 23 Aug 2021 17:08:15 -0400 Subject: [PATCH 6/6] d --- package-lock.json | 34 +++++++++++++++++----------------- package.json | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index f4bc804..c94d83f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "lux-viewer-2021", - "version": "2.2.0", + "version": "3.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "lux-viewer-2021", - "version": "2.2.0", + "version": "3.0.0", "license": "MIT", "dependencies": { - "@lux-ai/2021-challenge": "^2.2.0", + "@lux-ai/2021-challenge": "^3.0.0", "@material-ui/core": "^4.11.0", "@material-ui/icons": "^4.11.2", "@types/classnames": "^2.2.10", @@ -346,12 +346,12 @@ } }, "node_modules/@lux-ai/2021-challenge": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@lux-ai/2021-challenge/-/2021-challenge-2.2.0.tgz", - "integrity": "sha512-V69gGmflNpwVYnEHeADGbQUkljGCsZU9CumEC+ZF5Rz03St+XELE1S1yti84DFfmHiTSjzLWzJDCw6H1GEQ31w==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@lux-ai/2021-challenge/-/2021-challenge-3.0.0.tgz", + "integrity": "sha512-9PTl1ng3boRZAF8IAFVomVgUVTrWCe245/sBvf9B9e1NQ6NClpxCQH4WnBhvfXtXVkBGfbPPkJNApb9GK1VWOQ==", "dependencies": { "colors": "^1.4.0", - "dimensions-ai": "^5.1.2", + "dimensions-ai": "^5.1.3", "jszip": "^3.5.0", "nanoid": "^3.1.12", "seedrandom": "^3.0.5", @@ -3046,9 +3046,9 @@ "dev": true }, "node_modules/dimensions-ai": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/dimensions-ai/-/dimensions-ai-5.1.2.tgz", - "integrity": "sha512-e8717PMUxxXcXuNKToGa+vkN8qzbOiuODN+6AOWLgV2RW5o6Q9N/TNN2HYOXTTI9oB1pLwiamry9Rrwz5+rQ9A==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/dimensions-ai/-/dimensions-ai-5.1.3.tgz", + "integrity": "sha512-/ebR+XYNQ39wVPG5Z9eNzqWuEszIJK2/Fv6KAMxAlkLSiVHwujEi+eLppVTFR1AGqsW4MuV0eo5fa/YOHS7utQ==", "dependencies": { "bcryptjs": "^2.4.3", "body-parser": "^1.19.0", @@ -12925,12 +12925,12 @@ } }, "@lux-ai/2021-challenge": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@lux-ai/2021-challenge/-/2021-challenge-2.2.0.tgz", - "integrity": "sha512-V69gGmflNpwVYnEHeADGbQUkljGCsZU9CumEC+ZF5Rz03St+XELE1S1yti84DFfmHiTSjzLWzJDCw6H1GEQ31w==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@lux-ai/2021-challenge/-/2021-challenge-3.0.0.tgz", + "integrity": "sha512-9PTl1ng3boRZAF8IAFVomVgUVTrWCe245/sBvf9B9e1NQ6NClpxCQH4WnBhvfXtXVkBGfbPPkJNApb9GK1VWOQ==", "requires": { "colors": "^1.4.0", - "dimensions-ai": "^5.1.2", + "dimensions-ai": "^5.1.3", "jszip": "^3.5.0", "nanoid": "^3.1.12", "seedrandom": "^3.0.5", @@ -15212,9 +15212,9 @@ } }, "dimensions-ai": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/dimensions-ai/-/dimensions-ai-5.1.2.tgz", - "integrity": "sha512-e8717PMUxxXcXuNKToGa+vkN8qzbOiuODN+6AOWLgV2RW5o6Q9N/TNN2HYOXTTI9oB1pLwiamry9Rrwz5+rQ9A==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/dimensions-ai/-/dimensions-ai-5.1.3.tgz", + "integrity": "sha512-/ebR+XYNQ39wVPG5Z9eNzqWuEszIJK2/Fv6KAMxAlkLSiVHwujEi+eLppVTFR1AGqsW4MuV0eo5fa/YOHS7utQ==", "requires": { "bcryptjs": "^2.4.3", "body-parser": "^1.19.0", diff --git a/package.json b/package.json index d87a0ad..e5f2128 100755 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "webpack-dev-server": "^3.11.0" }, "dependencies": { - "@lux-ai/2021-challenge": "^2.2.0", + "@lux-ai/2021-challenge": "^3.0.0", "@material-ui/core": "^4.11.0", "@material-ui/icons": "^4.11.2", "@types/classnames": "^2.2.10",