Share your repls and programming experiences

← Back to all posts
I made a 21 game Vs. a computer (difficult)
Murpy (0)

This is a project that I had made on a different account that I made on my old account and transferred it here. The point of the game is to increment the number to make the other person say 21 or higher (opposite of Blackjack, you don't want 21). I made an AI that just makes moves based on what the number is. It is somewhat difficult, but possible.

Voters
Murpy (0)
Comments
hotnewtop
DynamicSquid (4899)

Cool! Just a tip though:

# all this:

def compOne():
  global compMove
  global number
  compMove = 1
  number = number + compMove

def compTwo():
  global compMove
  global number
  compMove = 2
  number = number + compMove

def compThree():
  global compMove
  global number
  compMove = 3
  number = number + compMove

# can be turned to this:

def comp(num):
  global compMove
  global number
  compMove = num
  number += compMove
Murpy (0)

@DynamicSquid Okay thanks, I appreciate all the advice since I am somewhat new to programming. I also made this a few months ago and am re-uploading it to a new account so my knowledge here is a little outdated.

DynamicSquid (4899)

@Murpy Oh no worries! It was just a suggestion :)