# Getting a Highscore in Kuku Kube [closed]

First of all, this is more a challenge, than a serious programming question, I would like to share.

Some of you might know the game Kuku kube, where you have to identify a square in a grid, which has a different colour than the others and click it.

You can find it under http://kuku-kube.com/ .

As this seems to be an ideal exercise for our image processing students, I want to see, which way is the best to get the highest score.

My code so far:

from pymouse import PyMouse
import time
b=time.time()
m=PyMouse()
start=(2912,895)
tl=(2695,387)
br=(3129,814)
def click():
m.click(start[0],start[1])
time.sleep(0.1)
while time.time()-b<60:
for i in range(0,9):
for l in range(0,9):
m.click(2696+i*53.625,390+l*53.125)
time.sleep(0.004)

click()


gets me to about 370-ish. Is it possible to get more? Use image processing?

High-score wins!

• Since you've accepted an answer which, on the basis of the question alone, I would expect you to consider not to be a valid answer, I think you need to clarify what is and isn't acceptable. Apr 15 '15 at 14:43
• I'm voting to close this question as off-topic because it's not a programming puzzle, but a program optimization challenge. Apr 16 '15 at 8:28

# Javascript (Cheating), Score = limitless?

I realized that the game timer was using setInterval, which is a very unreliable way of keeping time. With that in mind, since js is single threaded, if we simply hog the thread, the timer can't update. As a result, you can essentially get any score you want. If you perform 1000 clicks in a single function call without releasing the thread, you guarantee a score of at least 60000 (in fact I did this and got 180000). This is obviously cheating because the game lasts longer than 60 seconds, though the game doesn't realize it. For this reason, any js solution at all is really sort of cheating. Though the time increase is minimal for code that completes quickly, you can still potentially delay the timer for as long as your code runs.

var factor = 1000;

function findAndClick() {
var array = document.getElementById("box").children;

for(var j = 0; j < factor; j++){
var one = array[0].style.cssText;
var two = array[1].style.cssText;

var color;
if(one != two){
color = array[2].style.cssText;
} else {
color = one;
}

for (var i=0; i < array.length; i++) {
if (array[i].style.cssText != color) {
array[i].click();
break;
}
}
}
}
$(".play-btn").click(); setInterval(findAndClick, 0);  # Javascript (REALLY Cheating), Score = limitless? The game's object is actually global. As a result, you can tweak various properties to your advantage. The easiest of which is to just set your score to whatever you want it to be: $(".play-btn").click();
Game.lv = 1000000;

• I really like this way of thinking. Apr 20 '15 at 15:35

# Javascript, Score ≈ 10700 14400 (Chrome)

On the home page, open your developer console (F12), copy/paste the following code and wait 60 seconds.

jQuery slow down the execution, so I used the fantastic Vanilla-JS

function findAndClick() {
var array = document.getElementById("box").children;
var last = "";
for (var i=0; i < array.length; i++) {
if (array[i].style.cssText != last) {
array[i].click();
last = array[i].style.cssText;
}
}
}
\$(".play-btn").click();
setInterval(findAndClick, 0);

• On my setup (ubuntu, firefox) that gives me ~2170. But nevertheless, pretty cool :) Apr 15 '15 at 12:34
• I have also tried on Firefox, it is pretty bad on Windows too. Apr 15 '15 at 12:36
• Firefox gives me around 4300, but Chrome reached 10701 on first try. Apr 15 '15 at 12:52
• Just got 15977 with the new version. Apr 15 '15 at 13:01
• Be careful when running this code to refresh the screen before executing the code again. Otherwise the original code is still running plus the new one. You will increasingly get better scores the more times you run the code (without refreshing) because it's delaying the game's timer. Apr 15 '15 at 17:38

# Javascript/JQuery: 4489

I went the same route as Mig, but I think his is more efficient than mine, as my javascript skills are quite limited.

clickBox = function() {
a = jQuery("#box span");
if (!a.is(":visible")) {
clearInterval(clickBox);
return;
};
var colors = {};
a.each(function(i, o) {
var style = jQuery(this).attr("style");
colors[style] = 1 + (colors[style] || 0)
});
a.each(function() {
if (colors[jQuery(this).attr("style")] == 1) {
jQuery(this).click()
}
});
};
setInterval(clickBox, 0);