Leo's Pokerface

13

3

Pokerface

Introduction

Leo enjoys playing poker, but his job at Tech Inc. is too demanding for him to learn how to play well. Leo, being a computer scientist, is not discouraged. He decides to take more time than it would have taken to just learn poker, and use it to write a poker bot to help him play better. But now Leo has a problem: in order to understand how to play a bit better, Leo needs to observe multiple games of multiple "people," but the "people" need different play styles to improve the quality and reality of the game.

The Challenge

Leo recalls that there is actually a website dedicated to programming challenges, and is enlisting your help! Your job is to write a program which plays "Pokerface" a modified version of 5-card poker. The program will take input as a 5-card hand in whatever format you wish, after which the program will output:

  • Exactly (case-sensitive) "true" "1" or "t" if the player wishes to exchange cards, any other non-empty output otherwise.
  • If true, list of indices of cards and/or card names the player wishes to exchange.
  • A single number between 0 and 3, which specifies how many additional cards the player wants.
  • Print out the hand the player wishes to use.

(See formatting below)

Pokerface rules

  • Since pokerface is a text-based adventure game, cards must be presented in a consistent way. Cards are represented by two character codes, the first character is the suit, and the second is the name of the card.
    • Cards:
      • 2-9 = 2-9
      • 10 = T
      • Jack = J
      • Queen = Q
      • King = K
      • Ace = A
    • Suits:
      • Spades = S
      • Clubs = C
      • Hearts = H
      • Diamond = D

So the ace of spades would be SA, the 10 of hearts is HT, the 4th of diamonds is D4, etc.

  • A single round of Pokerface consists of four steps:
    • The deck is reshuffled and a five card hand is dealt to each player.
    • Each player is given the chance to exchange as many cards as they want.
    • Each player is given the chance to gain up to three more cards.
    • Each player must reveal their best hand.
  • The best hand wins, and gains that player a point. In the event of a tie, both players get a point.
  • In a single game, ten rounds are played and the player with the most points wins and gains a single "win point." In the event of a tie, both players gain a win point.
  • Leo doesn't really have a large amount of money, so your bot can assume that this is a perfect world with no betting.

Hands

  • Hands are exactly 5 cards in length (initial input and final output).
  • Hands are ranked consistent with the rules described here.

Input / Output

  • Leo only knows Java, so your program must be executable via the Process API (command line), and use STDIN and STDOUT for input and output, respectively.
  • For each step of input and output detailed above, the input and output must each exist on one line.
  • There must be at least one trailing new line after the final output. (This is due to the way input is read from STDIN)
  • No extraneous input/output is allowed, other than trailing and leading spaces. The parser simply does not understand things like final_hand=... or draw 0.
  • When drawing, output is a single integer, when exchanging output is a list of integers and/or cards defined below, and when being dealt the original hand, output is a list of cards defined below.
  • All input/output numbers must be positive integers in base 10.
  • You may define the format for card input (see post format below).
  • True is defined as exactly "true," "1" or "t" and false is any other non-empty value.
  • During the exchange step:
    • Card indices must be output with at least one space between them (e.g. 3 4 0)
    • Card names must be output with at least one space between them (e.g. H4 S8)
    • Card names and indices may be mixed in the output (e.g. 0 H7 3 D3)
    • Trailing and leading spaces are allowed.
    • The input as a result of the player outputting the above will be formatted as specified by the bot.jlsc file, in the same order as requested
  • The number of cards a player wants to add to their hand can have leading and trailing spaces.
  • Hands must be output with at least one space between them (e.g. H4 D5 CA), trailing spaces and leading spaces are allowed.
  • Hands do not need to be output in proper order (e.g. H4 D4 C4 DA SA and H4 DA D4 SA C4 both represent 4, 4, 4, Ace, Ace, which is a full house).
  • If you wish to build a strategy by analyzing opponents hands, you may store data in a <botname>/data directory.
    • After competing bots have displayed their hands, they will be written to every bots data directory, in hands.txt, with each hand on a new line (separated by \n). The file will be encoded in US_ASCII.
  • After your bot requests new cards or exchange cards, the cards will be input depending on what format you specify in the bot.jlsc file.

