diff --git a/07_final_assignment/baboonSimulation.R b/07_final_assignment/baboonSimulation.R index 70d6e4a..b444b69 100644 --- a/07_final_assignment/baboonSimulation.R +++ b/07_final_assignment/baboonSimulation.R @@ -135,6 +135,7 @@ stimuli <- result$Stimuli expect_equal(nrow(trials), count) expect_equal(length(stimuli$StimulusType[stimuli$StimulusType == "LearnedWord"]), 102) + # TODO: FAILES SOMETIMES!!! }) MakeMonkey <- function(cueset, outcomeset=c("Word", "Nonword"), @@ -145,16 +146,9 @@ learner <- function(stim, resp){ cues <- unlist(strsplit(stim, "_")) - print(cat("Cues: ", cues)) - print(cat("Outcome: ", resp)) - print("Weights: ",weights) - print(outcomeset) - print(weights[,outcomeset]) - totalActivation <- sum(weights[cues, outcomeset]) - - print(str(cues)) + + totalActivation <- colSums(weights[cues, outcomeset]) for (j in 1:length(cues)) { - print("HIIIER") if (resp == "Nonword") { yesType <- "Nonword" noType <- "Word" @@ -164,15 +158,20 @@ } else { stop("Unknown outcome", resp) } - weights[cues[j],yesType] <<- weigths[cues[j],yesType] + - alpha * beta * (lambda - totalActivation[yesType]) + weights[cues[j],yesType] <<- weights[cues[j],yesType] + + alpha * beta * (lambda - totalActivation[yesType]) weights[cues[j],noType] <<- weights[cues[j],noType] + - alpha * beta * (0 - totalActivation[noType]) + alpha * beta * (0 - totalActivation[noType]) } + # TODO: RETURN GUESS!!! } + give_weights <- function(){ + return(weights) + } + list( - Weights=weights, + Weights=give_weights, Learner=learner ) } @@ -181,8 +180,17 @@ cueset <- c("a","b","c") monkey <- MakeMonkey(cueset) + monkey$Learner("a_b","Word") + monkey$Learner("b_c","Nonword") + monkey$Learner("a_b","Word") + monkey$Learner("b_c","Nonword") + monkey$Learner("a_b","Word") + monkey$Learner("b_c","Nonword") + monkey$Learner("a_b","Word") + monkey$Learner("b_c","Nonword") + + print(monkey$Weights()) print(str(monkey)) - monkey$Learner("a_a_b_c","Word") - print(monkey$Weigths) + # TODO: MAKE TESTCASES!! }) # EOF