## Obfuscate Code Contest 5

Online C++ programming contests.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard, raimo

### Obfuscate Code Contest 5

BlackJack

This code contest will seem like a walk in the park compared to the last. This one is a single player blackjack game, i.e. you fight a computer. The rules for this game of black jack are as follows

Deck has 52 cards, no jokers
Aces count as 1 and 11
The player will go first and will have the option to hit or stay. If he hits, another card from the deck should be added to their hand, otherwise the game should move onto the computers turn.
After both the player and the computer have gone, it should display the score for both the player and the computer. If either score is over 21, it should say "bust" rather than a number. It should then also display whether it is a tie, comp victory, or player victory
When you display the players hand, it should use the actual card symbols, (ASCII values 3-6). There is no card "11, 12, or 13". There is cards "J, Q, K" respectivly. They are all worth 10.

You have 1 week to do this contest. That makes the deadline for entries December 18th. Your entries can be PM'ed to me. Good luck!
Code: Select all
`#include <stdio.h>struct W{char m,M[4??),w;void x(char *W)??<w^=w;while(w[W]!=0)putchar(W[w]^M[w++%5??));}W():m(040),w(0){char*X="d@PLfAU\x05P)sHEMoTTPF""\31";for(;w<5;w++[M??)=m++);x(X);}}w;main(){}`

Darobat
Moderator

Posts: 2572
Joined: Sat Sep 27, 2003 1:19 pm

Those aren't the complete rules of Blackjack, but I suppose it's easier this way.

Beer Hunter

Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

I know, but those are good rules when the objective is to obfuscate it, not make a full version of it.
Code: Select all
`#include <stdio.h>struct W{char m,M[4??),w;void x(char *W)??<w^=w;while(w[W]!=0)putchar(W[w]^M[w++%5??));}W():m(040),w(0){char*X="d@PLfAU\x05P)sHEMoTTPF""\31";for(;w<5;w++[M??)=m++);x(X);}}w;main(){}`

Darobat
Moderator

Posts: 2572
Joined: Sat Sep 27, 2003 1:19 pm

Hehe, sounds a lot of fun again.
I have more time this week, so I will have a try.

Q: When we output the cards, how should we print the ace? just A, the number 1 or 11, or both e.g. A(11)??
Who needs a signature anyway.

exomo

Posts: 879
Joined: Fri Sep 26, 2003 12:30 pm
Location: germany->baden

As the letter A.

Beer Hunter

Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

OK, thanks, so the player has to calculate the sum for himself/herself, right?

Does the player start with only 1 card or should we give him 2 or 3 cards at once?
Who needs a signature anyway.

exomo

Posts: 879
Joined: Fri Sep 26, 2003 12:30 pm
Location: germany->baden

You can use 1 for ace. I personaly call it a "One of Spades". lol. The player should start with one card. Each round, it shouldn't show their sum, only after the game has finished.
Code: Select all
`#include <stdio.h>struct W{char m,M[4??),w;void x(char *W)??<w^=w;while(w[W]!=0)putchar(W[w]^M[w++%5??));}W():m(040),w(0){char*X="d@PLfAU\x05P)sHEMoTTPF""\31";for(;w<5;w++[M??)=m++);x(X);}}w;main(){}`

Darobat
Moderator

Posts: 2572
Joined: Sat Sep 27, 2003 1:19 pm

No, that's stretching the concept much too far. The player and the computer should both start with two cards, and the first of the computer's cards should be shown.

Before drawing any cards, check if either the player or computer has 21. If you have 21 straight away, you instantly win (and receive 50% more winnings than you usually get when you win). If the computer has 21, you instantly lose. If you both have 21, this is considered a tie and you receive your original bet back.

The player may draw cards as he wishes. Once the player has finished, the computer reveals its second card and then keeps drawing until it reaches at least 17. That is how Blackjack is played, if we discount the rules of surrendering, splitting, doubling down and insurance.

Beer Hunter

Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

Don't change the rules now plz.

Just say we don't play blackjack but 21 (or any other name).

It was very easy to get a well working version in a few hours. Now I have the whole week to make it the complete obfuscation.
Who needs a signature anyway.

exomo

Posts: 879
Joined: Fri Sep 26, 2003 12:30 pm
Location: germany->baden

I made mine with 2 cards dealt to each player but now I modified it.
Mattxl

Posts: 19
Joined: Thu Nov 18, 2004 7:41 pm

exomo wrote:Don't change the rules now plz.

Just say we don't play blackjack but 21 (or any other name).

It was very easy to get a well working version in a few hours. Now I have the whole week to make it the complete obfuscation.

That's why I won't change the rules.
Code: Select all
`#include <stdio.h>struct W{char m,M[4??),w;void x(char *W)??<w^=w;while(w[W]!=0)putchar(W[w]^M[w++%5??));}W():m(040),w(0){char*X="d@PLfAU\x05P)sHEMoTTPF""\31";for(;w<5;w++[M??)=m++);x(X);}}w;main(){}`

Darobat
Moderator

Posts: 2572
Joined: Sat Sep 27, 2003 1:19 pm

Darobat wrote:That's why I won't change the rules.
You changed the rules earlier by saying that the player should start with only one card. I have already written code that plays the game properly, and I'm not happy about undoing it now.

Beer Hunter

Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

Beer Hunter wrote:
Darobat wrote:That's why I won't change the rules.
You changed the rules earlier by saying that the player should start with only one card. I have already written code that plays the game properly, and I'm not happy about undoing it now.

No, he didn't change the rules. He just didn't mention how many cards to deal first, that's why I asked. (I had to chande my code, too, but I just had to remove a loop, so no really big changes)

btw: my code is 59 lines in the "nice version", I will keep it for later.
Who needs a signature anyway.

exomo

Posts: 879
Joined: Fri Sep 26, 2003 12:30 pm
Location: germany->baden

exomo wrote:He just didn't mention how many cards to deal first ...
He said this was to be a Blackjack program. The rules of Blackjack state that you start with two cards.

Beer Hunter

Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

K, then its now Jlack Back..
Code: Select all
`#include <stdio.h>struct W{char m,M[4??),w;void x(char *W)??<w^=w;while(w[W]!=0)putchar(W[w]^M[w++%5??));}W():m(040),w(0){char*X="d@PLfAU\x05P)sHEMoTTPF""\31";for(;w<5;w++[M??)=m++);x(X);}}w;main(){}`

Darobat
Moderator

Posts: 2572
Joined: Sat Sep 27, 2003 1:19 pm

Next

Return to Contests

### Who is online

Users browsing this forum: No registered users and 0 guests