Changeset 4015 for trunk/ProjectFortress/demos
- Timestamp:
- 07/28/09 03:49:09 (4 months ago)
- Location:
- trunk/ProjectFortress/demos
- Files:
-
- 2 modified
-
newtictactoe.fss (modified) (3 diffs)
-
tictactoe.fss (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/demos/newtictactoe.fss
r3910 r4015 144 144 try 145 145 println "Your turn, " name 146 yourMove = strToInt(readLine()) 147 newBoard = board.move(yourMove, playerOne) 148 if newBoard.isGameOver() then 149 announceGameEnd(newBoard) 146 line = readLine() 147 if (|line| = 0) 148 then 149 println "Invalid response." 150 exit quit with false 150 151 else 151 myMove = smartAi(newBoard) 152 println "I play " myMove 153 play(newBoard.move(myMove, playerTwo)) 152 yourMove = strToInt(line) 153 newBoard = board.move(yourMove, playerOne) 154 if newBoard.isGameOver() then 155 announceGameEnd(newBoard) 156 else 157 myMove = smartAi(newBoard) 158 println "I play " myMove 159 play(newBoard.move(myMove, playerTwo)) 160 end 154 161 end 155 162 catch e … … 157 164 println "You cannot move there. Choose again." 158 165 play(board) 159 end160 IndexOutOfBounds[\ZZ32\] => do161 println "Invalid response."162 exit quit with false163 166 end 164 167 end … … 191 194 name = readLine() 192 195 println "What size board?" 193 try 194 N = strToInt(readLine()) 196 line = readLine() 197 if (|line| = 0) 198 then 199 println "Invalid response." 200 else 201 N = strToInt(line) 195 202 while playGame(name, N) do 196 203 println "" 197 204 end 198 catch e199 IndexOutOfBounds[\ZZ32\] =>200 println "Invalid response."201 205 end 202 206 println "Bye!" -
trunk/ProjectFortress/demos/tictactoe.fss
r3645 r4015 241 241 println board 242 242 println "Your turn " name 243 pos = strToInt(readLine()) 244 play(smartAi(board.move(pos, 1))) 243 line = readLine() 244 if (|line| = 0) 245 then 246 println "Invalid response." 247 exit quit with false 248 else 249 pos = strToInt(line) 250 play(smartAi(board.move(pos, 1))) 251 end 245 252 catch e 246 253 IllegalMove => do 247 254 println "You cannot move there. Choose again." 248 255 play(board) 249 end250 IndexOutOfBounds[\ZZ32\] => do251 println "Invalid response."252 exit quit with false253 256 end 254 257 end

