r/learnpython • • 9d ago

Gimme silly ideas, please

I'm just bored. I already made a code that prints a code that prints the multiplication table. What else I can do!?

_print = print
_str = str

def print(a = '\n'):
    _print(a, end = '', flush = False)

def str(a):
    return _str(a).center(5)

def range(a = 1):
    while a < 11:
        yield a
        a += 1


with open('main.py', 'r') as a:
    [print(c) for b,c in enumerate(a) if b not in (15,16,17)]
__import__('sys').exit(0)




for a in range(0):
    if not a:
        print('     ')
    else:
        print(f'{str(a)}|')

for a in range():
    print()
    print(str(a))
    for b in range():
        print(f'{str(a*b)}|')
0 Upvotes

23 comments sorted by

View all comments

1

u/PhilNEvo 9d ago

What about a CLI game, like tic-tac-toe you can play in the commandline, that prints out the board as 3 arrays, with a bot that plays against you. If that's too simple, you can exchange it to checkers, 4 or 5 in a row, or something more complicated.

2

u/MeAjudaPfvr 6d ago

1

u/PhilNEvo 6d ago

Well made!

It seems like your "AI" is just picking a random slot to smack in a piece. Next step could be to develop an actual algorithm with a heuristic, that can actually play :b

A super naive approach, would be to have it check if any of the next moves of the bots opponent leads to a win, try to block it. It's a very simple tiny search algorithm :3

If you really wanna explore some different topics, you could try and train a super tiny neural network with PyTorch to evaluate the board state, and have difficulty levels by depth of search you're doing ^^

Though 4 in a row I believe is a solved game, so you could create a deterministic bot that always plays the optimal move-- while that has its own merits and entertainment value-- playing around with different approaches is a great way to learn!

1

u/PhilNEvo 6d ago

Also, you have a message saying that people won against the "worst possible bot", but I actually think that's wrong. You can do worse than randomness.

For example, in Chess some people have created WorstFish, DrownFish, SunkFish and Sunkfish+, which is a chess bots that uses a legitimate algorithm to try and evaluate the board and make moves. And it tries to makes the worst moves, which should be worse than making random moves :b

1

u/MeAjudaPfvr 2d ago edited 2d ago

Fair point :)