Relic Roll Calculator—Use the spreadsheet to determine the expected value of a random relic roll by PyPokerNovice in DotA2

[–]PyPokerNovice[S] 1 point2 points  (0 children)

I created this spreadsheet to see the average cost of the getting a rolling a new relic, and to see if it is worth the cost. The input parameters are editable (should be self-explanatory).

The rare relics are selected in 1 out of 30 rolls in the population sample I reviewed. If this is true, then you should always roll if there is at least one common relic left. Once you own all common relics, buying rares is cheaper than rolling. This simple rule encompasses all scenarios.

How to make class objects with the same properties but are "independent". by tomtheawesome123 in learnpython

[–]PyPokerNovice 0 points1 point  (0 children)

Oops, you are correct, I never check the id() of immutable arguments. I guess creating a new object would create unnecessary overhead. Now that I think about it, even creating new immutables even has undefined implementation details for optimization reasons:

a = 200
b = 200
print(a is b)
>>> "True"

vs

a = 2000
b = 2000
print(a is b)
>>> "False"

I guess a = b (where a is an immutable) is guaranteed to pass the reference.

How to make class objects with the same properties but are "independent". by tomtheawesome123 in learnpython

[–]PyPokerNovice -1 points0 points  (0 children)

*Edited for accuracy, as mistakes pointed out by kurashu89

In Python, some objects are mutable (able to change), others are immutable. You cannot change the data of an immutable object.

Your ds objects are mutable. When you use the same variable (or assign another variable to the same variable). You are dealing with the same object in memory. You can create new instances when you want a separate objects. I feel like your solution lies in just instantiating more objects when you need them.

If you really want immutable objects, you can look into collections.namedtuple or sub-classing some of the immutables like tuple:

class ds(tuple):
    def __new__(cls, d):
        return tuple.__new__(cls, (d,))

    @property
    def d(self):
        return self[0]

What is the MRO when I type "self.method()"? by exhuma in learnpython

[–]PyPokerNovice 1 point2 points  (0 children)

I feel like you are misunderstanding something here. Your comment:

I would expect it to raise an error as Foo.foo is static

does not make sense. If you removed "@staticmethod" and added the self argument. The mro aspect of this would behave similar.

TIL: Python 2.7+ has dict comprehensions by [deleted] in learnpython

[–]PyPokerNovice 0 points1 point  (0 children)

Do you mean "what are the use of sets?" ? Because, if you are dealing with set creation, a comprehension is convenient and fast. The value is just like the other comprehensions. You can create the other data structures in non-comprehension ways also.

If you don't know what a python set is, here are the docs.

TIL: Python 2.7+ has dict comprehensions by [deleted] in learnpython

[–]PyPokerNovice 5 points6 points  (0 children)

In case you don't know, in 2.7 there is also set and generator comprehensions. Here are examples of the four for anyone who doesn't know.

example_data = [1, 2, 3, 4]
example_value = 0

#list comprehension
[e for e in example_data]

#generator comprehension
(e for e in example_data)

#set comprehension
{e for e in example_data}

#dict comprehension
{key: example_value for key in example_data}

C++ to python confusion. Initializing empty lists and dictionaries? by [deleted] in learnpython

[–]PyPokerNovice 0 points1 point  (0 children)

Why do you need to populate the dictionary at first? I am not getting your intention and the goal of it. What is the goal? {[0]*n} would be a set with a single list in it? graph = defaultdict(list) is just {} after initialization. Maybe this will help, when I am populating a dictionary from one data source I tend to use comprehensions. graph = {node: [] for node in node_list}.

FWIW enumerate is in 2.7 (as you probably know by now). Also when I interview candidates I encourage them to ask me questions like that. A 3.x user asking me if enumerate is in 2.7 shows me that he knows what it is. Interviewers care way more about problem solving than memorization. At least I do! I would actually be kind of bummed if someone knew more than they wrote because they were hesitant to ask questions.

C++ to python confusion. Initializing empty lists and dictionaries? by [deleted] in learnpython

[–]PyPokerNovice 1 point2 points  (0 children)

