Thomas S
hacker

@ThomasS1 (56)
Student who programmes for fun. Uses python mainly but also HTML/CSS/JS/PHP and learning C++ to avoid the snake-haters' wrath.
A simple idle game
posted to Share by nulll

Nice work!


I can relate... except for the chromebook bit sadly!! Impressive to make this so quickly though!

██ Empty ██
posted to Share by mat1

B... b... bea... beautiful. Stop, it's making me cry.
This game has taught me more about life than... anything else... ever.

~ Knuth's MASTERMIND algorithm in Python (board game)! ~
posted to Share by ThomasS1

Upvote this comment if you'd like to see a more detailed explanation / tutorial of the code for this!

Artificial Intelligence Competition
posted to Share by lydiahallie

Currently working (with a friend) on an evolution algorithm (https://www.techopedia.com/definition/32751/evolutionary-algorithm) to solve almost any type of cipher. All you need to do is write the code that generates random keys for your type of cipher (e.g. in Vigenere, it should generate a random string of letters; in Playfair the same but with no repeated letters), as well as the decrypt function, and you're good to go! We will provide some presets (including Vigenere and Playfair). What do you think? Any ideas?

Need help with a function modification code.
posted to Ask by tracivdecker

That function all works in theory, you just need to add a ( before the s in line 8, and remove the space between the + = in line 10.

SceneMachine: Drag, configure and shoot! (SVG 2D Physics Game)
posted to Share by ggzor

Absolutely amazing. My only suggestion is that maybe we could use the keyboard a bit more, e.g. enter to start a level, right arrow for 'Continue', space to shoot? It's just a bit quicker. Otherwise perfect!

How to program MineSweeper in Python! (fully explained in depth tutorial)
posted to Learn by ThomasS1

Hi @Steve1260 , I get that question quite a bit, but sadly the solution isn't as easy as it might sound! You might want to read the chain of messages above. Basically you'd need to change a bunch of numbers and some of the lists. I might start work on a tutorial explaining how to make different difficulties... I'll keep you posted. Good luck! (if you liked the tutorial, an upvote would be really appreciated... thanks! :)

Display the largest number
posted to Ask by sharkquik

You're welcome, glad I could help, and thanks for accepting it as the answer! @sharkquik

Need help with a function modification code.
posted to Ask by tracivdecker

You're welcome! Could you mark my answer as the solution please, if you found it the post helpful? Thanks! @tracivdecker

Display the largest number
posted to Ask by sharkquik

Hi, line 19 is the issue here. z is currently just a string, and calling max() on a string returns the highest value character in the string - this is '9' here, of course.
To find the largest number, you need to first split the line into the different numbers.
The line is currently this:
119,131,139,141,85,95,13,86,133,87,70,182,77,148,191,150,180,152,26,3,185,98,25,132,11,147,29,151,4,51,74,13,193,57,36,189,195,162,126,78, (you need to remove the comma at the end of the file)
And to split it up you can just do

numList = z.split(',')

This will produce a list of the numbers:
['119', '131', '139', '141', '85', '95', '13', '86', '133', '87', '70', '182', '77', '148', '191', '150', '180', '152', '26', '3', '185', '98', '25', '132', '11', '147', '29', '151', '4', '51', '74', '13', '193', '57', '36', '189', '195', '162', '126', '78']
But these are all strings, so we can loop through the list and convert each one to an int:

intList = [int(n) for n in numList]

Then we can find the largest one:

largest = max(intList)

We can actually put this all on one line, so to fix it you can replace line 19 with this:

print("The largest number is {}".format(max([int(n) for n in z.split(',')])))

Hope that makes sense!

Conduct an Orchestra Through Vision Processing
posted to Share by burakdemirelli

@burakdemirelli Oh ok I'm on Safari so that makes sense. Maybe in a future update adding support for more browsers would be a good thing to work on?

Conduct an Orchestra Through Vision Processing
posted to Share by burakdemirelli

Cool idea and lovely graphics but... no audio?! Just me? Also the hand recognition isn't great but I can imagine that would be practically impossible to get right.

How to program MineSweeper in Python! (fully explained in depth tutorial)
posted to Learn by ThomasS1

@kieranlocke98 You'd pretty much just have to change a bunch of numbers (9s to 10s and 8s to 9s) and the printBoard() function. These are the lines you'd need to change (might have missed some, sorry); make sure you refer to my code cause the spacing of yours is probably different.

46, 48, 51, 52, 58, 74, 75, 108, 113, 123, 135, 140, 143, 147, 157, 158
All of the printBoard() function.
183, 184, 225

That should be it... I'd recommend duplicating your code before you start editing it! Good luck

How to program MineSweeper in Python! (fully explained in depth tutorial)
posted to Learn by ThomasS1

@kieranlocke98 You're welcome. Yeah, after I made this version, I tried to make one where the player could choose the grid size and how many bombs were in it, but it was much more difficult than I'd expected. Have fun playing!

How to program MineSweeper in Python! (fully explained in depth tutorial)
posted to Learn by ThomasS1

@kieranlocke98 Great, that's exactly what I need. Here are a few things to fix:

  1. Because you originally wrote your code outside of repl.it, you quite rightly didn't import the replit module in line 3. However, throughout your program you call the replit.clear() function. You need to import the os module in line 3, and change every replit.clear() line to os.system('clear'). If you're on windows, you'll need to do os.clear('cls') instead. Hope that makes sense.

  2. There seem to be 10 rows in the bombs list, b, on lines 51-55. Just remove one of the lists inside it. It's the same with the known grid, k, on lines 68-72.

  3. Lines 39-49: Presumably while moving stuff around trying to fix it, you've placed the placeBomb(b) function right in the middle of the reset() function. You should move the placeBomb(b) function elsewhere and then tabulate lines 51-80 in by a tab so that they count as part of the reset() function. To do this, select all those lines, and press the tab key once. Bear in mind that as you move stuff around, line numbers will change!

  4. Lines 214-255: Again, these are tabulated wrong, so they don't count as part of the play(b, k, startTime) function. To fix this, tabulate that whole section in by one tab. The same with lines 182-186, which should be part of the printBoard(b) function.

Those are all the syntax errors which kill the program; now for some logic errors that stop the program functioning properly:

  1. In line 25, you used .lower() to make the player's input lowercase. But then in the if function, you used uppercase letters (P and I), meaning that the program is left in a constant loop asking for a user input. So on line 25, just change .lower() to .upper().

  2. Lines 78 and 79 should both have a range of (0, 8). Although there are 9 rows and columns in b, we use 0 as our first index, so we don't need 9.

  3. Line 53: I think you just misread the tutorial: you wrote a 1 rather than an l, before the brackets.

  4. In the updateValues(rn, c, b) function, you seem to have changed all the 9s to 10s, presumably because you originally had 10 rows in your bombs list! I'd just re-copy the whole function from the tutorial into the same place. It's the same with the zeroProcedure(r, c, k, b) and printBoard(b) functions, so just re-copy them from the tutorial. But remember in the first line of the printBoard(b) function, you need to change it from replit.clear() to os.system('clear').

  5. Line 233, the line in the play(b, k, startTime) function which currently reads:
for x in range (0, 10):

should instead read:

for x in range (0, 9):
  1. In the checkZeros(k, b, r, c) function, the two lines which currently read:
for x in range (10):
    for y in range (10):

should instead read:

for x in range (9):
    for y in range (9):

And that should fix it! The actual order of the functions doesn't really matter as long as they are all tabulated correctly. Of course, make sure the very last line of your program is reset(). Hope it works for you! Have fun playing :D

Replit Module Does not Exist!
posted to Ask by HarperframeInc

This should be a fix even with multiple files: replit module fix

Please select this as the answer if it works for you! Hope it does. Thanks!

No 'replit' module
posted to Ask by Lumpy_Wiggles

Here's a fix: replit module fix

Please select this as the answer if it works for you! Thanks.

badcode
posted to Ask by rovertb

The others are right that you were missing a colon at the end of line 1, but you also have another problem: input cannot be used as a variable name as it is a reserved function name. You can change lines 5-9 to this:

base = float(input("enter base: "))
height = float(input("enter height:"))

and it should then work.

How to program MineSweeper in Python! (fully explained in depth tutorial)
posted to Learn by ThomasS1

Hi @kieranlocke98 , great to hear you're still interested. Since you're on repl.it, the easiest way is probably just to copy all your code into a python repl and then send me the link to that. No worries, it's no trouble at all!

JS (+HTML) - how to save (leaderboard) data - for music jam!
posted to Ask by ThomasS1

@JustARatherRidi @TheDrone7 don't worry, I've only been entering for fun really and the leaderboard doesn't really add much to the game itself. Also, @JustARatherRidi's suggestion worked :D so I should now be able to get the leaderboard up and running, even if not for the game jam. Thanks! Also, does anyone know if I can tick multiple replies as the answer? It's been a joint effort if you know what I mean. Thanks again for all your help!

JS (+HTML) - how to save (leaderboard) data - for music jam!
posted to Ask by ThomasS1

@TheDrone7 I'm trying this out and all seems to be going well except...

From here, my old non-express/node repl which I've gone back to. script.js, lines 279-291

... I'm getting that error! Any ideas? It seems to me that jsonstore doesn't accept requests from replit :( Please reply quickly if you can, the competition closes tonight! Thanks

JS (+HTML) - how to save (leaderboard) data - for music jam!
posted to Ask by ThomasS1

@TheDrone7 Thanks that's much simpler. I've set up the database and created a few functions to add/get rows from it, but I'm now having trouble calling those functions from public/script.js. The code is here.
At the moment I'm getting this error...

...when I load the page (that's the Safari console btw). Any ideas? Thanks

EDIT: now given up on this :( moved onto @TheDrone7 's separate reply, see below...

JS (+HTML) - how to save (leaderboard) data - for music jam!
posted to Ask by ThomasS1

@EthanJustice Sorry I didn't reply to your comment sooner; I was going to try express next, but it seems it is part of the same solution that @vedprad1 was suggesting. Thanks :) Going to look into it now.

JS (+HTML) - how to save (leaderboard) data - for music jam!
posted to Ask by ThomasS1

@katyadee Wow thanks, that would be great, but perhaps wait until I know if the alasql thing works. I've been kinda busy but I'll do some more testing tomorrow (UK time). I'll reply again if it doesn't. Thanks! :D

JS (+HTML) - how to save (leaderboard) data - for music jam!
posted to Ask by ThomasS1

@vedprad1 Hi, I've been reading through the alasql documentation and testing out various things - it's amazing! But I'm a bit confused as to how to set up a server, and get/save data from/to it...?

JS (+HTML) - how to save (leaderboard) data - for music jam!
posted to Ask by ThomasS1

@vedprad1 Thanks; I've read through and understood the 'Node.js Tutorial' bit, and I've now moved onto the 'Node.js MySQL' section, which I think is what I need for a database? I've tried running this code and, whatever user and password I give, I get an ECONNREFUSED error! Any ideas? Thanks so much for all the help so far!

JS (+HTML) - how to save (leaderboard) data - for music jam!
posted to Ask by ThomasS1

@vedprad1 Thanks, that's really helpful! But I don't know how to use node.js on an HTML/CSS/JS repl... is it possible? Thanks again for replying so quickly!

How to program MineSweeper in Python! (fully explained in depth tutorial)
posted to Learn by ThomasS1

Hi @kieranlocke98 , really glad to hear you're liking it! The source code is here: https://repl.it/@ThomasS1/MineSweeper . The exact order of the functions usually doesn't matter, so it's probably something else, but if you're still stuck, feel free to send me a link to your code and I'll have a look :D

Minesweeper (Game Jam Edition)
posted to Share by lclarkejhdf

Wow very cool. I made this https://repl.it/@ThomasS1/MineSweeper a while ago but it doesn't have the mouse-click support (which is awesome, by the way @mat1 and @lclarkejhdf ). I also really like the money element. Tried to leave an upvote but I can't vote on a closed board apparently :(
My only suggestion is that, because mac users don't have middle mouse buttons, could there be a choice of what to use to place flags (maybe middle mouse or right click)?