Spaces:
Runtime error
Runtime error
Commit
·
008456e
1
Parent(s):
f0dc1c3
added doom
Browse files- package-lock.json +0 -15
- package.json +0 -1
- src/app/games/doom.ts +27 -0
- src/app/games/dungeon.ts +1 -1
- src/app/games/index.ts +2 -1
- src/app/games/types.ts +2 -2
- src/app/main.tsx +13 -10
package-lock.json
CHANGED
@@ -44,7 +44,6 @@
|
|
44 |
"next": "13.4.10",
|
45 |
"pick": "^0.0.1",
|
46 |
"postcss": "8.4.26",
|
47 |
-
"qs": "^6.11.2",
|
48 |
"react": "18.2.0",
|
49 |
"react-circular-progressbar": "^2.1.0",
|
50 |
"react-day-picker": "^8.8.0",
|
@@ -4835,20 +4834,6 @@
|
|
4835 |
"node": ">=6"
|
4836 |
}
|
4837 |
},
|
4838 |
-
"node_modules/qs": {
|
4839 |
-
"version": "6.11.2",
|
4840 |
-
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz",
|
4841 |
-
"integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==",
|
4842 |
-
"dependencies": {
|
4843 |
-
"side-channel": "^1.0.4"
|
4844 |
-
},
|
4845 |
-
"engines": {
|
4846 |
-
"node": ">=0.6"
|
4847 |
-
},
|
4848 |
-
"funding": {
|
4849 |
-
"url": "https://github.com/sponsors/ljharb"
|
4850 |
-
}
|
4851 |
-
},
|
4852 |
"node_modules/queue-microtask": {
|
4853 |
"version": "1.2.3",
|
4854 |
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
|
|
|
44 |
"next": "13.4.10",
|
45 |
"pick": "^0.0.1",
|
46 |
"postcss": "8.4.26",
|
|
|
47 |
"react": "18.2.0",
|
48 |
"react-circular-progressbar": "^2.1.0",
|
49 |
"react-day-picker": "^8.8.0",
|
|
|
4834 |
"node": ">=6"
|
4835 |
}
|
4836 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4837 |
"node_modules/queue-microtask": {
|
4838 |
"version": "1.2.3",
|
4839 |
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
|
package.json
CHANGED
@@ -45,7 +45,6 @@
|
|
45 |
"next": "13.4.10",
|
46 |
"pick": "^0.0.1",
|
47 |
"postcss": "8.4.26",
|
48 |
-
"qs": "^6.11.2",
|
49 |
"react": "18.2.0",
|
50 |
"react-circular-progressbar": "^2.1.0",
|
51 |
"react-day-picker": "^8.8.0",
|
|
|
45 |
"next": "13.4.10",
|
46 |
"pick": "^0.0.1",
|
47 |
"postcss": "8.4.26",
|
|
|
48 |
"react": "18.2.0",
|
49 |
"react-circular-progressbar": "^2.1.0",
|
50 |
"react-day-picker": "^8.8.0",
|
src/app/games/doom.ts
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Game } from "./types"
|
2 |
+
|
3 |
+
const initialSituation = [
|
4 |
+
`looking at building on Mars, with multiple moons in the sky`,
|
5 |
+
].join(", ")
|
6 |
+
|
7 |
+
const initialActionnables = [
|
8 |
+
"gun",
|
9 |
+
"person",
|
10 |
+
"door",
|
11 |
+
"laser",
|
12 |
+
"window",
|
13 |
+
"box"
|
14 |
+
]
|
15 |
+
|
16 |
+
export const game: Game = {
|
17 |
+
title: "Doom",
|
18 |
+
type: "doom",
|
19 |
+
initialSituation,
|
20 |
+
initialActionnables,
|
21 |
+
getScenePrompt: (situation?: string) => [
|
22 |
+
`Screenshot from Doom`,
|
23 |
+
situation || initialSituation,
|
24 |
+
`first person, beautiful, unreal engine`
|
25 |
+
]
|
26 |
+
}
|
27 |
+
|
src/app/games/dungeon.ts
CHANGED
@@ -55,5 +55,5 @@ export const game: Game = {
|
|
55 |
situation || initialSituation,
|
56 |
`medieval`,
|
57 |
`unreal engine`,
|
58 |
-
]
|
59 |
}
|
|
|
55 |
situation || initialSituation,
|
56 |
`medieval`,
|
57 |
`unreal engine`,
|
58 |
+
]
|
59 |
}
|
src/app/games/index.ts
CHANGED
@@ -3,8 +3,9 @@ import { GameType } from "./types"
|
|
3 |
import { game as pirates } from "./pirates"
|
4 |
import { game as city } from "./city"
|
5 |
import { game as dungeon } from "./dungeon"
|
|
|
6 |
|
7 |
-
export const games = { pirates, city, dungeon }
|
8 |
|
9 |
export const defaultGame: GameType = "pirates"
|
10 |
|
|
|
3 |
import { game as pirates } from "./pirates"
|
4 |
import { game as city } from "./city"
|
5 |
import { game as dungeon } from "./dungeon"
|
6 |
+
import { game as doom } from "./doom"
|
7 |
|
8 |
+
export const games = { pirates, city, dungeon, doom }
|
9 |
|
10 |
export const defaultGame: GameType = "pirates"
|
11 |
|
src/app/games/types.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
export type GameType = 'pirates' | 'city' | 'dungeon'
|
2 |
|
3 |
export interface Scene {
|
4 |
actionnables: string[]
|
@@ -10,5 +10,5 @@ export interface Game {
|
|
10 |
type: GameType
|
11 |
initialSituation: string
|
12 |
initialActionnables: string[]
|
13 |
-
getScenePrompt: (situation?: string) => string
|
14 |
}
|
|
|
1 |
+
export type GameType = 'pirates' | 'city' | 'dungeon' | 'doom'
|
2 |
|
3 |
export interface Scene {
|
4 |
actionnables: string[]
|
|
|
10 |
type: GameType
|
11 |
initialSituation: string
|
12 |
initialActionnables: string[]
|
13 |
+
getScenePrompt: (situation?: string) => string[]
|
14 |
}
|
src/app/main.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
"use client"
|
2 |
|
3 |
import { useEffect, useRef, useState, useTransition } from "react"
|
4 |
-
import
|
5 |
|
6 |
import { ImageRenderer } from "@/components/business/image-renderer"
|
7 |
|
@@ -30,9 +30,11 @@ export default function Main() {
|
|
30 |
maskBase64: "",
|
31 |
segments:[]
|
32 |
})
|
33 |
-
const
|
34 |
-
|
35 |
-
const
|
|
|
|
|
36 |
const [situation, setSituation] = useState("")
|
37 |
const [scene, setScene] = useState("")
|
38 |
const [dialogue, setDialogue] = useState("")
|
@@ -47,13 +49,14 @@ export default function Main() {
|
|
47 |
|
48 |
// console.log(`getting agent..`)
|
49 |
// note: we use a ref so that it can be changed in the background
|
50 |
-
const type =
|
|
|
51 |
const game = getGame(type)
|
52 |
|
53 |
// console.log(`rendering scene..`)
|
54 |
const newRendered = await render(
|
55 |
// SCENE PROMPT
|
56 |
-
|
57 |
|
58 |
// ACTIONNABLES
|
59 |
(Array.isArray(nextActionnables) && nextActionnables.length
|
@@ -63,7 +66,7 @@ export default function Main() {
|
|
63 |
)
|
64 |
|
65 |
// detect if something changed in the background
|
66 |
-
if (type !==
|
67 |
console.log("agent type changed! reloading scene")
|
68 |
setTimeout(() => { loadNextScene() }, 0)
|
69 |
return
|
@@ -94,7 +97,7 @@ export default function Main() {
|
|
94 |
|
95 |
await startTransition(async () => {
|
96 |
|
97 |
-
const game = getGame(
|
98 |
|
99 |
let newDialogue = ""
|
100 |
try {
|
@@ -131,9 +134,9 @@ export default function Main() {
|
|
131 |
<div className="flex flex-row items-center space-x-3">
|
132 |
<label className="flex">Select a story:</label>
|
133 |
<Select
|
134 |
-
defaultValue={
|
135 |
onValueChange={(value) => {
|
136 |
-
|
137 |
setRendered({
|
138 |
assetUrl: "",
|
139 |
error: "",
|
|
|
1 |
"use client"
|
2 |
|
3 |
import { useEffect, useRef, useState, useTransition } from "react"
|
4 |
+
import { useSearchParams } from 'next/navigation'
|
5 |
|
6 |
import { ImageRenderer } from "@/components/business/image-renderer"
|
7 |
|
|
|
30 |
maskBase64: "",
|
31 |
segments:[]
|
32 |
})
|
33 |
+
const searchParams = useSearchParams()
|
34 |
+
|
35 |
+
const requestedGame = (searchParams.get('game') as GameType) || defaultGame
|
36 |
+
console.log("requestedGame:", requestedGame)
|
37 |
+
const gameRef = useRef<GameType>(requestedGame)
|
38 |
const [situation, setSituation] = useState("")
|
39 |
const [scene, setScene] = useState("")
|
40 |
const [dialogue, setDialogue] = useState("")
|
|
|
49 |
|
50 |
// console.log(`getting agent..`)
|
51 |
// note: we use a ref so that it can be changed in the background
|
52 |
+
const type = gameRef?.current
|
53 |
+
console.log("type:", type)
|
54 |
const game = getGame(type)
|
55 |
|
56 |
// console.log(`rendering scene..`)
|
57 |
const newRendered = await render(
|
58 |
// SCENE PROMPT
|
59 |
+
game.getScenePrompt(nextSituation).join(", "),
|
60 |
|
61 |
// ACTIONNABLES
|
62 |
(Array.isArray(nextActionnables) && nextActionnables.length
|
|
|
66 |
)
|
67 |
|
68 |
// detect if something changed in the background
|
69 |
+
if (type !== gameRef?.current) {
|
70 |
console.log("agent type changed! reloading scene")
|
71 |
setTimeout(() => { loadNextScene() }, 0)
|
72 |
return
|
|
|
97 |
|
98 |
await startTransition(async () => {
|
99 |
|
100 |
+
const game = getGame(gameRef.current)
|
101 |
|
102 |
let newDialogue = ""
|
103 |
try {
|
|
|
134 |
<div className="flex flex-row items-center space-x-3">
|
135 |
<label className="flex">Select a story:</label>
|
136 |
<Select
|
137 |
+
defaultValue={gameRef.current}
|
138 |
onValueChange={(value) => {
|
139 |
+
gameRef.current = value as GameType
|
140 |
setRendered({
|
141 |
assetUrl: "",
|
142 |
error: "",
|