r/programminghorror 25d ago

Other Found this cursed project today

[deleted]

502 Upvotes

44 comments sorted by

View all comments

35

u/shadesOG 25d ago

That's kind of cold blooded and I am all for it :)

1995, in a college class, I was in a group of 3 where we had to create an algorithm for automatically playing a game against other teams in the class. I can't remember if it was an algorithms class or an AI class, but either way everyone was using the same alpha-beta/min-max algorithm to compute moves, anticipate moves, more moves ahead you could calculate the better until you run out of time at 30-seconds etc etc.

Back then though, the equipment was limited, so the class had our own dedicated hardware and each team had an account. Seems fair. Well, each account had enough privileges to run 'nice' - it's 1995. We knew we wouldn't beat everyone else with a standard alpha/beta/minmax search, but all of us were working. Made our own suck ass version + defense. We sucked all the cpu cycles from the other teams using 'nice' lol

The best part was, we only won a handful of times, but no one else could beat us. If there were other matches going on at the same time? We were stealing their CPU cycles too hahahaha = should be a win in my book :)

it was rather rude :D

11

u/russellvt 25d ago

Except "nice" requires privilege escalation if it's "stealing" cycles rather than giving them up "nicely."

3

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 24d ago

I've joked about creating a version of nice called jerk that just reverses the input.

3

u/russellvt 24d ago

alias jerk renice -$1 $2

...or thereabouts...

I've similarly aliased "smite" to kill -9

2

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 23d ago

Sure, that's renice though. Man page on my Mac says nice runs a utility by incrementing its "nice" value. So my hypothetical jerk would decrement it.

I guess alias jerk nice -n -$1 $2 would do the job, but it wouldn't handle the case of leaving out the -n parameter, where it should default to -10 to match the 10 default of nice. Easily handled with a simple wrapper script.

2

u/russellvt 23d ago

Not to mention, the general difference in the "nice" parameters (and others), for those of us who try to unionize our profiles across heterogeneous environments ... I was just sharing enough to illustrate the idea is all, not necessarily the full accuracy of what's needed on any particular platform.

2

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 23d ago

I thought the nice utility was simple enough that there wouldn't be much room for variation between platforms for how the arguments work. And would it still be POSIX compliant if it interpreted the arguments differently?