about tmscli
A fun little project from 2024 to see who could code faster
Philosophy
tmscli started as a fun competition to see whether python or C++ could make minesweeper faster and run smoother, now the python version has been uploaded to PyPi and can be downloaded using pip.
It is inteded to engage people into what coding can get you and should not be used to personal advantage (not sure how, but it's a must say)
Behind the scenes
tmscli is fully python and relies on random to build the minefield
lets take a look at some code
while True:
terminal_minesweeper.print_board(board)
cmd=input()
cmds=cmd.split()
if int(cmds[1])>terminal_minesweeper.size or int(cmds[1])<0 or int(cmds[2])>terminal_minesweeper.size or int(cmds[2])<0:
print('coordinate out of range, please try again')
if cmds[0]=='uc':
if (not board[int(cmds[1])-1][int(cmds[2])-1][0]) and (not board[int(cmds[1])-1][int(cmds[2])-1][1]):
board[int(cmds[1])-1][int(cmds[2])-1][0]=True
if board[int(cmds[1])-1][int(cmds[2])-1][2]==0:
board=terminal_minesweeper.richochet(board,(int(cmds[1])-1,int(cmds[2])-1))
else:
print('already uncovered')
elif cmds[0]=='fl':
if not board[int(cmds[1])-1][int(cmds[2])-1][1]:
board[int(cmds[1])-1][int(cmds[2])-1][1]=True
else:
print('already flagged')
elif cmds[0]=='uf':
if board[int(cmds[1])-1][int(cmds[2])-1][2]:
board[int(cmds[1])-1][int(cmds[2])-1][0]=False
else:
print('already not flagged')
else:
print('unrecognised command, please try again')
terminal_minesweeper.check(board)
This is a rather large chunk of code, and is what the main loop does
as you can see it has three commands, uc, fl, and uf. Each doing something different. If it does not think the input is valid, it will output what it thinks the error is. (May be inaccurate)
Github Repository
tmscli is 100% owned by a-humanly-human.
Link to Repository: https://github.com/a-humanly-human/terminal-minesweeper/