Jump to content
  • entries
    2
  • comments
    23
  • views
    445

Save System for Game



def lsave():
    path = input("Welcome Back! Path to your save file?\n\n        [SAVE] ")
    sfile = open(path, "r")
    save = sfile.read()
    sfile.close()
    return(parse(save))

#  Save List Syntax:
#  name, zone, map, location, equipped items, all items, path/to/file
def parse(save):
    lists = save.rstrip().rsplit("\n")
    final = []
    final.append(lists[9].split(";")[0])
    final.append(lists[0].split(" ")[1])
    final.append([])
    for i in range(1, 8):
        final[-1].append(lists[i].split("|"))
    final.append(lists[9][-4:].split(", "))
    final.append([lists[11].split(", ")[0][16:]])
    for i in lists[11].split(", ")[1:]:
        final[-1].append(i)
    final.append([lists[13].split(", ")[0][11:]])
    for i in lists[13].split(", ")[1:]:
        final[-1].append(i)
    final.append(lists[-1])
    final[1:]
    return(final)
def csave():

    print("Name your character!\n")
    name = input("        [SAVE] ").split(" ")
    if not "CSWrath" in name:
        print(f"\n\nWelcome, {" ".join(name)}! I probably could have named a better character.\n")
    else:
        print("\n\nWell, that's something.\n")
    print("Define the path to your save file.\n")
    path = input("        [SAVE] ")
    defaultSave = f"""Map: Forest
P|X|X|X|X|X|X
X|X|X|X|X|X|X
X|X|X|X|X|X|X
X|X|X|X|X|X|X
X|X|X|X|X|X|X
X|X|X|X|X|X|X
X|X|X|X|X|X|X

{"|".join(name)}; 0, 0

Equipped Items: Rag, Simple Blade, 3, Empty

All Items: Rag, Simple Blade
{path}
"""
    print("\n\nThanks! Creating File Now.")
    sfile = open(path, "w")
    sfile.write(defaultSave)
    return(parse(defaultSave))
def getsave():

    print("Welcome to the Twisted Forest!\n\n  ! Choose \"Load Save\" or \"Create Save\" !")
    valid = False
    while valid == False:

        action = input("\n        [SAVE] ")
        print("\n\nThank you! Redirecting now.\n")
        if action.rstrip().lower() == "load save":
            return(lsave())
        if action.rstrip().lower() == "create save":
            return(csave())
        print("Incorrect Input. Try spelling.\n")

def save(s):
    superstring = "Map: "
    superstring += s[1]
    superstring += "\n"
    for i in s[2]:
        for j in i:
            superstring += j
            superstring += "|"
        superstring += "\n"
    superstring += "\n"
    superstring += f"{s[0]}; {s[3][0]}, {s[3][1]}\n\nEqquiped Items: "
    for i in s[4]:
        superstring += f"{i}, "
    superstring = superstring[:-2]
    superstring += "\n\nAll Items: "
    for i in s[5]:
        superstring += f"{i}, "
    superstring = superstring[:-2]
    superstring += f"\n{s[-1]}\n"

 

A saving system I made. I think I got all the bugs, but if I didn't...

yall know what bugs actually are?

features

16 Comments


Recommended Comments

Through the Living Shadow

Posted

Okay there was one more bug but I fixed it

Lsave was before parse in the code, which is fine in most cases, but if I call Lsave directly...

KaladinsSenseOfHumourSpren

Posted

