Bay 12 Games Forum

Please login or register.

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

Author Topic: Astronaut text based game (Python)  (Read 8535 times)

Deadmeat1471

  • Bay Watcher
    • View Profile
Astronaut text based game (Python)
« on: January 16, 2011, 09:31:19 am »

Ok, so I'm a complete nooby when it comes to programming. What little I have learnt is from reading through a book on python once or twice.
I have been improving over the years, but my knowledge is very small.

I am attemping to make a very simple astronaut text game, comprising of a timeframe 1957-1972.
You play an astronaut, you have certain skills and aptitudes and you can do various action to A) improve these and B) get your ass in the driving seat of a capsule.
Currently it is in the total theoretical phase (only basic menu items have been coded).

This is NOT one of those 'I'm going to make the most epic game evar and cant program'. I accept my limitations and am using what I know to make a game for personal fun :D and any ideas anyone has or can offer would help, coding or not.

My primary concerns at the moment are:
Organising the various choices to do. So far there is: rest, practice, socialise end turn (I plan for at least 4 more).

Rest would rest, raising moral slightly which will make you less likely to burn out. Practice will be split into the skills, Capsule, EVA, LEM, Docking, Endurance. Socialise would raise some 'visibility' modifier, which would raise your chance to be chosen for a mission not based on skill, but partially because of who you know.
End turn would move to the calculation phase.

The 'mission' phase will be the majority of the coding. If anyone has played BARIS (See my LP in 'others' forum), you will imagine already how the mission will go.

Missions would be run like this:

what componants does mission have? launch=yes, orbital insertion=yes, eva=no,docking=no. etc etc
Launch stage, roll for rocket safety = success or failure? roll for catastrophic failure?
Orbital insertion stage, roll for capsule safety + pilot skill = success or failure? roll for catastrophic failure?
and so on.

The development of the space agency and when missions are run I am undecided whether to make it historical (historic launch times) or write some ramdomised code.
Example = usa gets 100 money each turn, soviets get 75, when money reaches 500 a semi random mission is rolled and initiated? (one which is needed) also random events may increase/decrease this money.

The goal will be getting yourself ready and in position compared to npc astronauts to be chosen for the mission, based on your avaliability (maybe other decent ones washed out of training/got injured etc) or your proficiency for the mission.

Code would be something along the line of: semi random mission roll - sub orbital manned, need crew?=yes, required astronaut 1skill=capsule, required astronaut2 skill= docking. pick one which has the highest of both of these. (this code I will have to research, I have forgotten how to do 'lists')

Anyway as I said any help is welcome in coding or ideas!

Heres what I have so far, Ill update as it comes along. (yes it is probably the most disorganised code you have ever seen!)
Spoiler (click to show/hide)
   
   
   

« Last Edit: January 19, 2011, 06:01:35 am by Deadmeat1471 »
Logged

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Astronaut text based game (Python)
« Reply #1 on: January 16, 2011, 12:47:48 pm »

It looks ok for a main program loop. I would have put the two stages (character creation, turn phase) in functions to make it easier to come back to from other parts of the program without restructuring things majorly. It would also clean up your state logic - you could do something like
Code: [Select]
while quit == false
    charCreateFunction()
    while alive
        aliveFunction()
    loop
    endGameFunction()
loop
Then within aliveFunction(), call your daily turns and special events, including mission generators and the like. And within endGameFunction(), decide if quit == false, do your highscore, that sort of thing. Easier to see what's going on, all in one place without other statements around it. Functions are very useful - if you haven't learned them, that should be your next step :)
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044

Deadmeat1471

  • Bay Watcher
    • View Profile
Re: Astronaut text based game (Python)
« Reply #2 on: January 16, 2011, 01:14:52 pm »

Thanks for the tip, the functions I have learnt, but they tended to confuse me :D I was looking into them again aswell. So far ive been sticking to things i was secure in, but functions Ill have to bring into it like you say!
Logged

Armok

  • Bay Watcher
  • God of Blood
    • View Profile
Re: Astronaut text based game (Python)
« Reply #3 on: January 16, 2011, 03:58:51 pm »

Sounds like you're doing great so far! You've already passed with flying colours several obstacles where many projects are crippled. Like the choice of programming language and being self concious about your own skill and reasonable project scope.
Logged
So says Armok, God of blood.
Sszsszssoo...
Sszsszssaaayysss...
III...

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: Astronaut text based game (Python)
« Reply #4 on: January 16, 2011, 04:00:58 pm »

Sounds like you're doing great so far! You've already passed with flying colours several obstacles where many projects are crippled. Like the choice of programming language and being self concious about your own skill and reasonable project scope.
This.

Also, are you using objects and stuff?
Logged

Deadmeat1471

  • Bay Watcher
    • View Profile
Re: Astronaut text based game (Python)
« Reply #5 on: January 16, 2011, 06:27:18 pm »

Objects?

