/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1556061313874.jpg (800x1078, 153K)

Other urls found in this thread:

codeforces.com/
youtube.com/watch?v=r804UF8Ia4c
chessprogramming.org/Horizon_Effect
tutorialspoint.com/python/python_multithreading.htm
docs.python.org/3/library/functions.html#print
twitter.com/SFWRedditImages

kitsune.touchTail()

C++ is the most powerful programming language.

any codeforces fag around?

Attached: 1548564503166.png (448x357, 3K)

My hello world wont compile

Attached: 1556381047018.jpg (351x420, 108K)

I need to make a fuzzy logic function that evaluates if the danger is bigger than the movement score and the damage score.

I was thinking to normalize all the three values to the same range and just evaluate which is bigger.

I just need to refactor my code into being recursive and maybe do a recursive function to get the best posible move of each board configuration, maybe comparing it to possible enemy moves, and maybe make a prunning function with the ones that are dumb.

Attached: 1555533395828.png (1373x833, 59K)

What programming language lets me summon a 800 year old fox god?

Fuck off, stupid frogposter.
You're not welcome here.

Attached: 1410721305946.png (365x470, 209K)

Unlambda

Trying to come up with a project that combines Embedded and Distributed systems for a capstone project.
I’m thinking of some sort of generic command centre for iot shit, but this sounds like it would be a solved problem.

ive heard java may do anything if youre good enough

Take a remedial math course. Also chess pieces don’t have hp you stupid frog.

Attached: 62B2878A-AB76-4235-965E-448952AF9340.jpg (295x275, 28K)

whats that

hey weeb stop e-bullying apu-poster
he just want to be fren for all
aapologize now

Attached: 1536377475326.png (1448x1892, 635K)

>remedial math
I'm not in college.

how do I do fuzzy logic?

>chess pieces
mine does and is very fun.

you have been asking for help on this thread with the same question for like 3 days.
maybe you should review the concepts of what you are doing instead of begging for help.

Attached: pizza gif.gif (300x300, 1.08M)

it's a contests/challenges platform our college teachers have shilled the last months. I'm not sure how broadly it is used but it seems promising if you have some free time to spare. the problem is, sometimes I'm not sure how to solve some of the puzzles and just reading other people's codes hasn't been enough for me. I might invite some classmates to a Telegram group so we can help each other with it

here's the link btw codeforces.com/

youtube.com/watch?v=r804UF8Ia4c

ok, so I need a rule system that says what the input is, and it translates it to a humane output like
"Is too hot" and then decides on which one is preferable.

nice.

Attached: 1556139511926.jpg (640x640, 38K)

So what is the difference between Web development and just regular development? Does Web just mean frontend web application development? Like HTML, CSS, JavaScript, whatever .js framework? Cause the backend stuff seems like it isn't any different then just "regular" software development.

>Roblox game gets 10,000 visits in 24 hours
>not at all prepared to devote the time to capitalise on this popularity surge
It's not even the weekend in the US jeez

Attached: Oh no.png (626x625, 259K)

Normal development is creating applications to run on your computer.

Web development is creating applications to run on someone else's computer.

>roblox
>horse pedo
please end your life

Web development consists of coming up with the same solution to the same imaginary problem over and over again, and burning everything to the ground for no good reason other than to chase trends.
Yes, backend development would be the closest to other programming, but I just think webdev is unbelievably dull and uninteresting.

Enjoy your ban.

Not the same guy, but many things are pretty similar I think. A lot of the stuff is inserting into databases for example, that's not different from desktop software. And then depending on your application you might do a lot of computation that's also the same.
Then you simply send the data back as Json or someting. Or am I missing something here?

So the client and server relationship is the main difference? I'm just wondering because I see most jobs are web based nowadays it seems. I mostly see web stuff and embedded and I know embedded is a totally different thing in itself.

Is it that different? Because you could really have a website that works just like a desktop app nowadays. Except maybe most of the desktop-like code is run on a server.

>remedial math

this is why america is going to be destroyed by the chinese

looks interesting

>Is it that different?
Not really. I actually mainly write server code but for an IPC system instead of anything hitting the network. Fundamentally it's somewhat similar in design to a web backend would do, but I'm sure you're not writing your web backend in C. I just personally prefer dealing with much lower level systems.

How good is the AI now? Do refactor to make it easier to substitute with alternative AI modules though.

Attached: Prepare_for_Chinese_invasion_of_west_coast_6_of_6-73Nl0ubbNlE.jpg (480x360, 13K)

It works but the AI still keeps zerg rushing like a dumbfuck into my pieces, so I need some fuzzy logic decision to make it not do dumb shit.

Also it needs to prioritize when the enemy is in your territory, since this means it can lose by a random piece who attack their HP.