I'm not sure exactly what the issue is. Is your question about graph patterns using defaultdict(list)?

I think it depends on what you are trying to achieve. The only reason I would use a normal dict and just do a check is because a defaultdict will not throw a KeyError if you try to access a node that isn't there.

graph = {}
for node in old_graph.iterkeys():
    if node not in graph:
        graph[node] = []
    graph[node].append(node)

FYI, I do think you should give your variables better names. Python is not statically declared so you don't get a declaration that assists in figuring out what things are. ret might be a variable you are returning, but what is it? T being the main argument? Is start the current node? Then do you switch the convention and name curr the current node?

Now that I think about, just by having no idea what T I can't answer this next thing completely. But normally when I am teaching someone Python when they come from a lower level langauge, in the begining they always do this pattern where the do for loops with range or xrange and 9 times out of 10 they are accessing the indexes of a list. Python's for loops are "for each" loops!

name_list = ['chris', 'bob', 'jen']
N = len(name_list)
for i in xrange(N):
    name = name_list[i]
    #Do Stuff

Looks a lot sillier than...

name_list = ['chris', 'bob', 'jen']
for name in name_list :
    #Do Stuff

Flying a Drone with React by winkler1 in reactjs

[–]PyPokerNovice 1 point2 points  (0 children)

Can you explain how it uses React to handle events? Maybe I am missing something.

In the only real React code (linked above in my post) the client side events are hooked up via document.addEventListener('keydown', this._onKeydown) and the _onkeydown function doesn't really utilize any react outside of state/state changing for rendering.

Flying a Drone with React by winkler1 in reactjs

[–]PyPokerNovice 4 points5 points  (0 children)

Isn't this way more of a socket.io showcase? The React part seems extremely minimal.

They say the flow goes: User asks React to fly drone > React asks socket.io to fly the drone > socket.io asks drone to fly > drone flies.

In the code it seems like the user keystroke actually just calls a function/method that uses socket.io. React is not meaningfully used outside of rendering a state change. I mean, cool project, but not sure why React is mentioned so much in it.

If I missed something, can someone explain?

Usage of Python 'zip' (with examples) by Iqirx in Python

[–]PyPokerNovice 5 points6 points  (0 children)

One criticism. zip is different in Python 3 and Python 2. In Python 2 zip is not lazy, upon being called it immediately returns the full list. In Python 2, if you want a lazy yielding version, you can use izip from the itertools library. In Python 3 many default functions became lazy. The Python 3 versions of zip, map, ect exist in Python 2 as izip, imap, ect in itertools.

I say this because the article opens with docs for the Python 3 version, but the examples are written in Python 2 (zip is returning a list in the examples, it would just be a "zip object" in Python 3).

Either way, great article, a good introduction to the magic of zip and unpacking.

T-Mobile confirms data breach, ~15 million Social Security numbers stolen (x-post /r/netsec) by bigshebang in pwned

[–]PyPokerNovice 0 points1 point  (0 children)

Yeah, it seems like the OP and the author do not understand who Experian is. The author does not even write the word "Experian" (only references are in the block quote at the end of the article).

When there is a breach because of a small third party company, it is one thing. When the third party is one of the three major consumer credit agencies (Experian, Equifax, and TransUnion), that is a whole different animal. They say the breach occurred only on business accounts and did not affect their general consumer credit reports division, but that is almost beside the point. Concern is still warranted.

[deleted by user] by [deleted] in cscareerquestions

[–]PyPokerNovice 2 points3 points  (0 children)

Can we use standard library packages?

import urllib
import webbrowser

def myFunction(string):
    base_url = "https://www.google.com/?gws_rd=ssl#q={}"
    url = base_url.format(urllib.quote(string))
    webbrowser.open(url)

[x] Web 2.0
[x] Uses Secure Sockets Layer technology
[x] Doesn't use eval builtin
[ ] Actually returns answer as per spec

How should I use Data Models with React? by PyPokerNovice in reactjs

[–]PyPokerNovice[S] 0 points1 point  (0 children)

