[PD] rock, paper, scissors

PSPunch shima at pspunch.com
Tue Aug 5 03:17:25 CEST 2008


Hi,


You are already treating the "hand"s as random integers.

iL = hand (value) of left player
iR = hand (value) of right player

Get the value of (iL - iR).
Send above value to [sel -2 -1 0 1 2]

-2 .. Right player wins
-1 .. Left player wins
  0 .. Even
  1 .. Right player wins
  2 .. Left players wins


There may be a smarter looking way without using [sel] but I think this 
is as few as you can get with number of objects used.

--
David Shimamoto



> hi
> 
> i tried to do a recreation of the classic rock, paper, scissors game in pd.
> attached is the easy part :-) i got stuck in the interesting part, the 
> one where  the results from each chain ("hand", if you will)
> must be compared, to see who wins. before building a super complex and 
> rube golberg-like chain of gates, moses and selects, i wanted to check 
> for advice here. im quite sure i overlooked some brilliant and effective 
> way of doing this.
> 
> thanks
> p
> 
> 
> #N canvas 0 22 511 410 10;
> #X obj 108 33 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
> 1;
> #X obj 108 117 sel 0 1 2;
> #X msg 125 245 set paper;
> #X obj 108 89 random 3;
> #X symbolatom 108 310 10 0 0 0 - - -;
> #X obj 308 117 sel 0 1 2;
> #X msg 325 244 set paper;
> #X obj 308 78 random 3;
> #X symbolatom 308 310 10 0 0 0 - - -;
> #X obj 108 61 metro 2000;
> #X msg 108 221 set rock;
> #X msg 142 269 set scissors;
> #X msg 308 221 set rock;
> #X msg 342 269 set scissors;
> #X connect 0 0 9 0;
> #X connect 1 0 10 0;
> #X connect 1 1 2 0;
> #X connect 1 2 11 0;
> #X connect 2 0 4 0;
> #X connect 3 0 1 0;
> #X connect 5 0 12 0;
> #X connect 5 1 6 0;
> #X connect 5 2 13 0;
> #X connect 6 0 8 0;
> #X connect 7 0 5 0;
> #X connect 9 0 3 0;
> #X connect 9 0 7 0;
> #X connect 10 0 4 0;
> #X connect 11 0 4 0;
> #X connect 12 0 8 0;
> #X connect 13 0 8 0;
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list





More information about the Pd-list mailing list