What's the reason to make your language dynamically typed? Is it just faster to compile/interpret? Is that why JavaScript is dynamically typed so it will be interpreted faster? Because otherwise I can't think of a reason since you could just use type inference instead if you want cleaner syntax.

Just finishing up a new malloc() for my operating system. It's significantly faster than the old one, which is a nice boost for basically everything.
It's a slab+freelist allocator that defers to mmap() for allocations over 4 KB. It's not thread safe yet, so that's a FIXME.

Attached: Screenshot at 2019-05-02 02-44-11.png (1920x1080, 1.09M)

do refactoring mean simply making newer functions with newer code that replaces the old functions but you keep the old functions as reference?

Attached: 1556644338575.png (713x730, 156K)

Increasing the search depth would mitigate horizon effects, at least a little. chessprogramming.org/Horizon_Effect

Some chess programs extend search until at least the King is out of check.

It just means restructuring the code to follow a different design. You could refactor and delete all of the old code if you wanted or keep it.

>Compilation error: 'Kitsune.touchTail()' is inaccessible due to its protection level

This is true. Maybe you could add "without changing old or adding new functionality"
There are some standard techniques, but whatever you do if your intention is simply to make the code clearer that's refactoring.

I found a hack to getting github stars
What you do is make a test folder, put like 1/2 test files in there, and like 99.99% of people don't even look, they see the test folder and think "oh, he has tests, it must be well tested :)"

Only like 5-6 people even look out of thousands

I found a hack too. You just make something kinda cool and people keep starring it

hi I'm dumb, can somebody tell me what I'm doing wrong here?

import time

status = True
count = 0

def runner():
while status:
print("penis")
global count
count += 1
time.sleep(1)


def killer():
while True:
global count
if count == 6:
global status
status = False
print("HALT")

runner()
killer()

lmao. You fuckers are what makes getting a job so hard. Have to prove you aren't a bullshitter in the interview.

you are supposed to put those functions in main and then call main()

running and killer aren't running at the same time, you know.

hint: runner and killer are not being run in parallel (your code has other problems though)

I’m going through a basic c++ book and got stuck on a simple exercise program.

Book has only covered basic variables, conditionals, and loops so far.
Using that how do you read in an integer then output it with the appropriate commas? Like read in 1274859 and output 1,274,859 or whatever. Not with some fancy printing function but algorithmically.

Only thing I can think of is retarded, figure out the max digits then for every triplet so a loop from 0-999, 1000-999000, and so on storing each chunk separately then printing with the commas... surely that’s not the intended method lol.

using python

Isn't this python? Python can't do parallel programming can it? But even so multi-threaded programs are pretty complex. You should look into race conditions and atomicity if you want to understand it.

Lisp

Okay but what if I'm trying to do it in Flask?


@app.route("/execute")
def execute():
try:
while RUN_STATUS:
do_something()
global MASTER_COUNT
MASTER_COUNT += 1
except Exception as e:
print(e)


@app.route("/kill")
def kill_process():
global RUN_STATUS
RUN_STATUS = False
return jsonify({"status": "Halted"})

tutorialspoint.com/python/python_multithreading.htm

[quote]
To spawn another thread, you need to call following method available in thread module −

thread.start_new_thread ( function, args[, kwargs] )
[/quote]

damn python is gay

import time

status = True
count = 0

def runner():
while status:
print("penis")
global count
count += 1
if count == 6:
global status
status = False
time.sleep(1)


def killer():
print("HALT")

runner()
killer()

is flask multithreaded?

If that is not preemptive multitasking, that loop is just going to keep running forever.
I don't know about snekshit, which doesn't even support real threads.

Attached: 1556458812117.png (1193x810, 817K)

What are you trying to do? killer does pretty much nothing, it's still not parallel.
In other languages you can multithread, but if you just call 2 functions they still get executed sequentially,

>Python
>multithreading

python is multithreaded, it just can't interpret code on more than one thread at a time. anyway, if flask uses threads for workers, his code should work.

All of the complication of multi-threading, with none of the advantages.
What a fucking great idea that was.

How code works, even without any parallelism. runner ends itself.

>python is multithreaded, it just can't interpret code on more than one thread at a time.

Attached: 1503545941041.jpg (1000x1000, 407K)

A friend helped me with the deck-creating function and now my program looks really nice

import random as rand

def createDeck():
c = { 0: { 1: 'Ace', 11: 'Jack', 12: "Queen", 13: "King" }, 1: [ 'Spades', 'Hearts', 'Clubs', 'Diamonds' ] }
deck = [ (f"{c[ 0 ][ num ] if num in c[ 0 ] else num} of {c[ 1 ][ type ]}") for num in range( 1, 14 ) for type in range( 0, 4 ) ]
return deck


def main():
deck = createDeck()

n = int(input("How many cards do you want in your hand?:"))

print("Your hand:", end = '\n')
for cards in range(n):
print(rand.choice(deck), end = '\n')

main()