Post Format

  • Every post must include two things:
    • The source code of your bot, or a link to a public facing repository.
    • A zip file containing:
      • The compiled/executable version of your bot (If the file is a .exe or other non-de-compilable file, please just include compilation instructions in your post).
      • A bot.jlsc file, see below (side note: the .jlsc extension is just because of a side project of mine, a configuration format. The file below matches the proper syntax, so don't worry).
    • The .zip file must be named the same as your bot.
  • If you don't have access to windows or some other zipping utility, or can't make a .zip for whatever reason, just include the text of the bot.jlsc file in your post

bot.jlsc file:

name= "Botty"
link= "example.com"
cmd= "java -jar Botty.jar"
input_hand= "${0} ${1} ${2} ${3} ${4}"
input_1= "${0}"
input_2= "${0} ${1}"
input_3= "${0} ${1} ${2}"
input_4= "${0} ${1} ${2} ${3}"

Where:

  • "cmd" is the windows command line command to run your bot. Note that your bot will be in directory <botname>, so adjust the command accordingly.
  • "name" is the name of your bot.
  • "link" is the link to your answer, you'll have to edit this in after posting.
    • "input_hand" is how you want the original dealing to be formatted (with ${#} representing cards 0-4).
  • "input_1" is how you want the input of one additional card to be formatted.
  • "input_2" is how you want the input of two additional cards to be formatted.
  • "input_3" is how you want the input of three additional cards to be formatted.
  • "input_4" is how you want the input of four additional cards to be formatted.

Specifics

  • These loopholes are disallowed (see 'common pitfalls')
  • You may not write a bot the will always output the best hand possible, every time, within the rule set. (i.e. no long-running brute-force bots, nothing should be quite as 'good' as LeoBot)
  • Your bot should run in ~100 ms or less (Lenient on this point, max of ~1 second)
  • Any output of the bot after its chosen hand will be ignored.
  • Standard loopholes are disallowed.
  • Yes, I know linux is better, but I have a windows PC, so be sure the compiled/executable version of your program can be run from the windows command line.
    • I already have python and java installed on my computer, but I'm willing to update to new versions and install other environments, so please specify what type of environment your program requires.
  • You may not write a bot which does the same thing as another bot in every case. Spam bots are allowed, but discouraged.
  • Your bot may only use cards it has. Cards lost through exchange or not dealt to begin with are invalid output in the final hand.
  • Input and output may only contain ASCII characters.

Tournaments

  • Tournaments will be run when I get the time (my schedule is nearly as packed as Leo's, so this my be a little infrequent. Sorry for the inconvenience.).
  • Bots will be pit against eachother in 4 person games, and there will be one game for each possible subset of bots (i.e. lots of games).
    • This process will be repeated five times.
    • Due to the way the tournament handler makes the groups of bots, up to three filler bots will be added to make the number of bots divisible by 4. These bots will simply return the hand they were originally dealt.
  • After every round and game is run, the scores of the bots will be computed based on the number games they won.
    • Multiple bots can share a position (ties for first won by first posted).
  • After a tournament finishes, the scores will be appended to the bottom of this post.

Scoring

Normal KoTH rules. The bot(s) that win the most games win the challenge.

LeoBot

Leo's bot is pretty smart. It doesn't exchange any cards, that's too hard, but it does request the maximum number of additional cards, and it determines the best possible hand it can make, and plays that hand. The main logic of leobot is below.

package com.gmail.socraticphoenix.pokerface.leobot;

import com.gmail.socraticphoenix.pokerface.lib.card.Card;
import com.gmail.socraticphoenix.pokerface.lib.card.Deck;
import com.gmail.socraticphoenix.pokerface.lib.rule.HandRegistry;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class LeoBot {

    public static void main(String[] args) {
        List<Card> hand = new ArrayList<>();

        Scanner scanner = new Scanner(System.in);
        hand.addAll(Card.parseHand(scanner.nextLine()));
        System.out.println(false);

        System.out.println(3);
        hand.addAll(Card.parseHand(scanner.nextLine()));

        List<List<Card>> possibleHands = LeoBot.getSubsets(hand, 5);
        System.out.println(Deck.toString(possibleHands.stream().sorted((a, b) -> HandRegistry.determineWinner(b, a).comparable()).findFirst().get()));
    }

    private static <T> void getSubsets(List<T> superSet, int k, int idx, List<T> current, List<List<T>> solution) {
        if (current.size() == k) {
            solution.add(new ArrayList<>(current));
            return;
        }
        if (idx == superSet.size()) return;
        T x = superSet.get(idx);
        if (!current.contains(x)) {
            current.add(x);
        }
        getSubsets(superSet, k, idx + 1, current, solution);
        current.remove(x);
        getSubsets(superSet, k, idx + 1, current, solution);
    }

    public static <T> List<List<T>> getSubsets(List<T> superSet, int k) {
        List<List<T>> res = new ArrayList<>();
        getSubsets(superSet, k, 0, new ArrayList<T>(), res);
        return res;
    }

}

Note that if LeoBot consistently wins the tournaments, and there are a good amount of entries, I'll stop including him in the running.

Important Links

Disclaimer

Leo and Tech Inc. are story elements and any resemblance to real-life companies or people is purely unintentional. (However, when Leo's 'situation' adds or subtracts conditions from the question, those are actually part of the question...)

Socratic Phoenix

Posted 2016-07-29T03:07:01.940

Reputation: 1 629

Wait, isn't this a [tag:king-of-the-hill] question? – R. Kap – 2016-07-29T03:12:20.750

Cuz I forgot the tag... – Socratic Phoenix – 2016-07-29T03:15:33.877

Surely a dumb bot (that is shortest in bytes) is going to win this competition. – Nathan Merrill – 2016-07-29T03:18:15.363

@Nathan Merrill That's probably true... if it becomes a problem I'll weight the tournament position more... – Socratic Phoenix – 2016-07-29T03:26:13.237

1@SocraticPhoenix I'd highly recommend weighting it now or never. It'd be really unfair to players to adjust the scoring after submission are already ranked. – Nathan Merrill – 2016-07-29T03:29:42.097

Okay, adjusting now – Socratic Phoenix – 2016-07-29T03:41:23.583

This challenge definitely needs more detail. It is unclear how hands are scored (I assume standard poker rules, but maybe some people don't know those, or I'm wrong), what exactly a best hand is (is it all cards, some cards, a choice of the number of cards), why someone wouldn't want to receive more cards (because not drawing cards results in less chance of winning (less good hand, I think), and less info), is the deck shuffled after a round, etc. – Destructible Lemon – 2016-07-29T05:06:07.747

2@DestructibleWatermelon better? Just FYI, this was on sandbox for like 2-3 days... No one commented. I mean, it's all cool though – Socratic Phoenix – 2016-07-29T05:18:11.837

Well, I can definitely understand that. I got feedback about my challenge as it went out of the sandbox. A little bit annoying, I must say. Behind the issues I stated, you have a good challenge here. I might participate later, if I feel that I'm capable of making a bot. – Destructible Lemon – 2016-07-29T05:30:26.407

Do we have to choose the best hand at the end of our turn? In other words, we are allowed to choose any hand we so desire, right? – R. Kap – 2016-07-29T08:03:53.363

2Also, @NathanMerrill is probably still right about the dumb bot winning. After investigating cjam somwhat, a 5 byte program "f"q+ fulfils minimum requirements. If there are 10 people in competition, this probably beats all non-dumb entries (non-dumb entry probably has >75 chars, 5*10(score of dumb bot, coming last)=50<75 (score of very small smart bot (coming first))). Thusly, you should probably remove codegolf from this challenge – Destructible Lemon – 2016-07-29T08:05:09.657

2even if Cjam cannot be used, the point stands that dumbbots will be a reasonable strategy, and removing codegolf removes all the difficulties of balancing size VS performance – Destructible Lemon – 2016-07-29T08:14:24.453

@R.Kap you can choose whatever hand you like. – Socratic Phoenix – 2016-07-29T11:34:34.370

@DestructibleWatermelon if I do remove code golf, people may just write longer programs that brute-force the hands... Bad for performance and bad for business. I'll try to brainstorm some other method, cuz I don't want people just writing bots that can do everything... – Socratic Phoenix – 2016-07-29T11:34:39.293

The challenge was kind of supposed to be balancing size and performance... – Socratic Phoenix – 2016-07-29T11:36:59.617

Ooh, what.abput this: players are ranked in two separate lists, one for bytes and one for tourney. The final place is determined by adding their places from each list. – Socratic Phoenix – 2016-07-29T11:42:33.770

After Leo's successful pokerface, comes Leo's Fortune – Optimizer – 2016-07-29T11:46:23.500

Could you post LeoBot as an answer? I think [tag:codegolf] shouldn't be a factor and you should ask for a maximum runtime. See other [tag:king-of-the-hill] questions and http://meta.codegolf.stackexchange.com/q/8900/32686

– Blue – 2016-07-29T11:54:18.190

1Killed code-golf to death.... – Socratic Phoenix – 2016-07-29T12:53:39.227

What does exchanging do? If a bot asks to exchange all 5 cards, then asks for 3 new cards, will they be left with a 3 card hand? – Value Ink – 2016-08-02T01:09:06.713

No. When a bot exchanges a card at index x, it is dealt a new card to replace that card. So if a hand is HA H1 H2 H3 D9, the bot may ask to exchange 4 (fifth card, 0-indexed), and receive input like so: H4. The hand then becomes HA H1 H2 H3 H4 and the bot has a wonderful straight flush. Of course, the new card dealt is random, so it won't always help. – Socratic Phoenix – 2016-08-02T01:11:55.707

@ValueInk forgot to tag you. See above comment. – Socratic Phoenix – 2016-08-02T02:40:06.180

@SocraticPhoenix When are the results going to come out for who won? – Magenta – 2016-09-05T06:33:36.113

@Magenta soo... about that. The controller code wasn't work, and then I cleared out my old projects, but I accidentally deleted the controller too... so never? Sorry... – Socratic Phoenix – 2016-09-05T10:53:39.837

Answers

1

(Python), Pairbot, not quite competing (I don't know how to make cmd commands and stuff)

Pairbot will compete as soon as someone assists with the bot.jlsc, and zip files etc.


Pairbot knows that you don't always get good hands. He knows good hands are rare. Pairbot knows pairs and other duplicates are some of the best hands. Pairbot also knows the lowest hand you can get is a seven high, so he knows if he has 6 high, that's actually a straight (pairbot doesn't know why he knows that). He also knows if his lowest card is 10, (with no pairs), that's also a straight (pairbot knows he can get royal flush this way). Pairbot checks mainly for same number dupes, but also checks for two types of straights in special cases.

card_values={"2":2, "3":3, "4":4, "5":5, "6":6, "7":7, "8":8,
             "9":9, "T":10, "J":11, "Q":12, "K":13, "A":14,}
straight=False
def card_valuing(item):
    return card_values[item[1]]

input_list=input().split()
pairs_to_keep=[]
for item in input_list:
    if sum(item[1]==card[1] for card in input_list)>1:
        pairs_to_keep+=[item]
cards_to_remove=input_list
for item in pairs_to_keep:cards_to_remove.remove(item)#we want to remove all non pairs
hand=pairs_to_keep
if pairs_to_keep==[]:
    input_list.sort(key=card_valuing, reverse=True)
    if card_values[input_list[0][1]]==6:
        straight=True
        hand=input_list
    elif card_values[input_list[-1][1]]==10:
        straight=True
        hand=input_list
    else:
        print("true\n"+" ".join(input_list[1:]))
        hand+=input_list[0]+input().split()
elif input_list!=[]:
    print("true\n"+" ".join(input_list))
    hand+=input().split()
else:print(0, end=', ')
if straight:print("0\n0\n"+" ".join(hand))
else:
    print("3")
    hand+=input().split()
    same_number_dict={} #holds the amount of each type (A, 2, 3, etc.)

    def dict_value(item):
        return int(same_number_dict[item[1]])*100+card_values[item[1]]

    for card in hand:
        same_number_dict[card[1]]=sum(card[1] == item[1] for item in hand)

    hand=list(sorted(hand, key=dict_value, reverse=True))
    final_hand =[]
    last_number=hand[0][1]
    hand_taken=0
    while hand_taken < 5:
        if last_number==hand[0][1]:
            final_hand+=[hand[0]]
            hand=hand[1:]
            hand_taken+=1
        else:
            for card in hand:
                if same_number_dict[card[1]]>5-hand_taken:
                    same_number_dict[card[1]]=5-hand_taken
            hand=list(sorted(hand, key=dict_value, reverse=True))
            last_number=hand[0][1]
    print(" ".join(final_hand))

Format for input is the same as in the example: separated by spaces


If Socratic Phoenix could assist with the file stuffs, that would be good

Destructible Lemon

Posted 2016-07-29T03:07:01.940

Reputation: 5 908

Clever! So the file you'll want is here, I'm going to edit the main post to make the actual .zip optional...

– Socratic Phoenix – 2016-08-02T00:52:48.213

Also, +1 for FGITW – Socratic Phoenix – 2016-08-02T00:57:41.130

More like FGITLOSG (Fastest gun in the land of slow guns). – Destructible Lemon – 2016-08-02T01:00:10.267

True. I'm not sure that the input/output is in the proper form. When I enter a hand, the program prints "True" and then its current hand. I believe you wan to just print "false" as the "True" indicates you want to exchange cards. Secondly, the program needs to print a single integer when drawing, or integers separated by spaces when exchanging. Not "draw 0." I'll try to clarify the main post. – Socratic Phoenix – 2016-08-02T01:03:31.553

[So does it count as competing now?] didn't see new messages. I will correct bot right away – Destructible Lemon – 2016-08-02T01:18:17.343

@SocraticPhoenix, you are mistaken about the trading: it just trades all non-dupes but one, if there are no pairs, otherwise all non-dupes. Also, is it necessary to use card indices instead of the card name? I thought that would be ok – Destructible Lemon – 2016-08-02T01:29:46.950

I fixed the draw issue, which is now a single int, but I do not understand why I cannot use card names instead of integer indices. I shouldn't expect it too difficult to implement, if that is the issue, and it is a lot more intuitive for most answers – Destructible Lemon – 2016-08-02T01:39:08.357

You're probably right... I'll change it to allow exchanging via card names. However, it still looks like your printing "True" followed by the hand, where it probably should be "true", lowercase w/ no extraneous output – Socratic Phoenix – 2016-08-02T02:15:19.833

Okay... Your earlier comments weren't showing up. You just have some output issues. "true" must be on its own line, followed by the list of cards/indices, which must be separated by one or more spaces, not commas. Oh, and the true thing is case-sensitive – Socratic Phoenix – 2016-08-02T02:38:41.787

Case sensitive? It's just that python uses cap'd True. Anyway, I will fix this now. Thank you. – Destructible Lemon – 2016-08-02T02:44:50.927

If someone doesn't make another bot soon I might have to. – Destructible Lemon – 2016-08-02T03:10:07.947

It looks good to me! Someone will probably answer soon. I might actually place a bounty... Still considering that. I'll run a test tournament tomorrow with PairBot and LeoBot, just to make sure everything is working right. – Socratic Phoenix – 2016-08-02T03:18:07.560

1

Plumber, Python

Plumber is all about flushes. Plumber also prioritises higher value cards (meaning he can sometimes get straight flushes, especially royal ones (should they occur).) Plumber is pretty much messed if he doesn't get a flush, except that he might be lucky enough for a straight. Plumber will get flushes about 20% of the time, if calculations by Sherlock9 are correct

hand=input().split()
suit_in_hand={"S":0,"C":0,"D":0,"H":0}
card_values={"2":2, "3":3, "4":4, "5":5, "6":6, "7":7, "8":8,
             "9":9, "T":10, "J":11, "Q":12, "K":13, "A":14,}
def value_sort(x):
    return card_values[x[1]]
def suit_sort(x):
    return suit_in_hand[x[0]]

for card in hand:
    suit_in_hand[card[0]]+=1

hand.sort(key=suit_sort, reverse=True)

print(" ".join(hand[suit_in_hand[hand[0][0]]:]))
hand=hand[:suit_in_hand[hand[0][0]]]

for new_card in input().split():
    hand+=[new_card]
    suit_in_hand[new_card[0]]+=1

print(3)

for new_card in input().split():
    hand+=[new_card]
    suit_in_hand[new_card[0]]+=1
hand.sort(key=value_sort, reverse=True)
hand.sort(key=suit_sort, reverse=True)
print(" ".join(hand[:5]))

Also takes input separated by spaces like other my two bots

Destructible Lemon

Posted 2016-07-29T03:07:01.940

Reputation: 5 908

Note: I've changed the output rules slightly due to a bug in my own tournament program. There must now be at least one trailing new line after your final output. – Socratic Phoenix – 2016-08-03T16:01:03.790

1

LadyGaga, Python 3

  • Is somewhat blind to suits
  • Has a dress full of bugs
  • And likes to play Poker Face once in a while

    from math import ceil as f
    M=lambda A:max(set(A),key=A.count)
    K=lambda A:A.count(M(A))
    O=lambda A:range(len(A))
    J=lambda A:A[0]+str(U(A[1]))
    X={"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,"T":10,"J":11,"Q":12,"K":13,"A":14}
    def V(A):return([A[0]]+[int(X[A[1]])])
    def U(c):
     if c==10:c='T'
     if c==11:c='J'
     if c==12:c='Q'
     if c==13:c='K'
     if c==14:c='A'
     return(c)
    def P(A):
     S=[];C=[];t=len(A)
     for x in A:S.append(x[0]);C.append(x[1])
     B=[0]*9;q=len(set(C));p=K(C);D=list(set(C));D.sort()
     B[2]=1/f(13**(4-p));B[6]=1/f(13**(3-p));B[8]=1/f(13**(2-p))
     if (p,q)==(2,4):B[3]=1/1100;B[7]=5/34
     if (p,q)==(3,3):B[3]=1/169;B[7]=1/169
     if (p,q)==(4,2):B[3]=1/13;B[7]=1
     if (p,q)==(2,3):B[3]=5/169;B[7]=1
     if (p,q)==(3,2):B[3]=1;B[7]=1
     for x in O(D):D[x]-=x
     j=M(D);h=K(D)-5;B[5]=13**h
     for x in O(D):
      if j+h<D[x]<j-h and D[x]!=j:B[5]*=13
     W=K(S);B[4]=(4**(W-t))*(13-W)/52
     return(B,M(S))
    def E(B,h,u):
     x=0;D=[];C=[]
     while 1:
      k=list(C)
      C=[]
      while 1:
       p=list(B);del p[x]
       if len(D)==3:break
       if P(p)[0][h]>=P(B)[0][h]:C.append(B[x])
       x+=1
       if x>len(p):break
      if len(C)==0:break
      for x in O(C):
       if k==C or not((u in C[x])and(len(C)-1)):D.append(C[x]);del B[B.index(C[x])]
     return(D)
    s=input()
    A=s.split(' ')
    b=list(map(V,A));G,u=P(b);F=[649739,72192,4164,693,508,254,46.3,20,1.4];H=[]
    for x in O(F):F[x]=1-((1-(1/F[x]))**4)
    for x in O(F):H.append(G[x]-F[x])
    Y=H.index(max(H));p=[]
    e=E(list(b),Y,u);g=list(e)
    for x in O(e):e[x]=J(e[x])
    print(' '.join(e)if len(e)else'')
    for x in g:
     if x in b:del b[b.index(x)]
    s=input()
    if len(s):
     A=s.split(' ')
     b+=list(map(V,A))
    print(3)
    s=input()
    A=s.split(' ')
    b+=list(map(V,A));G,u=P(b);H=[]
    for x in O(F):H.append(G[x]-F[x])
    Y=H.index(max(H))
    e=E(list(b),Y,u)
    for x in e:
     if x in b:del b[b.index(x)]
    for x in O(b):b[x]=J(b[x])
    print(' '.join(b[:5]))
    print()
    
    • (I/O) modeled after PlumberBot -Edit: Extensive bugfixes thanks to Destructible Watermelon -Edit: Due to new rules, a trailing newline after the final output

Magenta

Posted 2016-07-29T03:07:01.940

Reputation: 1 322

You might want to use a dictionary instead of all that complicated stuff for the card values – Destructible Lemon – 2016-08-03T06:52:52.640

Anything that has been packed into an array already has been to my knowledge. Which section of code could I shorten? – Magenta – 2016-08-03T06:59:50.063

def V(A): b=[A[0]];c=A[1] if c=='T':c=10 if c=='J':c=11 if c=='Q':c=12 if c=='K':c=13 if c=='A':c=14 return (b + [int(c)])

to

x={"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,"T":10,"J":11,"Q":12,"K":13,"A":14,} def V(A):return(A[0] + x[A[1]]) – Destructible Lemon – 2016-08-03T07:02:59.940

Pairbot is only just longer than your program, and that's because it's readable – Destructible Lemon – 2016-08-03T07:05:49.283

I know. Bad codegolfing habits. – Magenta – 2016-08-03T07:06:58.517

How does this bot behave? It's too unreadable to tell – Destructible Lemon – 2016-08-03T07:09:26.300

evaluates rough probabilities on winning based on the hand at hand, and goes through (four of a kind, flush, straight, 3 of a kind, 2 pair, pair) to find out which is more likely, and chooses that one – Magenta – 2016-08-03T07:11:47.577

Also, how I/O works: First, you get a list of five cards, which are delimited how you like, default space delimited. Then you are expected to output whether you want to exchange any cards (output true or 1 if so, else 0 or false), and on a new line print the ones you wish to exchange if you do, then get input of new cards from the exchange, then print the amount of additional cards you want to draw (0 to 3), then get input if you want any cards. The bot is relaunched every round – Destructible Lemon – 2016-08-03T07:14:52.203

I'm not sure whether or not to feel threatened by this bot, with its fancy risk analysis – Destructible Lemon – 2016-08-03T07:15:53.833

If you saw the quality of that math that this has, you would not feel that way. – Magenta – 2016-08-03T07:16:44.953

Should we move this to chat? – Magenta – 2016-08-03T07:19:22.047

I would think that if you would think that – Destructible Lemon – 2016-08-03T07:20:11.637

Let us continue this discussion in chat.

– Magenta – 2016-08-03T07:20:36.123

Note: I've changed the output rules slightly due to a bug in my own tournament program. There must now be at least one trailing new line after your final output. – Socratic Phoenix – 2016-08-03T16:00:59.773

0

LuckyBot, Python

Pairbot invited his buddy Luckybot, who sprang for the chance. Luckybot had watched a lot of fictional poker, and reckoned he'd figured out the secret to poker: luck. Everyone knows the real pros (James Bond, for example) really rely and getting good hands, not skill. Hence, he doesn't look at his cards, and tries to pack as much good luck into them as possible


lucky_number=24 #IMPORTANT

from random import randint as roll


def lucky_shuffle(i):
    return sorted(i, key=lucky_dice)


def lucky_dice(seed):
    return sum(roll(1,6)for i in range(roll(1,6)))


hand=lucky_shuffle(input().split())

throw=lucky_dice(lucky_number)%5
print("true\n"+" ".join(hand[throw:]))

hand=hand[:throw]+lucky_shuffle(input().split())

hand=lucky_shuffle(hand)
hand=lucky_shuffle(hand)
#One more for good luck
hand=lucky_shuffle(hand)
#maybe one more
hand=lucky_shuffle(hand)
#I got a good feeling about this one
hand=lucky_shuffle(hand)

hand=lucky_shuffle(hand)
#I think I'm done
hand=lucky_shuffle(hand)
#for real this time


hand=lucky_shuffle(hand)

print("3")
hand=hand+lucky_shuffle(input().split())
#All right, I got a real good feeling about this,
#let me shuffle some more luck into them cards!


def extra_super_lucky_shuffle(item):
 return lucky_shuffle(lucky_shuffle(lucky_shuffle(\
    lucky_shuffle(lucky_shuffle(lucky_shuffle(\
        lucky_shuffle(lucky_shuffle(lucky_shuffle(item)))))))))


def super_duper_extra_ultra_uber_luckyshuffle(item):
    return extra_super_lucky_shuffle(extra_super_lucky_shuffle(\
        extra_super_lucky_shuffle(extra_super_lucky_shuffle(item))))


hand=super_duper_extra_ultra_uber_luckyshuffle(super_duper_extra_ultra_uber_luckyshuffle(hand))
#cmoooooooooooooooon
print(hand[:5])

Destructible Lemon

Posted 2016-07-29T03:07:01.940

Reputation: 5 908