The idea comes from the following page:

http://www.nytimes.com/interactive/science/rock-paper-scissors.html

Just for fun.

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAXSEQ 4
int rec[1<<(MAXSEQ<<1)][3];
int que[MAXSEQ];
int base[1<<3];
char info[3][5] =
{
        "LOSE",
        "DRAW",
        "WIN"
};
int result[3][3] =
{
        { 0,  1, -1},
        {-1,  0,  1},
        { 1, -1,  0}
};
int count[3];
int main(void)
{
        char s;
        for(int i=1; i<8; i++)
        {
                base[i] = base[i-(i&-i)] + 1;
        }
        while(scanf(" %c", &s) != EOF)
        {
                switch(s)
                {
                        case 'r': case 'R': s = 0; printf("Rock     <-> "); break;
                        case 's': case 'S': s = 1; printf("Scissors <-> "); break;
                        case 'p': case 'P': s = 2; printf("Paper    <-> "); break;
                }
                int len, flag = (1<<3)-1;
                for(len=MAXSEQ; len>=1; len--)
                {
                        int p = 0;
                        int a = 0;
                        int b = -1;
                        int r = 0;
                        for(int i=MAXSEQ-len; i<MAXSEQ; i++) p = (p<<2) | que[i];
                        for(int i=0; i<3; i++)
                        {
                                if((1<<i) & flag)
                                {
                                        if(b == -1 || rec[p][i] > rec[p][b])
                                        {
                                                b = i;
                                                r = 1<<i;
                                        }
                                        else if(rec[p][i] == rec[p][b])
                                        {
                                                r |= 1<<i;
                                        }
                                }
                        }
                        flag = r;   
                }
                int num = rand() % base[flag];
                int choice = -1;
                for(int i=0,k=0; i<MAXSEQ; i++)
                {
                        if((1<<i) & flag)
                        {
                                if(k == num) choice = i;
                                k ++;
                        }
                }
                switch(choice)
                {
                        case 0: printf("Paper   "); choice = 2; break;
                        case 1: printf("Rock    "); choice = 0; break;
                        case 2: printf("Scissors"); choice = 1; break;
                }
                count[result[choice][s]+1] ++;
                printf("\tCOMPUTER %s\tl=%d d=%d w=%d\n", info[result[choice][s]+1], count[0], count[1], count[2]);
                for(len=MAXSEQ; len>=1; len--)
                {
                        int p = 0;
                        for(int i=MAXSEQ-len; i<MAXSEQ; i++) p = (p<<2) | que[i];
                        rec[p][s] ++;
                }
                for(int i=0; i<MAXSEQ-1; i++) que[i] = que[i+1];
                que[MAXSEQ-1] = s + 1;
        }
        return 0;
}