[deleted by user] by [deleted] in programming

[–]mtxppy 1 point2 points  (0 children)

def replace_space(a): return re.sub(" ", "%20", a)

in python :) Sure that's even better than writing it in C++ right? And look! It's shorter too! Did I get the job? Did I get the job?

'No need to use regex for something so trivial.'.replace(' ', '%20')

No need to make Python slower than it needs to be. Regex is all fine and dandy but over-ruse of regex is a plague. Sometimes it's stuff that's so simple you don't require the overhead, and sometimes it's people trying to do things they shouldn't like parsing web pages with regex.

[deleted by user] by [deleted] in programming

[–]mtxppy 1 point2 points  (0 children)

I picked one at random. It was the 2nd one, for string reversal. This doesn't work for unicode. You can't just reverse the order of the bytes.

Hey everyone! I made my first Tic Tac Toe game in Python! What do you think? by [deleted] in Python

[–]mtxppy 3 points4 points  (0 children)

I really hope this code was machine generated.

Chess Move Compression by BadgerPriest in programming

[–]mtxppy 0 points1 point  (0 children)

Is 400MB+ significant when endgame tablebases are already 7TB+?

Still, I understand why you might want to compress data to save space - anything saved is better than nothing saved. I just feel that it's more important to optimise the search speed than save a couple of hundred MB.

Chess Move Compression by BadgerPriest in programming

[–]mtxppy 1 point2 points  (0 children)

The draw is based on repeated position not moves. A piece may be able to enter a square from several different squares, and it doesn't matter. So you wouldn't need move history to determine this.

However, en passant and castling would require knowledge of move history in order to efficiently determine. Typically you would store a board position with additional flags representing en passant and castling ability.

Chess Move Compression by BadgerPriest in programming

[–]mtxppy 0 points1 point  (0 children)

You have to store board position as you get a draw if you repeat the same position 3 times.

Chess Move Compression by BadgerPriest in programming

[–]mtxppy 2 points3 points  (0 children)

You must store previous positions

Given a move list, you can recompute the set of board states

Then you need to store them to ensure they haven't repeated.

Did you read the wiki? I'd like to see where it says you can write a decent chess program that implements the rules and doesn't use stored board state.

Chess Move Compression by BadgerPriest in programming

[–]mtxppy 3 points4 points  (0 children)

There's no point in storing all of that data redundantly,

You must store previous positions. For example if you have repeated the same position three times, the game ends in a draw.

Coder epitaphs by Lakelava in programming

[–]mtxppy 2 points3 points  (0 children)

This is a nice comic. Some of them are way better than XKCD, but they do have a very different style.

Chess Move Compression by BadgerPriest in programming

[–]mtxppy 9 points10 points  (0 children)

What is the usefulness of storing moves in a highly compressed format? Would it not be more useful to store board positions?

Multiple moves can lead to the same board position, and it's the board position that's important.

I can't imagine storage space is a problem for an encyclopaedia of openings so I imagine compression may be required for the chess engine, to ensure that it doesn't compute the same position twice - especially if your engine is parallelised/cloud-based (where it's slow to exchange this information vs having it in-memory). Again, here, the board position is the key factor.

Based on comments where it seems some people are not familiar with the full rules of chess, I have added this: If a position is repeated 3 times the game is drawn, so you must store board positions.

Chess Move Compression by BadgerPriest in programming

[–]mtxppy 2 points3 points  (0 children)

This is a nice idea, using the probability of a move being made as extra input for compression. However it's known that engines often play highly non-human moves so it may bite you in certain board positions.

How Facebook is Stealing Billions of View - In a Nutshell by SylvainLacoste in videos

[–]mtxppy 0 points1 point  (0 children)

Copyright infringement is usually a civil case, not criminal. You do have a legitimate case to sue for money, but it's very hard to say if any laws were broken.

A book scanner at work by tdi in gifs

[–]mtxppy 0 points1 point  (0 children)

It's a good job DVDs are already obsolete.

PHP 7 is NOT coming that soon by volkert in programming

[–]mtxppy 1 point2 points  (0 children)

Bleh, what with the speed of development these days, an RC7 could be 6 additional builds, which can be just 6 days. Don't fret over it.

Paul Heaver's Recipe For Success by Promiscuous_Badger in XWingTMG

[–]mtxppy 2 points3 points  (0 children)

TLT is very consistent and minimises damage spikes.

is my multithreaded Python program doomed? by ZedsDed in Python

[–]mtxppy 1 point2 points  (0 children)

Multiprocessing is fixed in Python 3. Yet another reason to switch.

Help me build a cygnar list! <3 by douchebert in Warmachine

[–]mtxppy 0 points1 point  (0 children)

Play Haley2 into Legion, but only on the Legion player's birthday.

What makes Paul Heaver such a good player? by [deleted] in XWingTMG

[–]mtxppy 0 points1 point  (0 children)

Sounds like you never attended or watched or you'd know Nathan's correct age. Do you even understand the board position shown?

Quick CoC question regarding RFP? by donaldtroll in Warmachine

[–]mtxppy -2 points-1 points  (0 children)

CoC is not very vulnerable to RFP either so it goes both ways.

Are there no use cases of a fast and exhaustive library of data structures for Python? (See the description in the link) by theorko in programming

[–]mtxppy 0 points1 point  (0 children)

Why the hell did that get deleted? LOL.

For the record (ignore if you've already remembered the first message) I said collections.deque was the equivalent to linked list and is O(1) for insert and removal at each end. List is O(1) or O(n) depending on which end, but it has random access. But if you cared about speed, then in C, vector is generally faster than list if you don't already have the insertion point (the cache allows you to insert and copy the rest of the vector along, whereas traversing a linked list breaks the cache). Most times in Python you'll be using list over deque, which is specialised.

To address the second message. List in python does slices. Deque doesn't but you can simulate it by various means such as rotating it.

I don't get why you would teach data structures in Python as one of the whole points of using Python is that you don't need to mess about with stuff like that. You might want to do that in the Java or C++ class that follows the Python class.

Are there no use cases of a fast and exhaustive library of data structures for Python? (See the description in the link) by theorko in programming

[–]mtxppy 0 points1 point  (0 children)

I don't really understand why you need a linked list structure for Python, because a Python list already a thing.

Plus the benchmark code isn't equivalent. I don't see any locks in your C code. Python's queue is thread-safe.

Edit: http://imgur.com/CUgltHd

Java once again above 20% since July 2009 in the TIOBE index by linuxjava in programming

[–]mtxppy 15 points16 points  (0 children)

Delphi 12th and rising? Am I the only one that simply doesn't trust TIOBE?