Attached: 3.jpg (655x527, 36K)

Fuck off, stupid frogposter.

Python threading works by creating entire copies of the entire program to avoid GIL. It's not multi-threaded, it's multi-process, which is vastly different.

Illegible garbage. One-liners are not better.

i mean, if your code wastes most of its time on ffi code or io it can enjoy some parallelism. also unless you're doing some serious computation work without using external libraries i don't see how the gil will hinder you that much.

i guess "working" here means that execute() ends

uhh

but this is multiprocessing..? i mean it's true that you're better off with multiprocessing if you want better performance but multithreading exists, and it has its uses.

How would you make it readable, then?

>you're better off with multiprocessing if you want better performance
That's categorically fucking wrong. You don't understand what you're actually saying, do you?

Literally anything else.

Chinese businessman don't know bout my Nash equilibrium solver.

Attached: poker.png (1082x855, 54K)

Also pythons multithreading exists and has basically 0 uses because of the aforementioned GIL as Python is a literal garbage language

>Literally anything else
Terrible advice, you should be ashamed

better with multiprocessing on python, i mean.

Even naive for loops would be better than that nested lisp comprehension over a dictionary garbage.

Then say that and maybe even give an example instead of being a faggot with a stick up his nigger ass, faggot

Attached: 1505265118738.jpg (640x360, 34K)

>My friend helped me write illegible one-liner garbage!
>It's illegible one-liner garbage
>Yeah but how could I make it better?
>Don't make it illegible one-liner garbage
>REEE THAT'S BAD ADVICE
Are you getting the picture yet? "Literally anything else" is the correct response because then you don't have illegible one-liner garbage.

Not him.
A deck of cards is a list of integers from 0 to 51.
Shuffle the list.
Return first n elements.

What do you do with all the amateurish shit code you published on github from your beginner days?

You didn't fall for the public git meme, right?

Attached: tohru dumb.gif (500x463, 1.4M)

Nice fucking strawman uber retard
You could've avoided being a faggot by actually answering with something useful but no, you HAD to be a faggot with a 10 inch diameter pole up his blown out pozzed faggot ass

There is no turning back now that you've shown how silly you are

I've never published anything on github, afraid of the Microsoft botnet.

Fix it up or just leave it and own up to it. Nothing wrong with that in my opinion. Nobody looks at your git anyways except on the surface.

>I am a big stupid retard
That's all I heard. Calling me names isn't gunna fix the fact you couldn't write a simple double for loop to build a deck of cards on your own, and needed your friend to serve you up some "pythonic" trash.

Meh, I don't think anyone really cares. All of the relevant things people should look at are already pinned.

I leave it there. Absolutely nobody is going to do a deep-dive on your github, that's a whole fucking lot of code nobody cares about

See? another fucking strawman
I'm gonna keep replying but ONLY to have the last word and in turn piss you off like the faggot you are, faggot

I can't hear you over the sound of you not writing an incredibly simple algorithm on your own

Talk more about it. What's that?

You don't need to declare end="" in that case, do you? Legit question not criticism

His code does overcomplicate things but he is clearly learning. Why so rude?

.

I'm very depressed and lashing out anonymously makes me feel superior.

.

.

Go write some code

Attached: 1364508011124.jpg (600x688, 75K)

no

stop dotposting answer this

end is an optional named parameter to print which let's you specify the terminating character.
In this case, yes, it is unnecessary as it already has the default value \n

docs.python.org/3/library/functions.html#print

If I have a python server that is incrementing a counter, how do I use React hooks to display this counter in real-time without refreshing the page?

It's a Nash equilibrium solver for poker that displays the strategy in a GUI.
A Nash equilibrium strategy is essentially a strategy that can never lose. It can tie in theory, but against humans it will almost always win.

The algorithm can handle any game with a random element, for example in rock/paper/scisors it will come up with the strategy to play each choice with 33% probability. That strategy will always tie in the long run in that game, but since poker is more complex the opponents can make mistakes that will cost them money.

I extended the software to more than 2 players and not only Hold'em, but also 6+ and omaha.
For more than 2 players a Nash equilibrium strategy can lose money in theory, but it's very unlikelly. The algorithm distinguishes between billions of states, while a human can barelly tell a top pair from a second pair.

There is abstraction involved to some degree. No limit poker has more states than there are atoms in the universe, but it can beat humans. And I don't mean noobs, but professionals.

If you have any further questions I am here.

ask /wdg/

How hard is PHP? I know the very basic of Python and my aunt might set me up for a position in her company if I happen to know PHP. Of course I don't intend to learn it by now but will I be able to pick it up in one year when I will be more familiar with programming?

Attached: 1554649084013.png (600x726, 366K)

php causes permanent brain damage

trying to understand android MonkeyRunner...
i cant find a proper guide anywhere..
can someone bring me a more decent guide from the android joke?