TrickJarrett.com

Saturday, February 13th, 2021

« Previous Day Next Day »

There is some serious snowfall going on up here. It started coming down yesterday, and has apparently just continued to fall. It isn't sticky so the snow isn't holding to roofs and is instead accumulating on the ground.

I am working on learning Python as a programming language and getting used to it. I sat down and coded "Rock, Scissors, Paper, Lizard, Spock" - First I did the endless if, elif, else statements then decided to go for a more compact solution via a dense multidimensional array.

from random import randint

t = [["Rock",[0,-1,1,1,-1],["ties","is covered by","smashes","crushes","is thrown by"]],
   ["Paper",[1,0,-1,-1,1],["covers","ties","is cut by","is eaten by","disproves"]],
   ["Scissors",[-1,1,0,1,-1],["smashed by","cuts","ties","decapitates","is used by"]],
   ["Lizard",[-1,1,-1,0,1],["is crushed by","eats","is decapitated by","ties","poisons"]],
   ["Spock",[1,-1,1,-1,0],["throws","is disproven by","uses","is poisoned by","ties"]]]

#assing a random play to computer
computerindex = randint(0,4)

player = False;

while player == False:
   player = input("Rock, Paper, Scissors, Lizard, Spock? ")

   noresult = True
   for entry in t:
       if entry[0] == player:
           if entry[1][computerindex] > 0:
               noresult = False
               print("You win! ",player,entry[2][computerindex],t[computerindex][0])
           elif entry[1][computerindex] 
2/13/2021 1:31 pm | |
Tags: python, programming

Remote Impact.io - Remote developer jobs for companies working towards the UN's Sustainable Development Goals (remoteimpact.io)

Came across this link on Reddit to a guy's website which lists remote working jobs for companies who are working towards the Sustainable Development Goals by the UN. First off, I wasn't actually aware of these goals, but also it's cool to see. I'm not looking to be a developer, but I love this idea.

2/13/2021 1:48 pm | |
Tags: remote work, better world, programming

Simple Tic-Tac-Toe in Python

My learning of Python continued today with me coding a simple Tic-Tac-Toe client. It is very dumb, the computer always plays randomly and currently has no intelligence to it. But I wrote it from scratch with no outside resource or code segments. Doing things like this is always a great feeling for me, learning something is one of my favorite things to do.

Here is my Python code:

from random import randint

board = [1,2,3,4,5,6,7,8,9]
legalplays = [1,2,3,4,5,6,7,8,9]

def drawboard(board):
   print(board[0],"|",board[1],"|",board[2])
   print("---------")
   print(board[3],"|",board[4],"|",board[5])
   print("---------")
   print(board[6],"|",board[7],"|",board[8])


def checkboard(board):
   patterns = [[0,1,2],
               [3,4,5],
               [6,7,8],
               [0,3,6],
               [1,4,7],
               [2,5,8],
               [0,4,8],
               [2,4,6]]
   for pattern in patterns:
       if board[pattern[0]] == board[pattern[1]] and board[pattern[0]] == board[pattern[2]]:
           return board[pattern[0]]
   return 0


def computerPlay(board):
   availableplays = []
   for i in board:
       if i in legalplays:
           availableplays.append(i-1);
   moves = len(availableplays)
   move = randint(0,moves-1)
   return availableplays[move]


playfirst = randint(1,2)

if playfirst == 1:
   #Computer Plays First
   play = randint(0,8)
   board[play] = "O";

noresult = True

while noresult:
   drawboard(board)
   player = input("Choose where to put your X: ")

   if player.isnumeric():
       player = int(player) - 1
       if player 
2/13/2021 3:00 pm | |
Tags: programming, python


(It's a math joke)

Trump Acquitted In Impeachment Trial (npr.org)

Shocking. (Not.)

2/13/2021 4:32 pm | |
Tags: us politics

Astronaut (astronaut.io)

Today, you are an Astronaut. You are floating in inner space 100 miles above the surface of Earth. You peer through your window and this is what you see. You are people watching. These are fleeting moments.

These videos come from YouTube. They were uploaded in the last week and have titles like DSC 1234 and IMG 4321. They have almost zero previous views. They are unnamed, unedited, and unseen (by anyone but you).

Astronaut starts when you press GO. The video switches periodically. Click the button below the video to prevent the video from switching.

I found this site back in May of 2020, but came across it as I was looking through my Facebook archive when I shared it. It's worth sharing again as a fun diversion and escape to these small glimpses from around the world.

Added audio functionality

[{audio}]8bit.mp3[{/audio}]

Among my development work today, after messing with Python I came back home to Glowbug and added some functionality that has been on my list. I can now upload mp3s and have it generate the play functionality.

2/13/2021 6:24 pm | |
Tags: glowbug, programming

Co-Signed (twitter.com)


2/13/2021 6:25 pm | |
Tags: mcu, mcu

📧 Daily Newsletter

Get an email with the day's links and posts delivered to your inbox! Sign up here.

« Previous Day Next Day »