chore(minecraft): various context adjustments
make gaze context prompt more informative provide time in hh AM/PM format instead of day/night
This commit is contained in:
@@ -17,18 +17,16 @@ export function buildConsciousContextView(ctx: ReflexContextState): ConsciousCon
|
||||
|
||||
const gaze = ctx.environment.nearbyPlayersGaze
|
||||
.map((g) => {
|
||||
const hit = g.hitBlock
|
||||
? `${g.hitBlock.name}@(${Math.round(g.hitBlock.pos.x)}, ${Math.round(g.hitBlock.pos.y)}, ${Math.round(g.hitBlock.pos.z)})`
|
||||
: 'air'
|
||||
|
||||
if (g.hitBlock)
|
||||
return `${g.name}->${hit}`
|
||||
if (g.hitBlock) {
|
||||
const block = `${g.hitBlock.name} at (${Math.round(g.hitBlock.pos.x)}, ${Math.round(g.hitBlock.pos.y)}, ${Math.round(g.hitBlock.pos.z)})`
|
||||
return `${g.name} is looking at ${block}`
|
||||
}
|
||||
|
||||
const lp = `(${Math.round(g.lookPoint.x)}, ${Math.round(g.lookPoint.y)}, ${Math.round(g.lookPoint.z)})`
|
||||
return `${g.name}->${hit} lookPoint${lp}`
|
||||
return `${g.name} is staring into the air around ${lp}`
|
||||
})
|
||||
.join(' | ')
|
||||
const gazeSummary = ctx.environment.nearbyPlayersGaze.length > 0 ? ` Nearby player gaze [${gaze}]` : ''
|
||||
.join('\n')
|
||||
const gazeSummary = ctx.environment.nearbyPlayersGaze.length > 0 ? `\nNearby player gaze:\n${gaze}` : ''
|
||||
|
||||
const environmentSummary = `${ctx.environment.time} ${ctx.environment.weather} Nearby players [${players}] Nearby entities [${entities}] Light ${ctx.environment.lightLevel}${gazeSummary}`
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ export interface ReflexSelfState {
|
||||
}
|
||||
|
||||
export interface ReflexEnvironmentState {
|
||||
time: 'day' | 'night' | 'sunset' | 'sunrise'
|
||||
time: string
|
||||
weather: 'clear' | 'rain' | 'thunder'
|
||||
nearbyPlayers: Array<{ name: string, distance?: number, holding?: string | null }>
|
||||
nearbyPlayersGaze: Array<{
|
||||
@@ -64,7 +64,7 @@ export class ReflexContext {
|
||||
food: 20,
|
||||
},
|
||||
environment: {
|
||||
time: 'day',
|
||||
time: 'SOMETHING WENT WRONG, YOU SHOULD NOTIFY THE USER OF THIS',
|
||||
weather: 'clear',
|
||||
nearbyPlayers: [],
|
||||
nearbyPlayersGaze: [],
|
||||
|
||||
@@ -173,8 +173,20 @@ export class ReflexRuntime {
|
||||
return acc
|
||||
}, [] as Array<{ name: string, distance: number, holding: string | null }>)
|
||||
|
||||
const formatMinecraftTime = (timeOfDay?: number): string => {
|
||||
if (typeof timeOfDay !== 'number')
|
||||
return 'Unknown time'
|
||||
|
||||
const hours24 = (6 + Math.floor(timeOfDay / 1000)) % 24
|
||||
const minutes = Math.floor(((timeOfDay % 1000) * 60) / 1000)
|
||||
|
||||
const hours12 = hours24 % 12 === 0 ? 12 : hours24 % 12
|
||||
const suffix = hours24 >= 12 ? 'PM' : 'AM'
|
||||
return `${String(hours12).padStart(2, '0')}:${String(minutes).padStart(2, '0')} ${suffix}`
|
||||
}
|
||||
|
||||
this.context.updateEnvironment({
|
||||
time: bot.bot.time?.isDay ? 'day' : 'night',
|
||||
time: formatMinecraftTime(bot.bot.time?.timeOfDay),
|
||||
weather: bot.bot.isRaining ? 'rain' : 'clear',
|
||||
nearbyPlayers: players,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user