User prompt
Let there be 20 levels and the questions get harder.
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'alpha')' in or related to this line: 'typingIndicator.alpha = 0.6;' Line Number: 262
User prompt
Please fix the bug: 'tween.to is not a function' in or related to this line: 'tween.to(bubble, {' Line Number: 171 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
improve
Code edit (1 edits merged)
Please save this source code
User prompt
Chat Bot Challenge
Initial prompt
Chat Gpt game
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var ChatBubble = Container.expand(function (message, isPlayer, bubbleWidth) {
var self = Container.call(this);
bubbleWidth = bubbleWidth || 800;
var bubbleHeight = Math.max(120, Math.ceil(message.length / 40) * 60);
var bubble = self.attachAsset(isPlayer ? 'chatBubblePlayer' : 'chatBubbleBot', {
width: bubbleWidth,
height: bubbleHeight,
anchorX: 0,
anchorY: 0
});
var messageText = new Text2(message, {
size: 45,
fill: isPlayer ? "#FFFFFF" : "#333333",
wordWrap: true,
wordWrapWidth: bubbleWidth - 40
});
messageText.anchor.set(0, 0);
messageText.x = 20;
messageText.y = 20;
self.addChild(messageText);
self.isPlayer = isPlayer;
self.message = message;
return self;
});
var OptionButton = Container.expand(function (text, callback) {
var self = Container.call(this);
var buttonHeight = Math.max(100, Math.ceil(text.length / 60) * 40);
var button = self.attachAsset('optionButton', {
width: 1600,
height: buttonHeight,
anchorX: 0,
anchorY: 0
});
var buttonText = new Text2(text, {
size: 40,
fill: 0x333333,
wordWrap: true,
wordWrapWidth: 1560
});
buttonText.anchor.set(0, 0.5);
buttonText.x = 20;
buttonText.y = buttonHeight / 2;
self.addChild(buttonText);
self.callback = callback;
self.originalColor = 0xDDDDDD;
self.down = function () {
button.tint = 0xBBBBBB;
tween(self, {
scaleX: 0.98,
scaleY: 0.98
}, {
duration: 100
});
};
self.up = function () {
button.tint = 0xDDDDDD;
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
if (self.callback) {
self.callback();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xF8F9FA
});
/****
* Game Code
****/
// Game state variables
var currentLevel = 1;
var chatHistory = [];
var currentOptions = [];
var isWaitingForResponse = false;
var scrollOffset = 0;
var maxScrollOffset = 0;
// UI Elements
var chatContainer = new Container();
var optionsContainer = new Container();
var scoreText = new Text2('Level: 1', {
size: 60,
fill: 0x333333
});
// Position UI elements
game.addChild(chatContainer);
game.addChild(optionsContainer);
scoreText.anchor.set(0, 0);
scoreText.x = 150;
scoreText.y = 50;
LK.gui.topLeft.addChild(scoreText);
// Chat scenarios data
var scenarios = [{
level: 1,
botGreeting: "Hello! I'm your AI assistant. I'm thinking of a number between 1 and 10. Can you guess it?",
correctAnswer: "5",
options: ["3", "5", "7", "I need a hint"],
responses: {
"3": "Too low! Try again.",
"5": "Correct! Well done. You've completed the first challenge!",
"7": "Too high! Try again.",
"I need a hint": "It's exactly in the middle of 1 and 10."
},
winCondition: "5"
}, {
level: 2,
botGreeting: "Great job! Now for something trickier. I'm an animal that says 'moo' and gives milk. What am I?",
correctAnswer: "cow",
options: ["dog", "cow", "cat", "I don't know"],
responses: {
"dog": "Dogs don't say 'moo' or give milk. Think again!",
"cow": "Excellent! Cows do indeed say 'moo' and give milk. Level complete!",
"cat": "Cats say 'meow', not 'moo'. Try again!",
"I don't know": "Think about farm animals. Which one makes that sound?"
},
winCondition: "cow"
}, {
level: 3,
botGreeting: "You're getting good at this! Here's a riddle: I have keys but no locks. I have space but no room. You can enter but not go inside. What am I?",
correctAnswer: "keyboard",
options: ["piano", "keyboard", "computer", "Give me a clue"],
responses: {
"piano": "A piano has keys, but think about something you use every day with computers.",
"keyboard": "Perfect! A keyboard has keys, a space bar, and an enter key. You've mastered level 3!",
"computer": "Close! But think more specifically about the part you use to type.",
"Give me a clue": "You use this to type messages and play games on your computer."
},
winCondition: "keyboard"
}, {
level: 4,
botGreeting: "Excellent! Now let's try some math. What is 15 + 27?",
correctAnswer: "42",
options: ["40", "42", "44", "I need help"],
responses: {
"40": "Close, but not quite right. Try adding again.",
"42": "Perfect! 15 + 27 = 42. Math skills unlocked!",
"44": "A bit too high. Double-check your addition.",
"I need help": "Break it down: 15 + 20 = 35, then add 7 more."
},
winCondition: "42"
}, {
level: 5,
botGreeting: "Time for geography! Which continent is Egypt located in?",
correctAnswer: "Africa",
options: ["Asia", "Africa", "Europe", "Give me a hint"],
responses: {
"Asia": "Egypt is not in Asia, though it's close to that continent.",
"Africa": "Exactly! Egypt is in the northeastern part of Africa. Well done!",
"Europe": "No, Egypt is south of Europe across the Mediterranean Sea.",
"Give me a hint": "Think about the continent that has the Nile River and the Sahara Desert."
},
winCondition: "Africa"
}, {
level: 6,
botGreeting: "Let's test your vocabulary. What does the word 'luminous' mean?",
correctAnswer: "bright",
options: ["dark", "bright", "heavy", "I'm not sure"],
responses: {
"dark": "That's the opposite! Luminous means giving off light.",
"bright": "Excellent! Luminous means bright or giving off light.",
"heavy": "No, luminous has nothing to do with weight.",
"I'm not sure": "Think about things that glow or shine, like the moon or stars."
},
winCondition: "bright"
}, {
level: 7,
botGreeting: "History time! In which year did humans first land on the Moon?",
correctAnswer: "1969",
options: ["1965", "1969", "1971", "Need a clue"],
responses: {
"1965": "A bit too early. The space race was still developing then.",
"1969": "Correct! Apollo 11 landed on the Moon in July 1969.",
"1971": "Close, but that was a later Apollo mission.",
"Need a clue": "It was during the 1960s, and it happened in the summer."
},
winCondition: "1969"
}, {
level: 8,
botGreeting: "Science challenge! What gas do plants absorb from the air during photosynthesis?",
correctAnswer: "carbon dioxide",
options: ["oxygen", "carbon dioxide", "nitrogen", "Help me"],
responses: {
"oxygen": "Plants actually release oxygen during photosynthesis!",
"carbon dioxide": "Perfect! Plants absorb CO2 and release oxygen.",
"nitrogen": "Nitrogen is in the air, but it's not what plants use for photosynthesis.",
"Help me": "Think about what we breathe out that plants need to make food."
},
winCondition: "carbon dioxide"
}, {
level: 9,
botGreeting: "Logic puzzle! If all roses are flowers, and some flowers are red, can we say all roses are red?",
correctAnswer: "no",
options: ["yes", "no", "maybe", "Explain please"],
responses: {
"yes": "Not quite! Just because some flowers are red doesn't mean all roses are red.",
"no": "Exactly! Some roses could be pink, white, or other colors.",
"maybe": "We can be more definitive than that based on the logic given.",
"Explain please": "We know roses are flowers, and some flowers are red, but roses could be any color."
},
winCondition: "no"
}, {
level: 10,
botGreeting: "Advanced math! What is the square root of 144?",
correctAnswer: "12",
options: ["10", "12", "14", "I need help"],
responses: {
"10": "Too low. What number times itself equals 144?",
"12": "Perfect! 12 × 12 = 144, so √144 = 12.",
"14": "Too high. Try a smaller number.",
"I need help": "Think: what number multiplied by itself gives you 144?"
},
winCondition: "12"
}, {
level: 11,
botGreeting: "Literature question! Who wrote the famous play 'Romeo and Juliet'?",
correctAnswer: "Shakespeare",
options: ["Dickens", "Shakespeare", "Austen", "Give me a hint"],
responses: {
"Dickens": "Charles Dickens wrote novels, not this famous tragedy.",
"Shakespeare": "Brilliant! William Shakespeare wrote Romeo and Juliet.",
"Austen": "Jane Austen wrote different types of stories, like Pride and Prejudice.",
"Give me a hint": "This English playwright lived in the 1500s-1600s and wrote many famous plays."
},
winCondition: "Shakespeare"
}, {
level: 12,
botGreeting: "Pattern recognition! What comes next in this sequence: 2, 6, 18, 54, ?",
correctAnswer: "162",
options: ["108", "162", "216", "Show me the pattern"],
responses: {
"108": "Look at the pattern more carefully. Each number is multiplied by 3.",
"162": "Excellent! The pattern is ×3: 2×3=6, 6×3=18, 18×3=54, 54×3=162.",
"216": "Too high. The pattern involves multiplying by 3, not 4.",
"Show me the pattern": "Each number is 3 times the previous number: 2×3=6, 6×3=18, etc."
},
winCondition: "162"
}, {
level: 13,
botGreeting: "Chemistry challenge! What is the chemical symbol for gold?",
correctAnswer: "Au",
options: ["Go", "Au", "Gd", "I don't know"],
responses: {
"Go": "That's not a real chemical symbol. Gold's symbol comes from Latin.",
"Au": "Perfect! Au comes from the Latin word 'aurum' meaning gold.",
"Gd": "That's the symbol for Gadolinium, not gold.",
"I don't know": "Gold's symbol comes from its Latin name 'aurum'."
},
winCondition: "Au"
}, {
level: 14,
botGreeting: "Complex riddle! I am not alive, but I grow. I don't have lungs, but I need air. I don't have a mouth, but water kills me. What am I?",
correctAnswer: "fire",
options: ["plant", "fire", "cloud", "Give me a clue"],
responses: {
"plant": "Plants are alive, but I said I'm not alive. Think again!",
"fire": "Brilliant! Fire grows, needs air to survive, and water extinguishes it.",
"cloud": "Clouds don't really 'grow' in the same way, and water doesn't kill them.",
"Give me a clue": "I'm something hot that you might see in a fireplace or on a candle."
},
winCondition: "fire"
}, {
level: 15,
botGreeting: "Advanced logic! If it takes 5 machines 5 minutes to make 5 widgets, how long does it take 100 machines to make 100 widgets?",
correctAnswer: "5 minutes",
options: ["5 minutes", "20 minutes", "100 minutes", "Help me understand"],
responses: {
"5 minutes": "Exactly right! Each machine makes 1 widget in 5 minutes, regardless of how many machines there are.",
"20 minutes": "Think about how many widgets each machine makes in the given time.",
"100 minutes": "That would be if one machine had to make all 100 widgets.",
"Help me understand": "If 5 machines make 5 widgets in 5 minutes, each machine makes 1 widget in 5 minutes."
},
winCondition: "5 minutes"
}, {
level: 16,
botGreeting: "Cryptography puzzle! If A=1, B=2, C=3... what number does the word 'CAB' equal when you add the letter values?",
correctAnswer: "6",
options: ["6", "9", "12", "Show me how"],
responses: {
"6": "Perfect! C=3, A=1, B=2, so 3+1+2=6.",
"9": "Double-check your letter values. C=3, A=1, B=2.",
"12": "That's too high. Remember A=1, not A=0.",
"Show me how": "C is the 3rd letter (3), A is the 1st letter (1), B is the 2nd letter (2)."
},
winCondition: "6"
}, {
level: 17,
botGreeting: "Philosophical question! If you have a ship and gradually replace every single part of it with new parts, is it still the same ship?",
correctAnswer: "debatable",
options: ["yes", "no", "debatable", "Explain this paradox"],
responses: {
"yes": "That's one valid philosophical position, but there are other viewpoints too.",
"no": "That's another valid philosophical stance, but it's not the only answer.",
"debatable": "Exactly! This is the famous Ship of Theseus paradox - there's no single correct answer.",
"Explain this paradox": "This is called the Ship of Theseus paradox. Philosophers debate whether identity persists through complete change."
},
winCondition: "debatable"
}, {
level: 18,
botGreeting: "Master-level math! What is 7! (7 factorial)?",
correctAnswer: "5040",
options: ["343", "5040", "7000", "What's factorial?"],
responses: {
"343": "That's 7³ (7 cubed), not 7! (7 factorial).",
"5040": "Incredible! 7! = 7×6×5×4×3×2×1 = 5040. You're a math master!",
"7000": "Much too high. Factorial means multiplying all numbers from 1 to that number.",
"What's factorial?": "7! means 7×6×5×4×3×2×1. It's all numbers from 7 down to 1 multiplied together."
},
winCondition: "5040"
}, {
level: 19,
botGreeting: "Ultimate word puzzle! What 9-letter word becomes shorter when you add two letters to it?",
correctAnswer: "shortness",
options: ["shortness", "something", "wonderful", "I give up"],
responses: {
"shortness": "Absolutely brilliant! 'Short' becomes 'shortness' when you add letters, but the word means 'shorter'!",
"something": "Not quite. Think about words related to the concept of length.",
"wonderful": "No, that doesn't relate to the concept of becoming 'shorter'.",
"I give up": "The answer is 'shortness' - it's longer in letters but means shorter in meaning!"
},
winCondition: "shortness"
}, {
level: 20,
botGreeting: "FINAL CHALLENGE! Here's the ultimate test: I am the beginning of everything, the end of everywhere. I'm the beginning of eternity, the end of time and space. What am I?",
correctAnswer: "the letter E",
options: ["time", "the letter E", "infinity", "I need the answer"],
responses: {
"time": "Think more literally about the riddle. Look at the letters in each word.",
"the letter E": "MAGNIFICENT! You are a true Chat Bot Champion! E is at the beginning of 'everything' and 'everywhere', etc!",
"infinity": "Close thinking, but look at the actual letters that start and end those words.",
"I need the answer": "Look at the first letter of 'everything' and 'everywhere', and the last letter of 'everywhere' and 'time'."
},
winCondition: "the letter E"
}];
var currentScenario = scenarios[0];
function addChatBubble(message, isPlayer) {
var bubble = new ChatBubble(message, isPlayer, 1400);
var yPos = 150;
for (var i = 0; i < chatHistory.length; i++) {
yPos += chatHistory[i].height + 20;
}
bubble.x = isPlayer ? 500 : 150;
bubble.y = yPos - scrollOffset;
// Add entrance animation
bubble.alpha = 0;
bubble.scaleX = 0.8;
bubble.scaleY = 0.8;
chatContainer.addChild(bubble);
chatHistory.push(bubble);
// Animate bubble appearance
tween(bubble, {
alpha: 1,
scaleX: 1,
scaleY: 1
}, {
duration: 300
});
// Auto-scroll to show latest message
updateScroll();
// Play sound
LK.getSound('messageSound').play();
return bubble;
}
function updateScroll() {
var totalHeight = 0;
for (var i = 0; i < chatHistory.length; i++) {
totalHeight += chatHistory[i].height + 20;
}
var visibleHeight = 1800; // Approximate visible chat area
if (totalHeight > visibleHeight) {
maxScrollOffset = totalHeight - visibleHeight;
var targetScrollOffset = Math.min(maxScrollOffset, scrollOffset + 150);
// Smooth scroll animation
var scrollObj = {
value: scrollOffset
};
tween(scrollObj, {
value: targetScrollOffset
}, {
duration: 400,
onFinish: function onFinish() {
scrollOffset = scrollObj.value;
// Update positions after animation
for (var i = 0; i < chatHistory.length; i++) {
var originalY = 150;
for (var j = 0; j < i; j++) {
originalY += chatHistory[j].height + 20;
}
chatHistory[i].y = originalY - scrollOffset;
}
}
});
} else {
// Update positions immediately if no scroll needed
for (var i = 0; i < chatHistory.length; i++) {
var originalY = 150;
for (var j = 0; j < i; j++) {
originalY += chatHistory[j].height + 20;
}
chatHistory[i].y = originalY - scrollOffset;
}
}
}
function clearOptions() {
for (var i = optionsContainer.children.length - 1; i >= 0; i--) {
var child = optionsContainer.children[i];
optionsContainer.removeChild(child);
child.destroy();
}
currentOptions = [];
}
function showOptions(options) {
clearOptions();
var startY = 2200;
for (var i = 0; i < options.length; i++) {
var option = new OptionButton(options[i], createOptionCallback(options[i]));
option.x = 224;
option.y = startY + i * 120;
optionsContainer.addChild(option);
currentOptions.push(option);
}
}
function createOptionCallback(optionText) {
return function () {
if (isWaitingForResponse) return;
handlePlayerResponse(optionText);
};
}
function handlePlayerResponse(response) {
isWaitingForResponse = true;
// Add player message
addChatBubble(response, true);
// Clear options temporarily
clearOptions();
// Add typing indicator
var typingIndicator = addChatBubble("Bot is typing...", false);
typingIndicator.alpha = 0.6;
// Animate typing dots
var dotCount = 0;
var typingTimer = LK.setInterval(function () {
dotCount = (dotCount + 1) % 4;
var dots = "";
for (var i = 0; i < dotCount; i++) {
dots += ".";
}
typingIndicator.children[1].setText("Bot is typing" + dots);
}, 300);
// Process response after a delay
LK.setTimeout(function () {
LK.clearInterval(typingTimer);
// Remove typing indicator
chatContainer.removeChild(typingIndicator);
typingIndicator.destroy();
chatHistory.pop();
processBotResponse(response);
}, 1000);
}
function processBotResponse(playerResponse) {
var botResponse = currentScenario.responses[playerResponse] || "I didn't understand that. Please try again.";
addChatBubble(botResponse, false);
// Check if this was the correct answer
if (playerResponse === currentScenario.winCondition) {
LK.getSound('correctSound').play();
LK.setScore(currentLevel);
// Move to next level after delay
LK.setTimeout(function () {
nextLevel();
}, 2000);
} else {
LK.getSound('wrongSound').play();
// Show options again after delay
LK.setTimeout(function () {
showOptions(currentScenario.options);
isWaitingForResponse = false;
}, 1500);
}
}
function nextLevel() {
currentLevel++;
if (currentLevel > scenarios.length) {
// Game complete
addChatBubble("Congratulations! You've completed all challenges! You're a true Chat Bot Champion!", false);
LK.showYouWin();
return;
}
// Load next scenario
currentScenario = scenarios[currentLevel - 1];
var newLevelText = 'Level: ' + currentLevel + ' / ' + scenarios.length;
scoreText.setText(newLevelText);
// Add visual feedback for level completion
LK.effects.flashScreen(0x4a90e2, 500);
// Add level transition message
addChatBubble("🎉 Level " + (currentLevel - 1) + " Complete! Moving to Level " + currentLevel + "...", false);
// Start new conversation
LK.setTimeout(function () {
addChatBubble(currentScenario.botGreeting, false);
LK.setTimeout(function () {
showOptions(currentScenario.options);
isWaitingForResponse = false;
}, 1000);
}, 2000);
}
// Initialize first conversation
addChatBubble("Welcome to Chat Bot Challenge!", false);
LK.setTimeout(function () {
addChatBubble(currentScenario.botGreeting, false);
LK.setTimeout(function () {
showOptions(currentScenario.options);
isWaitingForResponse = false;
}, 1500);
}, 1000);
// Handle scrolling with touch/mouse
var isDragging = false;
var lastTouchY = 0;
game.down = function (x, y, obj) {
isDragging = true;
lastTouchY = y;
};
game.move = function (x, y, obj) {
if (isDragging && maxScrollOffset > 0) {
var deltaY = lastTouchY - y;
scrollOffset = Math.max(0, Math.min(maxScrollOffset, scrollOffset + deltaY * 2));
// Update chat bubble positions
for (var i = 0; i < chatHistory.length; i++) {
var originalY = 150;
for (var j = 0; j < i; j++) {
originalY += chatHistory[j].height + 20;
}
chatHistory[i].y = originalY - scrollOffset;
}
lastTouchY = y;
}
};
game.up = function (x, y, obj) {
isDragging = false;
}; ===================================================================
--- original.js
+++ change.js
@@ -142,8 +142,212 @@
"computer": "Close! But think more specifically about the part you use to type.",
"Give me a clue": "You use this to type messages and play games on your computer."
},
winCondition: "keyboard"
+}, {
+ level: 4,
+ botGreeting: "Excellent! Now let's try some math. What is 15 + 27?",
+ correctAnswer: "42",
+ options: ["40", "42", "44", "I need help"],
+ responses: {
+ "40": "Close, but not quite right. Try adding again.",
+ "42": "Perfect! 15 + 27 = 42. Math skills unlocked!",
+ "44": "A bit too high. Double-check your addition.",
+ "I need help": "Break it down: 15 + 20 = 35, then add 7 more."
+ },
+ winCondition: "42"
+}, {
+ level: 5,
+ botGreeting: "Time for geography! Which continent is Egypt located in?",
+ correctAnswer: "Africa",
+ options: ["Asia", "Africa", "Europe", "Give me a hint"],
+ responses: {
+ "Asia": "Egypt is not in Asia, though it's close to that continent.",
+ "Africa": "Exactly! Egypt is in the northeastern part of Africa. Well done!",
+ "Europe": "No, Egypt is south of Europe across the Mediterranean Sea.",
+ "Give me a hint": "Think about the continent that has the Nile River and the Sahara Desert."
+ },
+ winCondition: "Africa"
+}, {
+ level: 6,
+ botGreeting: "Let's test your vocabulary. What does the word 'luminous' mean?",
+ correctAnswer: "bright",
+ options: ["dark", "bright", "heavy", "I'm not sure"],
+ responses: {
+ "dark": "That's the opposite! Luminous means giving off light.",
+ "bright": "Excellent! Luminous means bright or giving off light.",
+ "heavy": "No, luminous has nothing to do with weight.",
+ "I'm not sure": "Think about things that glow or shine, like the moon or stars."
+ },
+ winCondition: "bright"
+}, {
+ level: 7,
+ botGreeting: "History time! In which year did humans first land on the Moon?",
+ correctAnswer: "1969",
+ options: ["1965", "1969", "1971", "Need a clue"],
+ responses: {
+ "1965": "A bit too early. The space race was still developing then.",
+ "1969": "Correct! Apollo 11 landed on the Moon in July 1969.",
+ "1971": "Close, but that was a later Apollo mission.",
+ "Need a clue": "It was during the 1960s, and it happened in the summer."
+ },
+ winCondition: "1969"
+}, {
+ level: 8,
+ botGreeting: "Science challenge! What gas do plants absorb from the air during photosynthesis?",
+ correctAnswer: "carbon dioxide",
+ options: ["oxygen", "carbon dioxide", "nitrogen", "Help me"],
+ responses: {
+ "oxygen": "Plants actually release oxygen during photosynthesis!",
+ "carbon dioxide": "Perfect! Plants absorb CO2 and release oxygen.",
+ "nitrogen": "Nitrogen is in the air, but it's not what plants use for photosynthesis.",
+ "Help me": "Think about what we breathe out that plants need to make food."
+ },
+ winCondition: "carbon dioxide"
+}, {
+ level: 9,
+ botGreeting: "Logic puzzle! If all roses are flowers, and some flowers are red, can we say all roses are red?",
+ correctAnswer: "no",
+ options: ["yes", "no", "maybe", "Explain please"],
+ responses: {
+ "yes": "Not quite! Just because some flowers are red doesn't mean all roses are red.",
+ "no": "Exactly! Some roses could be pink, white, or other colors.",
+ "maybe": "We can be more definitive than that based on the logic given.",
+ "Explain please": "We know roses are flowers, and some flowers are red, but roses could be any color."
+ },
+ winCondition: "no"
+}, {
+ level: 10,
+ botGreeting: "Advanced math! What is the square root of 144?",
+ correctAnswer: "12",
+ options: ["10", "12", "14", "I need help"],
+ responses: {
+ "10": "Too low. What number times itself equals 144?",
+ "12": "Perfect! 12 × 12 = 144, so √144 = 12.",
+ "14": "Too high. Try a smaller number.",
+ "I need help": "Think: what number multiplied by itself gives you 144?"
+ },
+ winCondition: "12"
+}, {
+ level: 11,
+ botGreeting: "Literature question! Who wrote the famous play 'Romeo and Juliet'?",
+ correctAnswer: "Shakespeare",
+ options: ["Dickens", "Shakespeare", "Austen", "Give me a hint"],
+ responses: {
+ "Dickens": "Charles Dickens wrote novels, not this famous tragedy.",
+ "Shakespeare": "Brilliant! William Shakespeare wrote Romeo and Juliet.",
+ "Austen": "Jane Austen wrote different types of stories, like Pride and Prejudice.",
+ "Give me a hint": "This English playwright lived in the 1500s-1600s and wrote many famous plays."
+ },
+ winCondition: "Shakespeare"
+}, {
+ level: 12,
+ botGreeting: "Pattern recognition! What comes next in this sequence: 2, 6, 18, 54, ?",
+ correctAnswer: "162",
+ options: ["108", "162", "216", "Show me the pattern"],
+ responses: {
+ "108": "Look at the pattern more carefully. Each number is multiplied by 3.",
+ "162": "Excellent! The pattern is ×3: 2×3=6, 6×3=18, 18×3=54, 54×3=162.",
+ "216": "Too high. The pattern involves multiplying by 3, not 4.",
+ "Show me the pattern": "Each number is 3 times the previous number: 2×3=6, 6×3=18, etc."
+ },
+ winCondition: "162"
+}, {
+ level: 13,
+ botGreeting: "Chemistry challenge! What is the chemical symbol for gold?",
+ correctAnswer: "Au",
+ options: ["Go", "Au", "Gd", "I don't know"],
+ responses: {
+ "Go": "That's not a real chemical symbol. Gold's symbol comes from Latin.",
+ "Au": "Perfect! Au comes from the Latin word 'aurum' meaning gold.",
+ "Gd": "That's the symbol for Gadolinium, not gold.",
+ "I don't know": "Gold's symbol comes from its Latin name 'aurum'."
+ },
+ winCondition: "Au"
+}, {
+ level: 14,
+ botGreeting: "Complex riddle! I am not alive, but I grow. I don't have lungs, but I need air. I don't have a mouth, but water kills me. What am I?",
+ correctAnswer: "fire",
+ options: ["plant", "fire", "cloud", "Give me a clue"],
+ responses: {
+ "plant": "Plants are alive, but I said I'm not alive. Think again!",
+ "fire": "Brilliant! Fire grows, needs air to survive, and water extinguishes it.",
+ "cloud": "Clouds don't really 'grow' in the same way, and water doesn't kill them.",
+ "Give me a clue": "I'm something hot that you might see in a fireplace or on a candle."
+ },
+ winCondition: "fire"
+}, {
+ level: 15,
+ botGreeting: "Advanced logic! If it takes 5 machines 5 minutes to make 5 widgets, how long does it take 100 machines to make 100 widgets?",
+ correctAnswer: "5 minutes",
+ options: ["5 minutes", "20 minutes", "100 minutes", "Help me understand"],
+ responses: {
+ "5 minutes": "Exactly right! Each machine makes 1 widget in 5 minutes, regardless of how many machines there are.",
+ "20 minutes": "Think about how many widgets each machine makes in the given time.",
+ "100 minutes": "That would be if one machine had to make all 100 widgets.",
+ "Help me understand": "If 5 machines make 5 widgets in 5 minutes, each machine makes 1 widget in 5 minutes."
+ },
+ winCondition: "5 minutes"
+}, {
+ level: 16,
+ botGreeting: "Cryptography puzzle! If A=1, B=2, C=3... what number does the word 'CAB' equal when you add the letter values?",
+ correctAnswer: "6",
+ options: ["6", "9", "12", "Show me how"],
+ responses: {
+ "6": "Perfect! C=3, A=1, B=2, so 3+1+2=6.",
+ "9": "Double-check your letter values. C=3, A=1, B=2.",
+ "12": "That's too high. Remember A=1, not A=0.",
+ "Show me how": "C is the 3rd letter (3), A is the 1st letter (1), B is the 2nd letter (2)."
+ },
+ winCondition: "6"
+}, {
+ level: 17,
+ botGreeting: "Philosophical question! If you have a ship and gradually replace every single part of it with new parts, is it still the same ship?",
+ correctAnswer: "debatable",
+ options: ["yes", "no", "debatable", "Explain this paradox"],
+ responses: {
+ "yes": "That's one valid philosophical position, but there are other viewpoints too.",
+ "no": "That's another valid philosophical stance, but it's not the only answer.",
+ "debatable": "Exactly! This is the famous Ship of Theseus paradox - there's no single correct answer.",
+ "Explain this paradox": "This is called the Ship of Theseus paradox. Philosophers debate whether identity persists through complete change."
+ },
+ winCondition: "debatable"
+}, {
+ level: 18,
+ botGreeting: "Master-level math! What is 7! (7 factorial)?",
+ correctAnswer: "5040",
+ options: ["343", "5040", "7000", "What's factorial?"],
+ responses: {
+ "343": "That's 7³ (7 cubed), not 7! (7 factorial).",
+ "5040": "Incredible! 7! = 7×6×5×4×3×2×1 = 5040. You're a math master!",
+ "7000": "Much too high. Factorial means multiplying all numbers from 1 to that number.",
+ "What's factorial?": "7! means 7×6×5×4×3×2×1. It's all numbers from 7 down to 1 multiplied together."
+ },
+ winCondition: "5040"
+}, {
+ level: 19,
+ botGreeting: "Ultimate word puzzle! What 9-letter word becomes shorter when you add two letters to it?",
+ correctAnswer: "shortness",
+ options: ["shortness", "something", "wonderful", "I give up"],
+ responses: {
+ "shortness": "Absolutely brilliant! 'Short' becomes 'shortness' when you add letters, but the word means 'shorter'!",
+ "something": "Not quite. Think about words related to the concept of length.",
+ "wonderful": "No, that doesn't relate to the concept of becoming 'shorter'.",
+ "I give up": "The answer is 'shortness' - it's longer in letters but means shorter in meaning!"
+ },
+ winCondition: "shortness"
+}, {
+ level: 20,
+ botGreeting: "FINAL CHALLENGE! Here's the ultimate test: I am the beginning of everything, the end of everywhere. I'm the beginning of eternity, the end of time and space. What am I?",
+ correctAnswer: "the letter E",
+ options: ["time", "the letter E", "infinity", "I need the answer"],
+ responses: {
+ "time": "Think more literally about the riddle. Look at the letters in each word.",
+ "the letter E": "MAGNIFICENT! You are a true Chat Bot Champion! E is at the beginning of 'everything' and 'everywhere', etc!",
+ "infinity": "Close thinking, but look at the actual letters that start and end those words.",
+ "I need the answer": "Look at the first letter of 'everything' and 'everywhere', and the last letter of 'everywhere' and 'time'."
+ },
+ winCondition: "the letter E"
}];
var currentScenario = scenarios[0];
function addChatBubble(message, isPlayer) {
var bubble = new ChatBubble(message, isPlayer, 1400);