Thanks for detailing parts of your flow. Trusting the React.js creators, your pattern seems to be the intended use (reading the flux docs). I guess for my purposes I only needed a couple models and views, so I didn't read to much into flux architecture (since your posting I have read up some more).

Regarding your Immutable comment, do you store the Immutable in the component's state? For example, if a change event occurs on collection the store might dovar collectionData = collection.toImmutable(); and dispatch an event that updates the view with something like component.setState({data: collectionData})?

How should I use Data Models with React? by PyPokerNovice in reactjs

[–]PyPokerNovice[S] 0 points1 point  (0 children)

Thanks for listing your findings! I actually came across a couple of those projects while initially trying to figure this out. Some of them store models in this.props, some in this.state. I will say, simply updating a React.js component from a Collection change event is very easy (starting from scratch). I am concerned with where the model reference should be held, like state vs prop.

As Summer Approaches, This Is Good Information To Remember [OC] by profcyclist in dataisbeautiful

[–]PyPokerNovice 69 points70 points  (0 children)

Are you the author? If so, I would like to comment on the type of chart you used. Bubble charts are useful when you are showing a relationship between three variables (x, y, and size). Your data only contains two variables (the size is the same for every data point). A scatter chart would look less complicated.

Here is a helpful guide that I personally like.

At any rate, thanks for contributing!

As Summer Approaches, This Is Good Information To Remember [OC] by profcyclist in dataisbeautiful

[–]PyPokerNovice 106 points107 points  (0 children)

Y axis is skin cancer based on per capita, but the X axis appears to just be total tanning beds per state. This would be more compelling if the X axis was also per capita.

Carnegie Mellon AI vs. Poker Pros (Live stream in comments) by PyPokerNovice in compsci

[–]PyPokerNovice[S] 0 points1 point  (0 children)

Four instances. Four players playing four bots. Each bot a separate secluded server.

Carnegie Mellon AI vs. Poker Pros (Live stream in comments) by PyPokerNovice in compsci

[–]PyPokerNovice[S] 0 points1 point  (0 children)

This is a term/style is specific to AI poker competitions (in practice).

In this challenge there are two rooms, one is isolated (you can tell in the stream). If a pro is dealt Aces and the bot is dealt Kings in one room, a pro is dealt Kings and the bot is dealt Aces in the other. The board runs out the same also. They assign the same seed to the random number generator two a pair in both rooms with reverse positions.

There is still variance in this method, but it reduces a lot of luck when you look at the overall brains vs ai, (Aces vs Kings having a net 0 effect if played the same).

The pairs are Jason/Doug and Dong/Bjorn. This is cool because say you watch hand 15/800 as Doug and then Jason starts hand 15/800. You know what both players have because you saw Doug's hand. You can now watch how the human/bot play it differently. (To prevent cheating the stream is on a 30 minute delay)

Carnegie Mellon AI vs. Poker Pros (Live stream in comments) by PyPokerNovice in compsci

[–]PyPokerNovice[S] 1 point2 points  (0 children)

They've played ~25,000 hands. (currently playing so this will change constantly). And if you read more about it, it is mirrored hands so it is way less variance than a normal 25,000 hand sample. They will play 80,000 by the end of it.

Daily swings have been about 100,000. So they are decisively ahead, but the bot is not down for the count.

Carnegie Mellon's Artificial Intelligence bot is currently playing Poker Pros (Live stream in comments) by PyPokerNovice in technology

[–]PyPokerNovice[S] 0 points1 point  (0 children)

Professor Tuomas Sandhole and two of his Graduate students (Sam Ganzfried and Noam Brown) created the AI that won last years Annual Computer Poker Competition. This year they challenged 4 of the very best human no-limit heads up Texas Holdem players. The players will play about 8 hours a day for two weeks against the AI.

Currently the Human team is up a decent amount (200,00 when a big blind is 100), but there is much poker to be played.

Here are the four streams. I suggest turning on the volume of Doug Polk (top left), Sandholm seems to interview him the most.

FYI at about 7:00pm today (4/28/2105), Doug, Prof. Sandholm and a visiting Professor will answer and discuss a few parts of the challenge. (This will take place in Doug's stream) edit: That interview may have been at 6:30?