Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2] 3

Author Topic: Where to begin with programming this?  (Read 2614 times)

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Where to begin with programming this?
« Reply #15 on: February 24, 2013, 06:22:36 pm »

Nothing wrong with Java.
Ok so there are some things wrong with Java, but no language is perfect for everything. For this project these problems shouldn't become too abrupt though. It does strings, random numbers and file writers with minimal effort, tada!

SeriousConcentrate

  • Bay Watcher
  • The Hollow Street Hero
    • View Profile
Re: Where to begin with programming this?
« Reply #16 on: February 24, 2013, 06:52:03 pm »

So I was reviewing this thread and a thought came to me - one I'm surprised it took so long to think of, considering what forum this is. :P Would it be easier or harder to make a program call text from a series of raws like Dwarf Fortress? For example, suppose this quote is a file.

Quote from: Races
Human
Deep Dwarf
Common Dwarf
Wood Elf
City Elf
Halfling
Drow
etc.

Would it be possible to make a program select a random line from that file? I was thinking that if possible, it would make it easy to modify; you'd just have to edit that file and add or remove lines instead of going into the source and writing more lines of code (or deleting them) to get what results you wanted.

Possibly stupid question aside, Java sounds like a decent start; writing to a file is definitely something I want. I've googled tutorials for it, though, and all I found were ones focusing on game design... which I'm not really interested in, and frankly are above my level of knowledge anyway. :-\ Are there any good beginner tutorials out there?
Logged
SerCon Shorts: This Is How You Do It - Twenty-three one minute or less videos of random stupidity in AC:U, Bloodborne, DS2:SotFS, Salt & Sanctuary, and The Witcher 3.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Where to begin with programming this?
« Reply #17 on: February 24, 2013, 06:57:20 pm »

Yea, you could do that with Java easily.

Oracle themselves offer some lessons on how to make all this stuff work. Some homework to do, but anyway.
http://docs.oracle.com/javase/tutorial/essential/io/


I think the best thing to do right now would be to start building a bit of a foundation knowledge of how Java, or any language you like really, works. Make a 'Hello world' program. Then play with some loops and ifs and go from there.

freeformschooler

  • Bay Watcher
    • View Profile
Re: Where to begin with programming this?
« Reply #18 on: February 24, 2013, 11:52:02 pm »

Quote from: Races
Human
Deep Dwarf
Common Dwarf
Wood Elf
City Elf
Halfling
Drow
etc.

Would it be possible to make a program select a random line from that file? I was thinking that if possible, it would make it easy to modify; you'd just have to edit that file and add or remove lines instead of going into the source and writing more lines of code (or deleting them) to get what results you wanted.

I consider File I/O to be a little bit overkill for this and would again recommend using simple arrays at first, but it's a great thing to learn how to do either way.
Logged

Sirian

  • Bay Watcher
    • View Profile
Re: Where to begin with programming this?
« Reply #19 on: February 25, 2013, 01:42:52 pm »

If i had to do something like that, i'd probably use autohotkey, not because it's the best way, but because it's the laziest for me : I have it already installed to make game macros, it's very intuitive, and it doesn't bitch too much about syntax. Also what you're trying to do is very simple so I wouldn't bother installing/learning something else.
Logged

Muz

  • Bay Watcher
    • View Profile
Re: Where to begin with programming this?
« Reply #20 on: February 25, 2013, 10:29:53 pm »

Honestly, I found Java really hard to pick up. I was doing it professionally... took me about 3 months to finally grasp. You'd need to understand how programming works and how Object Oriented works to really get it.

By contrast, learning Python the hard way had me making text games within 4 days.
Logged
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

SeriousConcentrate

  • Bay Watcher
  • The Hollow Street Hero
    • View Profile
Re: Where to begin with programming this?
« Reply #21 on: February 27, 2013, 01:38:29 am »

Having not made much headway into things so far, I'm going to look into Autohotkey. The problem is I've looked at its command list and I don't really see anything that would help me with what I want to do. I mean, it could make posting here slightly easier (no more typing color=#0099CC :P) and I appreciate you telling me about it... I see it has a random function, which I suppose could work, but I would still have to fill out the sheets myself. Not really optimal, but it's something I could probably fall back on.

Hmm. Maybe if I can combine FileReadLine with Random and see if there's a way of outputting it...
« Last Edit: February 27, 2013, 01:43:39 am by SeriousConcentrate »
Logged
SerCon Shorts: This Is How You Do It - Twenty-three one minute or less videos of random stupidity in AC:U, Bloodborne, DS2:SotFS, Salt & Sanctuary, and The Witcher 3.

Muz

  • Bay Watcher
    • View Profile
