|
| 1 | +//Things I can add, adjust, can do better |
| 2 | +//1. Add a timer to the pc decision to give the impression the PC is thinking |
| 3 | +//2. make the computer more intelligent by teaching it the rules and strategies of the game |
| 4 | +//3. add difficulties |
| 5 | +//4. Optimize code |
| 6 | +// a. optimize the methodes |
| 7 | +// b. optimize the objects |
| 8 | +// c. use jquery |
| 9 | +//5. make a version with canvas instead of html table |
| 10 | +//6. add sound |
| 11 | + |
1 | 12 | //View object is responsible for displaying the status of the game on the page |
2 | 13 | var view = { |
3 | 14 | //display function will display X or O on the right location |
@@ -74,6 +85,7 @@ var model = { |
74 | 85 | symbols: ["X", "O"], |
75 | 86 | moves: [" "," "," "," "," "," "," "," "," "], |
76 | 87 | tdId: ["00","01","02","10","11","12","20","21","22"], |
| 88 | + |
77 | 89 | //randomly choose the symbol for the player and computer |
78 | 90 | pickRandom: function(){ |
79 | 91 | var randomIndex = Math.floor(Math.random()*2); |
@@ -125,9 +137,7 @@ var model = { |
125 | 137 | if(this.moves.indexOf(" ") != -1){ |
126 | 138 | var random = Math.floor(Math.random() * 9); |
127 | 139 | if(this.moves[random] != "X" && this.moves[random] != "O"){ |
128 | | - console.log(random); |
129 | 140 | this.moves[random] = this.pcSymbol; |
130 | | - console.log(this.moves); |
131 | 141 | view.display(this.pcSymbol, this.tdId[random]); |
132 | 142 | makeDecision = false; |
133 | 143 | } |
@@ -208,14 +218,9 @@ var model = { |
208 | 218 | } |
209 | 219 | } |
210 | 220 |
|
211 | | - |
212 | 221 | function init(){ |
213 | 222 | var buttonStatus = document.getElementById("startGame"); |
214 | 223 | buttonStatus.onclick = controller.startGame; |
215 | | - |
216 | | - |
217 | 224 | } |
218 | 225 |
|
219 | 226 | window.onload = init; |
220 | | - |
221 | | - |
|
0 commit comments