Prompt de génération de code pour un bot Minecraft de style Voyager
De Wikiprompt, l’encyclopédie libre de prompts
Prompt de génération de code pour un bot Minecraft de style Voyager Un système complet de prompt pour générer du code de bot Minecraft avec Mineflayer, incluant la définition du rôle, la réutilisation de la bibliothèque de code, la spécification des entrées, les exigences de sortie et le format de réponse.
Contenu du PromptEnregistrer
🌐
Explain: No previous code or errors to analyze. The task requires collecting specified items based on inventory and biome. I need to check inventory, gather missing items using exploration and mining, and ensure all requirements are met.
Plan:
1) Analyze the task to determine required items and quantities.
2) Check current inventory for required items.
3) For each missing item, explore to find the resource (using random directions), mine it with mineBlock, and collect the required count.
4) If items require crafting or smelting, use craftItem or smeltItem after collecting raw materials.
5) Continue until all required items are collected, then complete the task.
Code:
```javascript
async function completeCollectionTask(bot) {
// Define task requirements - this should be customized per task
const requirements = [
{ name: 'oak_log', count: 5 },
{ name: 'cobblestone', count: 10 }
];
// Check inventory for each requirement
for (const req of requirements) {
let currentCount = 0;
for (const item of bot.inventory.items()) {
if (item.name === req.name) {
currentCount += item.count;
}
}
if (currentCount < req.count) {
const needed = req.count - currentCount;
console.log(`Need ${needed} more ${req.name}`);
// Try to find the block type
const blockType = req.name.replace('_log', '_log').replace('cobblestone', 'stone');
let found = false;
// Explore in random direction to find the resource
const directions = [
[1, 0, 1],
[-1, 0, -1],
[1, 0, -1],
[-1, 0, 1],
[0, 0, 1],
[0, 0, -1]
];
const randDir = directions[Math.floor(Math.random() * directions.length)];
await exploreUntil(bot, randDir, 32, () => {
const blocks = bot.findBlocks({
matching: (block) => block.name === blockType,
maxDistance: 32,
count: 1
});
if (blocks.length > 0) {
return blocks[0];
}
return null;
});
// Check if we found it nearby
const foundBlocks = bot.findBlocks({
matching: (block) => block.name === blockType,
maxDistance: 32,
count: needed
});
if (foundBlocks.length > 0) {
// Mine the blocks
await mineBlock(bot, blockType, Math.min(needed, foundBlocks.length));
found = true;
}
if (!found) {
console.log(`Could not find ${blockType}, trying alternatives`);
// Try mining directly from nearby blocks
const nearby = bot.findBlocks({
matching: (block) => block.name === blockType,
maxDistance: 32,
count: needed
});
if (nearby.length > 0) {
await mineBlock(bot, blockType, Math.min(needed, nearby.length));
}
}
}
}
console.log("Task collection complete!");
}
```
Connectez-vous pour voir le prompt complet
Continuer avec:
En vous connectant, vous acceptez nos Conditions et Confidentialité
Utilisation
Ce prompt est conçu pour être utilisé avec coding. Copiez le contenu ci-dessus et collez-le dans votre outil d’IA préféré.
Pour de meilleurs résultats, personnalisez les espaces réservés (indiqués par des crochets ou des majuscules) selon vos besoins.
Références
- Catégorie: Prompts coding
- Source: https://x.com/dotey/status/1662255634035687426
Discussion
0 commentaires