{"id":4025,"date":"2025-06-15T08:36:53","date_gmt":"2025-06-15T13:36:53","guid":{"rendered":"https:\/\/madlysane.com\/?page_id=4025"},"modified":"2025-06-15T08:36:53","modified_gmt":"2025-06-15T13:36:53","slug":"sequence-shift","status":"publish","type":"page","link":"https:\/\/madlysane.site\/en\/sequence-shift\/","title":{"rendered":"Sequence Shift"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <title>Sequence Shift<\/title>\n  <style>\n    body {\n      font-family: Arial, sans-serif;\n      text-align: center;\n      background: #f0f0f0;\n      padding: 40px;\n    }\n    .game {\n      background: #fff;\n      padding: 30px;\n      border-radius: 10px;\n      box-shadow: 0 0 10px rgba(0,0,0,0.1);\n      display: inline-block;\n    }\n    .color-tile {\n      width: 100px;\n      height: 100px;\n      display: inline-block;\n      margin: 10px;\n      border-radius: 10px;\n      cursor: pointer;\n      transition: background-color 0.3s;\n    }\n    #message {\n      margin-top: 20px;\n      font-size: 20px;\n    }\n  <\/style>\n<\/head>\n<body>\n  <div class=\"game\">\n    <h2>Sequence Shift<\/h2>\n    <p>Watch the color tiles flash gray and back. Then repeat the sequence!<\/p>\n    <div id=\"tiles\"><\/div>\n    <div id=\"message\"><\/div>\n  <\/div>\n\n  <script>\n    const colors = [\"red\", \"blue\", \"green\", \"yellow\"];\n    const tilesDiv = document.getElementById(\"tiles\");\n    const message = document.getElementById(\"message\");\n\n    let sequence = [];\n    let userInput = [];\n    let round = 0;\n    let colorMap = {};\n\n    function createTiles() {\n      tilesDiv.innerHTML = \"\";\n      colors.forEach(color => {\n        const tile = document.createElement(\"div\");\n        tile.className = \"color-tile\";\n        tile.style.backgroundColor = color;\n        tile.dataset.color = color;\n        tile.onclick = () => handleInput(color);\n        tilesDiv.appendChild(tile);\n        colorMap[color] = tile;\n      });\n    }\n\n    function flashTile(color, delay) {\n      const tile = colorMap[color];\n      setTimeout(() => {\n        tile.style.backgroundColor = \"gray\";\n        setTimeout(() => {\n          tile.style.backgroundColor = color;\n        }, 400);\n      }, delay);\n    }\n\n    function playSequence() {\n      message.textContent = `Round ${round + 1}`;\n      userInput = [];\n      sequence.forEach((color, i) => {\n        flashTile(color, i * 800);\n      });\n    }\n\n    function handleInput(color) {\n      userInput.push(color);\n      const index = userInput.length - 1;\n      if (userInput[index] !== sequence[index]) {\n        message.textContent = \"\u274c Wrong! Starting over.\";\n        sequence = [];\n        round = 0;\n        setTimeout(startGame, 1500);\n        return;\n      }\n      if (userInput.length === sequence.length) {\n        round++;\n        mutateSequence();\n        setTimeout(playSequence, 1000);\n      }\n    }\n\n    function mutateSequence() {\n      if (sequence.length > 0) {\n        const indexToChange = Math.floor(Math.random() * sequence.length);\n        sequence[indexToChange] = colors[Math.floor(Math.random() * colors.length)];\n      }\n      sequence.push(colors[Math.floor(Math.random() * colors.length)]);\n    }\n\n    function startGame() {\n      sequence = [colors[Math.floor(Math.random() * colors.length)]];\n      playSequence();\n    }\n\n    createTiles();\n    startGame();\n  <\/script>\n<\/body>\n<\/html>\n\n","protected":false},"excerpt":{"rendered":"<p>Sequence Shift Sequence Shift Watch the color tiles flash gray and back. Then repeat the sequence!<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"class_list":["post-4025","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/madlysane.site\/en\/wp-json\/wp\/v2\/pages\/4025","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/madlysane.site\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/madlysane.site\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/madlysane.site\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/madlysane.site\/en\/wp-json\/wp\/v2\/comments?post=4025"}],"version-history":[{"count":5,"href":"https:\/\/madlysane.site\/en\/wp-json\/wp\/v2\/pages\/4025\/revisions"}],"predecessor-version":[{"id":4073,"href":"https:\/\/madlysane.site\/en\/wp-json\/wp\/v2\/pages\/4025\/revisions\/4073"}],"wp:attachment":[{"href":"https:\/\/madlysane.site\/en\/wp-json\/wp\/v2\/media?parent=4025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}