Welcome! | Log In
FOREST SERVER | Year: 147 Era: 17

HGG Community Forums

Any Programmer's Here? (Found a way for everyone to try it out!) - Hunt and Jump 2 - Forum
Log In to HorseGeneticsGame
Members log in here:
Username:
Password:

By hitting the above you signify that you agree with our rules and conditions.
Forgot your password?
HGG Community Forums

Join our discord server!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Any Programmer's Here? (Found a way for everyone to try it out!)
  • https://onlinegdb.com/BJPhzf1QL


    I'm taking a computer science class and we are learning to code in Python. I'm a super super beginner programmer, and I started with Matlab last semester and this is my first Python program. I bit off more than I could chew because I wanted to impress the teacher. Oops. But thankfully even though my Dad hasn't ever programmed in Python specifically he does know close to 50 languages so he was able to give me a few hints. Anyhoo.... We are making a "gamebook" as our first assignment. For (any?) of you that can understand this, or have something to run it on, what do you think? (Please ignore all of the newbie programmer nonsense there is)



    (Going to try and comment my code because it's too long to be submitted in one entry)
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • print("Hello player, your goal is to earn 100 gold pieces")
    def ocean_a_1(gold,skillz,deer,fish):
    #I had wanted to make it so that you could only go back to the shore to search for a fising pole after you had already been to the ocean on the raft.
    #Then I thought about making it so that if you had above a certain skillset then you could have the fishing pole as an option. Which, actually, is what I
    #think I want to do. But I still don't know how I would do that. I tried to make a slight variation of the ocean_1 based on your skillset but that just blew
    #up the entire program
    ocean_a_1_options= input("\nCongrats! You stole a raft and are now randomly floating in the ocean.\ntype(return) to go back to the shoreline.\ntype(float) to float here randomly :\n\n")
    {
    "return": ocean_1,
    "float": ocean_a_2
    }.get(ocean_a_1_options, invalid_entry)(gold,skillz,deer,fish)
    return gold,skillz,deer,fish

    def ocean_b_1(gold,skillz,deer,fish):
    print("\nUh-Oh I don't think that Dude is happy you stole his boat!")
    # would like to include a 50% chance of death here. Maybe weighted by current skill
    #Or... we are supposed to include a numerical input from the user at least once, so we could play the lucky number game. Problem is I don't want
    #them to learn what the good survival numbers are if they play long enough. So somehow would need to make it random.
    #Maybe something like rand(1)*(1+(skillz/100)). And if they had a score of less than .5 they would die and more than that and they would live.
    #Still ahve the problem that I need to have at least one numeric input for one of my decision points.
    ocean_b_1_options= input("\nSo... the dude with the boat mighta killed ya.\n type (continue) to keep trying\n\n")
    {
    "continue": player_death
    }.get(ocean_b_1_options, invalid_entry)(gold,skillz,deer,fish)


    def ocean_a_2(gold,skillz,deer,fish): print("\nOh great, Now you have sunburn. Good job dude")
    def town_a_1(gold,skillz,deer,fish):
    skillz = skillz + 3
    town_a_1_options= input("You are at the merchant's place\ntype (sell) to sell all of your inventory.\ntype (work) to ask the merchant for work.\ntype (return) to return to the town :\n")
    {
    "sell": town_a_2,
    "work": not_yet_implemented,
    "return": town_1
    }.get(town_a_1_options, invalid_entry)(gold,skillz,deer,fish)

    def town_a_2(gold,skillz,deer,fish):
    gold = ((deer * 30) + (fish * 3))*(1+(skillz/100))
    skillz = skillz + 30
    fish = 0
    deer = 0
    #Somehow need to make an exit for the game here if the player reaches the 100 gold
    #In reality I should probably check to see if the player even has any inventory, although really if inventory is =0 then they will just get no money
    town_a_2_options= input("\nCongrats! You have sold of your inventory and turned it into gold\ntype (return) to return to the town:\n\n")
    {
    "return": town_1
    }.get(town_a_2_options, invalid_entry)(gold,skillz,deer,fish)
    def town_a_2_options(gold,skillz,deer,fish): print("\nThis is the bar. Eventually you will waste money here")
    def town_b_1(gold,skillz,deer,fish): print("\nThis is the bar. Eventually you will waste money here")

    def forest_a_1(gold,skillz,deer,fish):
    skillz = skillz + 1
    forest_a_1_options= input("\nSo you headed deeper into the forest....\nYou see evidence of a horse and a deer. But's its also getting cold outsie.\ntype (horse) to try and tame the horse.\ntype (deer) to try and hunt the deer. \ntype (fire) to try and make a fire.\ntype (return) to head back out to the edge of the forest. :\n\n")
    {
    "horse": forest_a_3,
    "deer": forest_a_2,
    "fire": forest_b_1,
    "return": forest_1
    }.get(forest_a_1_options, invalid_entry)(gold,skillz,deer,fish)

    def forest_a_2(gold,skillz,deer,fish):
    forest_a_2options= input("Eventually I will have more options here. But for now, just say (continue) to hunt the deer :\n")
    {
    "continue": forest_a_2_1
    }.get(forest_a_2options, invalid_entry)(gold,skillz,deer,fish)

    def forest_a_2_1(gold,skillz,deer,fish):
    deer = deer + 1
    skillz = skillz + 30
    #Eventually I don't want to make it guaranteed you will get the deer. However you will have a greater chance of getting the deer if you have skills.
    # And you gain massive skills just by trying to hunt the deer.
    forest_a_2_1options= input("Okay. So you caught the deer.\ntype (return) to start leaving the forest :\n")
    {
    "return": forest_1
    }.get(forest_a_2_1options, invalid_entry)(gold,skillz,deer,fish)


    def forest_a_3(gold,skillz,deer,fish): print("\nThis is where you start talking about taming the horse\n")
    def forest_b_1(gold,skillz,deer,fish): print("\nEventually I will talk about the stupidity of making a fire here\n")

    def player_death(gold,skillz,deer,fish):
    skillz = skillz + 1
    print("Oh, by the way... You died. No worries. You get to start again. Skills intact, but no inventory")
    #Don't know if I want to keep the fact that there are "skills" from the player or not. I think it might be more fun as a hidden thing
    gold = 0
    skillz = skillz
    deer = 0
    fish = 0
    choice_2(gold,skillz,deer,fish)

    def forest_1(gold,skillz,deer,fish):
    skillz = skillz + 1
    forest_1_options= input("\nCongrats! You are now at the edge of the forest\ntype (hunt) to go hunting.\ntype (fire) to make a fire\ntype (return) to the beginning :\n\n")
    {
    "hunt": forest_a_1,
    "return": choice_2,
    "fire": forest_b_1
    }.get(forest_1_options, invalid_entry)(gold,skillz,deer,fish)

    def town_1(gold,skillz,deer,fish):
    skillz = skillz + 1
    town_1_options= input("\nCongrats! You are now at the edge of town\ntype (return) to go back\ntype (merchant) to talk to the merchant\ntype (bar) to go to the bar :\n\n")
    {
    "merchant": town_a_1,
    "return": choice_2,
    "bar": town_b_1
    }.get(town_1_options, invalid_entry)(gold,skillz,deer,fish)

    def not_yet_implemented(gold,skillz,deer,fish): print("\nThis option under development.:(")
    def invalid_entry(gold,skillz,deer,fish): print("\nInvalid entry please try again.")

    def ocean_1(gold,skillz,deer,fish):
    skillz = skillz + 1
    ocean_1_options= input("\nCongrats! You are now at the ocean's shore\ntype (return) to go back\ntype (raft) to steal a raft\ntype (boat) to steal a boat :\n\n")
    {
    "raft": ocean_a_1,
    "return": not_yet_implemented,
    "boat": ocean_b_1
    }.get(ocean_1_options, invalid_entry)(gold,skillz,deer,fish)


    def choice_2(gold,skillz,deer,fish):
    print("gold =",gold,"skillz =",skillz,"deer =",deer,"fish =", fish)
    beginningQuestion= input("Would you like to go to the forest, town, or the ocean? :\n")
    {
    "forest": forest_1,
    "town": town_1,
    "ocean": ocean_1
    }.get(beginningQuestion, invalid_entry)(gold,skillz,deer,fish)


    def choice_1():
    gold = 0
    skillz = 0
    fish = 0
    deer = 0
    print("gold =",gold,"skillz =",skillz,"deer =",deer,"fish =", fish)
    beginningQuestion= input("Would you like to go to the forest, town, or the ocean? :\n")
    {
    "forest": forest_1,
    "town": town_1,
    "ocean": ocean_1
    }.get(beginningQuestion, invalid_entry)(gold,skillz,deer,fish)

    choice_1()
    #How do I get all of the invalid entry responses to re-ask the previous question?
    Breeder of any and all crazy colored drafts and RH horses.
    15552
    Thanked by 1FollysFantasies
  • Well. None of the formatting stayed. But that's ok. I just am super proud of myself. Been working until midnight and had to share somewhere!

    (Don't mind my comments! They are just there for when its a reasonable hour of the day and I can ask either my Dad or brother in law)
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • Your degree in super geekiness is secured, though! See if you can code a 100HB bonus for everyone! :P
    image
  • Haha! That would be awesome. I have no idea what language Ammit has programmed the sites in.

    I am actually really surprised with how much fun I have found coding. I honestly did NOT want to follow in my Dad's footsteps. I can't even say how many times we tried. But he's the kind of person that knows a lot, but can't teach. Like can't teach to save his life. We tried to build an app forsomething my high school and community college were doing in partnership but he would do a bunch of complicated stuff for 3-4 hours. Way too long to start off for me. Then would leave for the bathroom and say that he wanted me to change something by the time he came back. But for some reason I had some fear of "Dad's computer" OMG. One he spent a bunch of money on and built himself etc. So long story short. Never learned.

    Then last semester I was in mechanical engineering classes but switched my computer science for engineers class to first semester instead of this semester and I found it super duper easy. The lab was a little bit harder and again Dad either would talk too complicated or just do it for me himself. Haha. So that didn't work. I'm super glad that i found out that my brother in law coded. He hadn't done Matlab in years but he figured it out and was good at teaching. And with python I have just taken off. It is so awesome. And it's a lot easier learning the second language. (not that I would in any shape or form of the word say I have even 10% learned Matlab, but you know!). So with a quick question from Creighton or Google and I have skyrocketed. I did have my code in "if" statements but Dad suggested what I did do. I admit it seems better. Although creighton was like "why would you do that?". So IDK.

    Sorry. Probably way more complicated than anyone wanted. But super excited. I wish there was a good way to show was my little program did though. I think it's twice as long now as it was last night! I was having so much fun I programmed until 2AM. Then slept until 10.
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • Oh man.... Now my brother in law disagree. So now what do I do? I in all honesty trust my Dad more as he actually is world class programmer, and Creighton just does some programming. But still. Creighton is the one that has been able to help me more.....

    Creighton doesn't like how I set up a "dictionary" he says its awkward (and no.... I don't fully understand what a dictionary is in this context). But at the same time my massive if statement were taking up a lot of room.. And was chaos because sometimes my functions are called out of order.
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • Ammit probably programs in Egyptian


    image
    image
  • Hahaha! That's awesome.
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • I think I totally bit off more than I could chew. I've been working on it literally all day and I don't really feel any closer to completion. But I'm also having lots of fun.
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • Woohoo! All done. I just need to figure out an exit at the merchant's. I used to know how to do that, but on the outer layer Dad helped me put an invalid entry thing that returns to previous questions, but I wasn't able to replicate it on the inner layers, and now I have no way to let the player exit once they win! lol.
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • Woo! 700 lines of code and a small amount of heartache its done! Only took 24 hours +. But oh well.
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • Good job.
    45120
  • Thank you! It was so rewarding to watch my friend play it.


    I don't know if it will work the same. But found an online compiler if anyone wanted to try the game

    https://onlinegdb.com/BJPhzf1QL
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • I tried it! Good work, it reminds me of a text-based survival game I play regularly that has the extremely original name "Survive". :))
    ~*~ Justa ~*~
    Main ID# 44842 Alt ID# 54460
    Chronic sufferer of shiny pony syndrome breeding all shades and sizes of Dun. If I can help you with anything, drop me a PM! :)
    she/her
  • Thank you!

    That's awesome! I think something similar was the teacher's source of inspiration
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • It's kind of like the old school Dungeons and Dragons 'choose your own adventure' books from TSR, too. They were usually kind of short novels where you had to make choices along the way, flipping to different pages to continue reading and find out what your choices did to the course of the story. Sometimes you died, other times you would get the girl (they were mostly targeted at teenaged boys lol) or find the treasure or whatever. That kind of interactive novel has recently been released on Google Play as a game, acting as if it's something new, but I'm old and geeky and I remember buying CYOA novels. I mowed lawns in the early eighties to build my collection. :D
    ~*~ Justa ~*~
    Main ID# 44842 Alt ID# 54460
    Chronic sufferer of shiny pony syndrome breeding all shades and sizes of Dun. If I can help you with anything, drop me a PM! :)
    she/her
  • Oh that's cool, I used to love text based games. My favourite was Hitchhiker Guide to the Galaxy, but there was quite a few around at the time! Infocom I think it was from that I got a whole disk of them years later! Zork was another I think
  • One time at my step Mom's film festival we showed a movie that was a choose your own adventure. We let the audience choose which decision they wanted. It was awesome

    When I was a kid I wanted to make a big scale choose your own adventure. Like each book is a different alt ending.
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • You both just inspired me! I've just been working on the code so far. Haven't had time to focus on the story. But there's nothing limiting me from making it as long a story as I want at each decision point. Problem is.... this is due tomorrow and I haven't gotten around to other homework. Ooops.....

    So, I think I am going to run a giveaway where I ask for help with the alt. endings.... Mwahahaha. Here's a sneak preview until I get the giveaway up and running.

    1st. In one alt. ending I have you die while capturing the horse? I mean from a horse person's point of view - "What the heck?". So maybe a crazy tale where at the end you get bucked off a cliff or into a tree or something.

    2nd. There is one instance where the above is supposed to happen to you, but due to sufficient skill you make it through. So maybe some epic tale of riding out a bunch of bucks only to have to give up in the end.

    3rd. So if you do catch a horse you randomly also get a deer. And I never said such a thing in my ending. I think I also let you go directly to the merchant? (don't remember if I actually did or not. Oops). But maybe some tale about how after you got the horse you were able to quickly hunt the deer then because you were so much faster you were able to go directly to the merchant. But then you decided you should let the horse run free. (But also I do give a substantial skill boost for catching the horse. Like +50 I think)

    4th. All of the bandit endings. (4A and 4B) Die or not die. Not die he takes some money, and you lose skills because you are all shaken up. Die and you actually gain skills because hopefully you learned your lesson.

    5th. Similar thing with catching the boat scenes. In some you die, in others you make it through but no boat. And some you have a boat. I don't have any story at all for these.

    6th. Catching the fish. Some you get a massive amount of fish, but lose skill. Like you are SO exhausted from it. Others you catch a medium amount of fish, and lose less skill because you are exhausted. In the other you catch a small amount of fish but you're skill goes up because you learned something.

    7th. All the deer endings. You catch it, die, or lose it. (7a, 7b, 7c). The die while catching deer statistically is just the lose it options, but if you have negative skill or something than "your sheer ineptitude" makes you lose it. Would love a story with that explained. (And all three of these endings)

    8 Raft stories
    8A floating and getting a sunburn.
    8B (searching for the fishing pole. (spoiler alert - no one ever gets the pole mwahaha)


    I will add as I remember more of my options.
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • Ok that was pretty fun! Makes me think I might want to play around with something like this - I miss coding web sites, back in the days before CSS...
    Reminds me of Zork. Love that game.
    Folly's Fantasies #43484 (she/her): Horses, straws, and eggs from my Doubleskunk tribute herd are always free.
  • Thank you! It actually is my first program, and I loved it! Got stressed when Dad suggested something fancy then didn't help me when I was unable to deal with the breakage. But oh well.
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • I remember our discussions about debugging code, and one thing my instructor said that has stayed with me for over 20 years now:
    When you send the elephant out to walk on the toaster and the toaster gets flattened, that's a bug; if the elephant gets hurt, that's a bug; and if the elephant falls due to the injury, that's another bug.
    And you have a whole cascade of stuff to figure out.
    Keep working at it!
    Folly's Fantasies #43484 (she/her): Horses, straws, and eggs from my Doubleskunk tribute herd are always free.
  • Haha. That's awesome.

    I think all of the under the hood stuff is going to have to wait until summer break. But I can't wait to see it again when I know more. I'm super glad that my brother in law was willing to do a patch job for me to get it good enough to turn in
    Breeder of any and all crazy colored drafts and RH horses.
    15552
  • I've been in love with choose your owns most of my life, and have played with writing one. In the last couple years I've stumbled across a handful as apps with various levels of quality. I couldn't figure out how to get your link to behave on my phone... Small display vs. text box. :-?? I like the premise you laid out in your 'code' post.

    I totally think skills should remain invisible, ”You wake up a little smarter, maybe, but all your stuff is gone."

    I'd kill for a real keyboard so I could type at storytelling speed.
    45120

Join our discord server!