and thanks Armok, I feel I can fairly easily achieve my text based game goals, possibly to the detail I imagine, possibly not  ;D Python isnt so much a choice as it is the only language i've looked at in any detail (as the first one people advise!)
« Last Edit: January 16, 2011, 06:30:01 pm by Deadmeat1471 »
Logged

Deadmeat1471

  • Bay Watcher
    • View Profile
Re: Astronaut text based game (Python)
« Reply #6 on: January 16, 2011, 06:42:03 pm »

Next things ill consider are what to calculate end of turn.
Off the top of my head it will be:

+1 year date
Astronaut program progression - money gained, equipment improvement maybe
Offered a place in a flight crew (primary crew or backup)?
Possible missions
Astronaut randomness (washouts/new recruits/etc)
Moral attrition (simple, drops by say 5-10 each year due to the stress of being in the program)
Probably more...


Right now I think i should get a good list of astronauts (easy peasy) random events (accident, washout, retirement) and a comprehensive list of historical missions of the Mercury program (the first stage of space flight). So I can 'test' the mission coding I have yet to do!


Mercury missions as Wikipedia says:
Spoiler (click to show/hide)

The 'Mercury Seven' astronauts (Group I):
Spoiler (click to show/hide)

Vostok program missions:
Spoiler (click to show/hide)

Vostok Cosmonauts:
Spoiler (click to show/hide)
« Last Edit: January 16, 2011, 06:55:44 pm by Deadmeat1471 »
Logged

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: Astronaut text based game (Python)
« Reply #7 on: January 16, 2011, 07:39:54 pm »

Objects?

and thanks Armok, I feel I can fairly easily achieve my text based game goals, possibly to the detail I imagine, possibly not  ;D Python isnt so much a choice as it is the only language i've looked at in any detail (as the first one people advise!)
You know, Object-orientated programming
Logged

Deadmeat1471

  • Bay Watcher
    • View Profile
Re: Astronaut text based game (Python)
« Reply #8 on: January 17, 2011, 12:50:17 am »

I thought you could only do that in Java or such, if that is not the case then I have absolutely no idea about OOP :D it's beyond my knowledge.
Logged

Deadmeat1471

  • Bay Watcher
    • View Profile
Re: Astronaut text based game (Python)
« Reply #9 on: January 17, 2011, 01:05:31 am »

Ok ive got my head around lists again (fairly easy). Next ill impliment the roster of Mercury 7 Astronauts and Vostok Cosmonauts!
Logged

Deadmeat1471

  • Bay Watcher
    • View Profile
Re: Astronaut text based game (Python)
« Reply #10 on: January 17, 2011, 01:22:08 am »

For those who like laughing at newbies, this was my test to make sure the astronaut list would work:

Spoiler (click to show/hide)

Resulting in:
Spoiler (click to show/hide)

Also I'm confident from my relearning lists I can do the 'pick a astronaut for the mission' bit.
« Last Edit: January 17, 2011, 01:30:29 am by Deadmeat1471 »
Logged

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: Astronaut text based game (Python)
« Reply #11 on: January 17, 2011, 02:27:50 am »

For those who like laughing at newbies, this was my test to make sure the astronaut list would work:

Spoiler (click to show/hide)

Resulting in:
Spoiler (click to show/hide)

Also I'm confident from my relearning lists I can do the 'pick a astronaut for the mission' bit.
That doesn't look too bad.
 
Now, if you say, made a class "Astronaut", then you could assign several values to it. Then instead having to remember which position in the array belongs to which stat you could just return something like
Code: [Select]
print Glenn.Skillwhich would give you the same value, except "skill" is more easily understandable than an arrray pointer.
 
Of course my knowledge of classes is (v rusty) so the details may be different, but that's the gist of it.
Logged

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Astronaut text based game (Python)
« Reply #12 on: January 17, 2011, 02:30:23 am »

Ninja'd a little. You don't have to use OOP until you need it. But, for instance, you could store the name of your astronauts in an Astronaut object, alongside their stats, and do something like
Code: [Select]
for every astronaut in astList (n)
    print astList(n).name
    print 'Capsule skill: ' str(astList(n).capSkill)
    print 'Cookie baking skill: ' str(astList(n).cookieSkill)
next
You can also make the Astronaut object a descendent of a more generic Human object, so that you can make Civilians or Saboteurs or whatnot act like Humans, and Astronauts act like Humans, but not have Astronauts act like Civilians or Saboteurs (or vice-versa), all by virtue of simply not having their attributes and functions available to them to mess them up.

If it's confusing, don't worry - you'll see where it's useful as you go along and find places where functional/non-structured programming is unnecessarily difficult. I find that's how most people learn (including myself)
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044

Deadmeat1471

  • Bay Watcher
    • View Profile
!
« Reply #13 on: January 17, 2011, 03:31:22 am »

Some good ideas, i will have to look into both OOP and the other stuff, I'll probably incorporate all of it if I can get my head around it! thanks!
Logged

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: Astronaut text based game (Python)
« Reply #14 on: January 17, 2011, 03:32:08 am »

Eh, even if you don't implement it, learning new stuff usually is a good thing.
Logged
Pages: [1] 2 3 ... 6