|
@@ -0,0 +1,51 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Document</title>
|
|
|
+ <script>////////////////
|
|
|
+ //blackBelt
|
|
|
+ var predictArray = {
|
|
|
+ 1111: 1
|
|
|
+ };
|
|
|
+ var historyArr = [1, 1, 1, 1];
|
|
|
+ var newValue = Math.round(Math.random());
|
|
|
+ let newKey = "1111"
|
|
|
+ let predictKey = []
|
|
|
+ function blackBelt() {
|
|
|
+ debugger
|
|
|
+ var yourMove = +prompt("Your move 0 or 1");
|
|
|
+ var answer;
|
|
|
+ predictArray[newKey] = +yourMove;
|
|
|
+ if (yourMove === 1 || yourMove === 0) {
|
|
|
+ if (+newValue === yourMove){
|
|
|
+ answer = confirm("I knew it. Let's try again");
|
|
|
+
|
|
|
+ } else {
|
|
|
+ answer = confirm ("You win. Let's try again");
|
|
|
+
|
|
|
+ }
|
|
|
+ historyArr.shift();
|
|
|
+ historyArr.push(yourMove);
|
|
|
+ newKey = "" + historyArr[0]+historyArr[1]+historyArr[2]+historyArr[3]
|
|
|
+ if(predictKey.indexOf(newKey) == -1){
|
|
|
+ newValue = Math.round(Math.random());
|
|
|
+ } else {
|
|
|
+ newValue = predictArray[newKey]
|
|
|
+ }
|
|
|
+ predictKey = Object.keys(predictArray)
|
|
|
+ if(answer == true) {
|
|
|
+ return blackBelt()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ alert ("Error. Try again")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ blackBelt();
|
|
|
+ </script>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+
|
|
|
+</body>
|
|
|
+</html>
|