Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Scenario: while programming you have a sudden nostalgic urge for the '80s and cheesy games.

Requirements: Make a GUI program (text probably won't work) for Simon, the game. Input can be clicking, or pressing a key. You should divide the screen into 4 regions: yellow, blue, red, green. When the game starts, a random color lights up and you activate it. Then, two lights come on, one after the other, and you need to activate those in order, etc. The game ends when you press the wrong color.

Bonuses:

-100 if you include sound (a note played when pressing and when the game shows you the colors)

-25 if you include a score counter.

share|improve this question
6  
GUI and code-golf don't generally work together. –  user80551 yesterday
2  
This should be doable in Minecraft. Wouldn't surprise me if someone already has. Don't know how one'd submit that here though... –  Kninnug yesterday
    
@Kninnug the amount of blocks * bytes per block;) –  Outlaw Lemur yesterday
add comment

3 Answers

Scratch, 150 – 125 = 25

I'm here for the fun, not the golf.

Edit: The scoring is based on this proposal at the moment. If another scoring system is generally adopted here, feel free to notify me or to edit this answer! For a break-down of this count, please see the comments.

Main program:

main

Individual sprites:

sprite

This is the sprite with number 0. The other sprites have the same script, except the number.

Play with it online.

Screenshot:

screenshot

Note: Please do not press two buttons within 0.3 seconds.

share|improve this answer
    
Ha, that's cool. A pause after a correct answer would be good, though, or some congratulatory sound. It sounds like my last move is part of the pattern. Also, I would play the sounds more slowly than the input cap, since rhythm and tone matching is how people (myself, at least) play... still, I like it. +1 –  krs013 yesterday
    
Scratch? Srs? Also, the byte count imo should be the total size of the SB2. –  Trimsty yesterday
    
@Trimsty Then it would be 126833 bytes (including the wav sound files etc), which is why I said "I'm here for the fun, not the golf." –  ace yesterday
    
According to the scoring I suggested here, the score is 60 (27 blocks, 20 chars/digits in constants, 8 operators, 5 variable uses). With bonuses, you get -65. –  ugoren 15 hours ago
    
@ugoren This is actually only a partial answer. There are 4 sprites, and only the script for one is shown, since the other sprites have almost identical scripts except the number. I will update the answer based on your scoring. Thanks. –  ace 5 hours ago
show 3 more comments

Bash 318 297 281 273-125=148

This is primarily a response to "Text probably won't work"; the following text-based bash script runs fine in Konsole, gnome-terminal etc. on my Ubuntu 14.04 machine. To create the regions of colour it sets the text background color. In fact, adding text makes the game more accessible to color-blind players. To make the game yet more accessible it reads the characters that the player needs to press (it assumes that espeak is installed). It also assumes that the only file matching /d*/ur*/ is /dev/urandom. For the regions of color to be of non-trivial size you probably want to set the text size to be quite large.

To play press y, r, g or b as appropriate.

set -e;d(){
(tput reset;echo 'x1r09mRx2g10mG
x3y11mYx4b14mBx0m'$s|sed s/.$1"//
s/[rgyb]..//g
s/x/`echo -e '\E'`[48;5;/g")
};x(){
d $c;espeak $c;d j
};l(){
for c in $o;do eval $1;x;done
};f(){
o=$o\ `tr -dc yrgb</d*/ur*|head -c1`
l;l 'read -n1 i;[ $c = $i ];s=$[s+1]';f
};f

See also the original ungolfed version.

The screenshots below are when the yellow light is on and the player's score is 7. The screenshot on the right has been desaturated to simulate colour-blindness.

screenshotBlackandWhite

share|improve this answer
    
Way too big for a code golf... –  Jan Dvorak yesterday
1  
True. I am here more for the "Programming Puzzles" more than the "Code Golf". –  gmatht yesterday
    
I have slightly golfed it now. –  gmatht yesterday
add comment

Mathematica, 409 - 125 = 284

k = 2;
p = Tuples[{0, 1}, 2];
f[c_, p_] := 
 EventHandler[{c, Rectangle[p]}, 
  "MouseClicked" :> (AppendTo[x, p]; Beep[]; g)]
h[R_] := (i = 1; 
  RunScheduledTask[
   H = If[OddQ@i, 
     Beep[]; {EdgeForm[{Thickness[0.02], Black}], FaceForm[], 
      Rectangle@R[[Ceiling[i/2]]]}, {}]; i++, {.3, 2 Length@R}])
s := (m = 0; x = {}; h[R = RandomChoice[p, k]];)
g := (m++; If[Take[R, m] != x, k = 2; s, If[m == k, k++; s]])
Dynamic@Graphics[{MapThread[f, {{Yellow, Red, Blue, Green}, p}], H}, 
  PlotLabel -> k]
s

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.