This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONST.TIME.LIMIT <- 6 # threshold of time(sec) for searching. | |
CONST.MAX.DEPTH <- 3 # max depth of depth-first searching. | |
##' main | |
othello <- function(verbose = FALSE) { | |
## initialize. | |
board <- as.numeric(rep(0,8^2)) | |
turn <- 1 | |
board[conv.xy2index(4,4)] <- board[conv.xy2index(5,5)] <- 1 | |
board[conv.xy2index(4,5)] <- board[conv.xy2index(5,4)] <- -1 |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:a04c38d9604adb7eb9ca89860dfa1ef72db66037cc2c07c391ef8e67a31f9254" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculate the nth Fibonacci number, f(n). Using invariants | |
def fibo_tr(n, acc1, acc2) | |
if n == 0 | |
0 | |
elsif n < 2 | |
acc2 | |
else | |
return fibo_tr(n - 1, acc2, acc2 + acc1) | |
end | |
end |