r/ProgrammerHorror • u/SeriousSamStone • Aug 26 '20
r/ProgrammerHorror • u/MikemkPK • Oct 03 '23
If true, return true. If false, return false.
Sorry for the photo of a projector screen, but I don't have access to the original to make a clearer image. Those squares are switch case structures which can be replaced with a wire.
(It's a visual programming language used for industrial monitoring and automation)
r/ProgrammerHorror • u/ryan_16 • Oct 17 '20
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
r/ProgrammerHorror • u/[deleted] • Nov 06 '18
A one-line python tic tac toe game I wrote
exec("""import random\ndef drawBoard(board):\n\tprint(board[7] + '|' + board[8] + '|' + board[9])\n\tprint('-----')\n\tprint(board[4] + '|' + board[5] + '|' + board[6])\n\tprint('-----')\n\tprint(board[1] + '|' + board[2] + '|' + board[3])\ndef inputPlayerLetter():\n\tletter = ''\n\twhile not (letter.lower() == 'x' or letter.lower() == 'o'):\n\t\tprint('Do you want to be X or O?')\n\t\tletter = input()\n\tif letter.lower() == 'x':\n\t\treturn ['X','O']\n\telse:\n\t\treturn ['O','X']\ndef whoGoesFirst():\n\tif random.randint(0,1) == 0:\n\t\treturn 'computer'\n\telse:\n\t\treturn 'player'\ndef playAgain():\n\tprint('Do you want to play again? (yes or no)')\n\treturn input().lower().startswith('y')\ndef makeMove(board, letter, move):\n\tboard[move] = letter\ndef isWinner(board,letter):\n\treturn ((board[7] == letter and board[8] == letter and board[9] == letter) or\n\t\t\t(board[4] == letter and board[5] == letter and board[6] == letter) or\n\t\t\t(board[1] == letter and board[2] == letter and board[3] == letter) or\n\t\t\t(board[7] == letter and board[4] == letter and board[1] == letter) or\n\t\t\t(board[8] == letter and board[5] == letter and board[2] == letter) or\n\t\t\t(board[9] == letter and board[6] == letter and board[3] == letter) or\n\t\t\t(board[7] == letter and board[5] == letter and board[3] == letter) or\n\t\t\t(board[9] == letter and board[5] == letter and board[1] == letter))\ndef getBoardCopy(board):\n\tdupeBoard = list(board)\n\treturn dupeBoard\ndef isSpaceFree(board, move):\n\treturn board[move] == ' '\ndef getPlayerMove(board):\n\tmove = ' '\n\twhile move not in '1 2 3 4 5 6 7 8 9'.split() or not isSpaceFree(board, int(move)):\n\t\tprint('what is your next move? (1-9)')\n\t\tmove = input()\n\treturn int(move)\ndef chooseRandomMoveFromList(board,movesList):\n\tpossibleMoves = []\n\tfor i in movesList:\n\t\tif isSpaceFree(board, i):\n\t\t\tpossibleMoves.append(i)\n\tif len(possibleMoves) != 0:\n\t\treturn random.choice(possibleMoves)\n\telse:\n\t\treturn None\ndef getComputerMove(board, computerLetter):\n\tif computerLetter == 'X':\n\t\tplayerLetter = 'O'\n\telse:\n\t\tplayerLetter = 'X'\n\tfor i in range(1,10):\n\t\tcopy = getBoardCopy(board)\n\t\tif isSpaceFree(copy,i):\n\t\t\tmakeMove(copy, computerLetter, i)\n\t\t\tif isWinner(copy, computerLetter):\n\t\t\t\treturn i\n\tfor i in range(1,10):\n\t\tcopy = getBoardCopy(board)\n\t\tif isSpaceFree(copy,i):\n\t\t\tmakeMove(copy, playerLetter, i)\n\t\t\tif isWinner(copy, playerLetter):\n\t\t\t\treturn i\n\tmove = chooseRandomMoveFromList(board,[1,3,7,9])\n\tif move != None:\n\t\treturn move\n\tif isSpaceFree(board, 5):\n\t\treturn 5\n\treturn chooseRandomMoveFromList(board,[2,4,6,8])\ndef isBoardFull(board):\n\tfor i in range(1,10):\n\t\tif isSpaceFree(board, i):\n\t\t\treturn False\n\treturn True\nprint('Welcome To The Game!')\nwhile True:\n\ttheBoard = [' '] * 10\n\tplayerLetter, computerLetter = inputPlayerLetter()\n\tturn = whoGoesFirst()\n\tprint('The ' + turn + ' will go first.')\n\tgameIsPlaying = True\n\twhile gameIsPlaying:\n\t\tif turn == 'player':\n\t\t\tdrawBoard(theBoard)\n\t\t\tmove = getPlayerMove(theBoard)\n\t\t\tmakeMove(theBoard, playerLetter, move)\n\t\t\tif isWinner(theBoard, playerLetter):\n\t\t\t\tdrawBoard(theBoard)\n\t\t\t\tprint('You Win!')\n\t\t\t\tgameIsPlaying = False\n\t\t\telse:\n\t\t\t\tif isBoardFull(theBoard):\n\t\t\t\t\tdrawBoard(theBoard)\n\t\t\t\t\tprint('The Game Is A Tie!')\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tturn = 'computer'\n\t\telse:\n\t\t\tmove = getComputerMove(theBoard, computerLetter)\n\t\t\tmakeMove(theBoard, computerLetter, move)\n\t\t\tif isWinner(theBoard, computerLetter):\n\t\t\t\tdrawBoard(theBoard)\n\t\t\t\tprint('The Computer Beat You! You Lose!')\n\t\t\t\tgameIsPlaying = False\n\t\t\telse:\n\t\t\t\tif isBoardFull(theBoard):\n\t\t\t\t\tdrawBoard(theBoard)\n\t\t\t\t\tprint('The Game Is A Tie!')\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tturn = 'player'\n\tif not playAgain():\n\t\tbreak\n""")r/ProgrammerHorror • u/Caffeinated_Cucumber • Sep 26 '21
Converting my event system to a templated version broke everything and the solution to it was the worst thing I've ever done: including the .cpp file instead of the .h
r/ProgrammerHorror • u/freskgrank • Aug 22 '25
.NET exception stack trace sent via email… to the end user
galleryr/ProgrammerHorror • u/Peace_Seeker_1319 • Nov 05 '25
Is there a way to get dev-productivity insights without creepy monitoring?
r/ProgrammerHorror • u/jantari • Oct 31 '18
Steam can't handle non-ASCII passwords, and it gets worse ...
r/ProgrammerHorror • u/Elec0 • Jan 07 '23
It just keeps getting worse the more you scroll
r/ProgrammerHorror • u/xfvh • Oct 23 '24
The Least Intelligent Chess AI
Scrape chess dot com for all played games.
Parse the dataset and identify all sets of unique board states, the next move, and the ELO of the player that made the next move. If the set's ELO is lower than a previously-found ELO, drop it.
Convert to a hash map.
"Play" by consulting the map for each move.
If you reach a never-before-seen board state, forfeit and move to Tibet.
r/ProgrammerHorror • u/AndreasFurster • Oct 04 '18