Can't actually run this now, my current computer doesn't have Python :(

But really cool!

Are familiar with classes? Have you used numpy?

Through the Living Shadow

Posted (edited)

Yes, but not in Python (I know them more in Java, but I'm rusty). I'm always intimidated by the terrible syntax. 

No. What is it?

 

*le gasp?*

 

No python3.exe .\saving.py? (Or ./saving.py if you're civilized)

its okay this doesn't actually run anything, you'd need to add a "getsave()" line at the end.

Edited by SpiritOfWrath
KaladinsSenseOfHumourSpren

Posted

It's a really popular library

Add it with

import numpy

Most people use

import numpy as np

So you don't have to type out numpy every time you want to use it

It adds a bunch of cool stuff, like actual arrays, which are way faster than lists. Also has random built-in, and has a whole bunch of maths functions.

Usseewa

Posted

On 12/22/2025 at 11:54 PM, SpiritOfWrath said:

rusty

Rust hehe

 

Quote
if action.rstrip().lower() == "load save":
    return(lsave())
if action.rstrip().lower() == "create save":
    return(csave())

u could use switch (or elif) here. Also it would be easier to replace w/numbers. Like prompt with:

Choose an option:

1 - Load Save

2 - Create Save

3 - Cancel (or something)

On 12/23/2025 at 12:07 AM, KaladinsSenseOfHumourSpren said:

So you don't have to type out numpy every time you want to use it

It adds a bunch of cool stuff, like actual arrays, which are way faster than lists. Also has random built-in, and has a whole bunch of maths functions.

I used numpy a few times but ehhh i didnt rlly know what else it did.

mainly just used it for processing (and failing to do so) a list with like millions of values.

 

Also u remind me of someone....

 

 

KaladinsSenseOfHumourSpren

Posted (edited)

4 minutes ago, Usseewa said:

Rust hehe

 

u could use switch (or elif) here. Also it would be easier to replace w/numbers. Like prompt with:

Choose an option:

1 - Load Save

2 - Create Save

3 - Cancel (or something)

I used numpy a few times but ehhh i didnt rlly know what else it did.

mainly just used it for processing (and failing to do so) a list with like millions of values.

 

Also u remind me of someone....

 

 

I used numpy to make a digit recognition AI once

Didn't work well, of course, since I was using the Darwinian method

Who?

Edited by KaladinsSenseOfHumourSpren
Through the Living Shadow

Posted

4 minutes ago, Usseewa said:

Rust hehe

 

u could use switch (or elif) here. Also it would be easier to replace w/numbers. Like prompt with:

Choose an option:

1 - Load Save

2 - Create Save

3 - Cancel (or something)

I used numpy a few times but ehhh i didnt rlly know what else it did.

mainly just used it for processing (and failing to do so) a list with like millions of values.

 

Also u remind me of someone....

 

 

Did you just....... quote a single word?

Usseewa

Posted (edited)

4 minutes ago, KaladinsSenseOfHumourSpren said:

I used numpy to make a digit recognition AI once

Didn't work well, of course, since I was using the Darwinian method

y u keep talkin' bout that Darwin crem

i gotta look dat up ig

ive never done anything related to "ai" or the thing with the thing if you know what i mean

also did u listen to IRIS OUT yet? U should listen to LOSER too. Do u know all the keyboard shortcuts? U know how u can do ctrl(or cmd ig)+enter to send an email? u can also do it to post smth on the Shard. equiveltn of lciking "post" or "update" or whatever (how did i just spell that word correctly from pressing keys fast and wierdly?)

anyway is dawrninian thing just like with the random traits and the genes or parents and evolving like all those yt videos where they make the ai thing play the game and get better?

3 minutes ago, SpiritOfWrath said:

Did you just....... quote a single word?

OHHHHH I forgot on this forum ppl associate "Rust" with the Mistborn curse. I was talking about the programming language (#rewritethecosmereinrust)

also yes. yes i did.

Edited by Usseewa
Through the Living Shadow

Posted

2 minutes ago, Usseewa said:

OHHHHH I forgot on this forum ppl associate "Rust" with the Mistborn curse. I was talking about the programming language (#rewritethecosmereinrust)

also yes. yes i did.

I registered it as both at once

😎

Usseewa

Posted

2 minutes ago, SpiritOfWrath said:

I registered it as both at once

😎

oh good

thats a good sign

KaladinsSenseOfHumourSpren

Posted

5 minutes ago, SpiritOfWrath said:

Did you just....... quote a single word?

You can select some text, then there's an option to quote selection

2 minutes ago, Usseewa said:

or the thing with the thing if you know what i mean

I don't know what you mean

3 minutes ago, Usseewa said:

anyway is dawrninian thing just like with the random traits and the genes or parents and evolving like all those yt videos where they make the ai thing play the game and get better?

Those videos use proper ML, which involves a lot of calculus I don't have.

The Darwinian method is far slower. How it works is, I randomly generate a bunch of garbage AIs, pick the best ones, replace all the others with mutated clones, and repeat. It takes a very long time to get anywhere though. I left my 2028 AIs running for like several hours and the best never got past 256. Of course, I was 10 when I did that and I could probably implement it better, but you get what I mean.

6 minutes ago, Usseewa said:

 

also did u listen to IRIS OUT yet? U should listen to LOSER too. Do u know all the keyboard shortcuts? U know how u can do ctrl(or cmd ig)+enter to send an email? u can also do it to post smth on the Shard. equiveltn of lciking "post" or "update" or whatever (how did i just spell that word correctly from pressing keys fast and wierdly?)

Not yet, don't have the time.

Through the Living Shadow

Posted

2 minutes ago, KaladinsSenseOfHumourSpren said:

ou can select some text, then there's an option to quote selection

Also, Wrath is the bestest person there ever was. And if you doubted someone could get pinged within a quote, watch this (glorious leader):

4 minutes ago, Usseewa said:

oh good

thats a good sign

Wrath is awesome

 

I know. But one word is........ ??!!!

 

Thank you, for these truthful admissions.

Usseewa

Posted (edited)

5 minutes ago, KaladinsSenseOfHumourSpren said:

You can select some text, then there's an option to quote selection

I don't know what you mean

Those videos use proper ML, which involves a lot of calculus I don't have.

The Darwinian method is far slower. How it works is, I randomly generate a bunch of garbage AIs, pick the best ones, replace all the others with mutated clones, and repeat. It takes a very long time to get anywhere though. I left my 2028 AIs running for like several hours and the best never got past 256. Of course, I was 10 when I did that and I could probably implement it better, but you get what I mean.

Not yet, don't have the time.

i dont get why pp lcdont d=listen to dosng simmediatnlylike imaybetheats jst me cuz if i get ia song rec itsgotta be inagenra o]ilike

i guess i get it yeah

5 minutes ago, KaladinsSenseOfHumourSpren said:

Of course, I was 10 when I did that and I could probably implement it better

bro real

5 minutes ago, KaladinsSenseOfHumourSpren said:

I don't know what you mean

like this:

Spoiler

 

1 minute ago, SpiritOfWrath said:

I know. But one word is........ ??!!!

 

Thank you, for these truthful admissions.

huh iut workde

Spoiler

image.thumb.png.ff0e96adb7285bf92c906508708f030f.png

 

Edited by Usseewa
Through the Living Shadow

Posted

3 minutes ago, Usseewa said:

i dont get why pp lcdont d=listen to dosng simmediatnlylike imaybetheats jst me cuz if i get ia song rec itsgotta be inagenra o]ilike

i guess i get it yeah

bro real

like this:

  Reveal hidden contents

 

huh iut workde

  Hide contents

image.thumb.png.ff0e96adb7285bf92c906508708f030f.png

 

And sometimes its really annoying because i get shadow quoted when they arent actually quoting me, just quoting a snippet of someone elses post that quoted me and I am not relevant to the conversation at all.

Usseewa

Posted

Quote

i dont get why pp lcdont d=listen to dosng simmediatnlylike imaybetheats jst me cuz if i get ia song rec itsgotta be inagenra o]ilike

what did i write lol

2 minutes ago, SpiritOfWrath said:

And sometimes its really annoying because i get shadow quoted when they arent actually quoting me, just quoting a snippet of someone elses post that quoted me and I am not relevant to the conversation at all.

idk if that e'er happened to me

KaladinsSenseOfHumourSpren

Posted

5 hours ago, Usseewa said:

i dont get why pp lcdont d=listen to dosng simmediatnlylike imaybetheats jst me cuz if i get ia song rec itsgotta be inagenra o]ilike

i guess i get it yeah

bro real

like this:

  Hide contents

 

huh iut workde

  Reveal hidden contents

image.thumb.png.ff0e96adb7285bf92c906508708f030f.png

 

Uh yeah that's basically what I'm doing

Though for something like Flappy Bird it's super simple so not really hard

In fact you don't even need an AI just a simple program is enough.

5 hours ago, SpiritOfWrath said:

I know. But one word is........ ??!!!

 

Thank you, for these truthful admissions.

-_-

×
×
  • Create New...