Re: Where to begin with programming this?
« Reply #22 on: February 27, 2013, 01:48:58 am »

I still think you can do it in Python within a week.
Logged
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Where to begin with programming this?
« Reply #23 on: February 27, 2013, 01:54:19 am »

I literally just did the following in python in less than a minute
Code: [Select]
import random
gender = ["male", "female"]
race = ["human", "panotti", "jotun", "cat"]
preferance = ["ice cream", "you", "crushing the hopes and dreams of those around me"]
print "I am a " + gender[random.randint(0,1)] + " " + race[random.randint(0,3)]
print "and I like " + preferance[random.randint(0,1)]

producing the following output when run three times

Quote
I am a male panotti
and I like ice cream
Quote
I am a female jotun
and I like you
Quote
I am a female panotti
and I like crushing the hopes and dreams of those around me


It would require a little more effort to make something that produces more realistic results, such as producing a 'race' class, but you could do a lot in a week with python.

SeriousConcentrate

  • Bay Watcher
  • The Hollow Street Hero
    • View Profile
Re: Where to begin with programming this?
« Reply #24 on: February 27, 2013, 02:34:14 am »

The problem with that is I read it and now I feel like a damn idiot for not figuring anything out so far. :P Seriously, I could probably just take that and make everything I need out of it. I'll see if I can do anything with the sample. Thanks, Max. ^^^

Also, I want to thank Sirian for showing me AHK again. :3 Now that I've figured a small bit of it out, I can use it for a few useful things for FG&RP and RTD.

EDIT: Hmm, when I try to replicate your code I get syntax errors at the 'print' stage.
« Last Edit: February 27, 2013, 02:49:36 am by SeriousConcentrate »
Logged
SerCon Shorts: This Is How You Do It - Twenty-three one minute or less videos of random stupidity in AC:U, Bloodborne, DS2:SotFS, Salt & Sanctuary, and The Witcher 3.

Berserker

  • Bay Watcher
    • View Profile
Re: Where to begin with programming this?
« Reply #25 on: February 27, 2013, 04:19:04 am »

EDIT: Hmm, when I try to replicate your code I get syntax errors at the 'print' stage.
You are probably using Python 3. Try adding parentheses after the print statement like this:
Code: [Select]
print("and I like " + preferance[random.randint(0,1)])
Logged

SeriousConcentrate

  • Bay Watcher
  • The Hollow Street Hero
    • View Profile
Re: Where to begin with programming this?
« Reply #26 on: February 27, 2013, 04:39:01 am »

I was/am using Python 3. I'm guessing it isn't as good as Python 2? But anyway, thanks for letting me know my error. I'll try it again and see what I can do. ^^^
Logged
SerCon Shorts: This Is How You Do It - Twenty-three one minute or less videos of random stupidity in AC:U, Bloodborne, DS2:SotFS, Salt & Sanctuary, and The Witcher 3.

Sirian

  • Bay Watcher
    • View Profile
Re: Where to begin with programming this?
« Reply #27 on: February 27, 2013, 06:55:28 am »

Having not made much headway into things so far, I'm going to look into Autohotkey. The problem is I've looked at its command list and I don't really see anything that would help me with what I want to do. I mean, it could make posting here slightly easier (no more typing color=#0099CC :P) and I appreciate you telling me about it... I see it has a random function, which I suppose could work, but I would still have to fill out the sheets myself. Not really optimal, but it's something I could probably fall back on.

Hmm. Maybe if I can combine FileReadLine with Random and see if there's a way of outputting it...

There's a function called FileAppend that you can use to create your character file. Other than that it's probably simpler if the various options (race, gender, etc...) were inside the .ahk file instead of an external file.

There's also a function called "InputBox" that you can use to input manually a variable.

For your project, you'd need a series of random checks and "if" logic (like branches each allowing a specific subset of other characteristics), and then write the choices selected inside a .txt file with FileAppend.
Logged

Andrew425

  • Bay Watcher
    • View Profile
Re: Where to begin with programming this?
« Reply #28 on: February 27, 2013, 09:20:48 am »

I would use java mostly because its one of the easiest ones I've used. A few random number generators and a couple of switch statements would give you a workable program without much difficultly.
Logged
May the mass times acceleration be with you

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Where to begin with programming this?
« Reply #29 on: February 27, 2013, 11:45:38 pm »

Thanks, Max. ^^^
No problemo!
I was hesitant to post code before because I like to see people go out on a limb for themselves, but sometimes a bit of code can go a long way.
There might come a point when you find your program produces somewhat unreal results, such as a 7 foot dwarf or a robot with a gender. If this becomes an issue, I would be willing to guide you through a simple object oriented solution.
Pages: 1 [2] 3