SFRPG

The forum for Science Fiction Role Playing Game inspiration and information! So Say We All!
It is currently Tue Jun 19, 2018 4:29 am

All times are UTC




Post new topic  Reply to topic  [ 21 posts ]  Go to page 1 2 3 Next
Author Message
PostPosted: Thu May 21, 2009 8:55 am 
Offline
User avatar

Joined: Thu Jul 03, 2008 5:41 am
Posts: 2168
Location: Yavne, Israel
Last week I've started to teach myself to program in the Python language, which is pretty enjoyable to code with (the last time I programmed anything was when I learned QBasic Turbo Pascal as a kid). Anyhow, part as an exercise and part as a tool I wanted to have, I've programmed a script to generate a Classic Traveller sector. It outputs a SEC file, not unlike the ones used in other CT-related programs.

I must admit that I'm a total newbie in Python (and in programming in general) so this version of the script is very primitive. So far there is no graphical user's interface (GUI) so parameters are controlled by a configuration file (see readme). Once I'll master Python's GUI functions, I'll make this script far more user-friendly.

Also note that this script uses the CT-LBB6 star generation rules which are broken; they were included for the sake of canonicity. In a later version I'll add more realistic rules for star generation which will apply if you'll choose the "realistic" option.

You need Python to run this script; it is provided from its homepage for free. The version you need is Python 2.6.2.

The script itself is Open Source and thus free to use, modify and distribute (or improve on my very modest scripting). However, the Traveller rules used in it are copyrighted by Far Future Enterprises (see below) and thus the rules portion of this script may only be distributed free of charge and accompanied by the following notice:

Quote:
The Traveller game in all forms is owned by Far Future Enterprises. Copyright 1977 - 2008 Far Future Enterprises. Traveller is a registered trademark of Far Future Enterprises. Far Future permits web sites and fanzines for this game, provided it contains this notice, that Far Future is notified, and subject to a withdrawal of permission on 90 days notice. The contents of this site are for personal, non-commercial use only. Any use of Far Future Enterprises's copyrighted material or trademarks anywhere on this web site and its files should not be viewed as a challenge to those copyrights.


EDIT: Note that, unless the output file is moved to another directory or the filename is changed in the configuration file, the output SEC file will be overwritten each time you run the script.

EDIT #2: Program Updated. See Below.

_________________
We are but a tiny candle flickering against the darkness of our times.

Stellagama Publishing - Visit our Blog, Den of the Lizard King


Last edited by Golan2072 on Sun May 24, 2009 7:44 pm, edited 1 time in total.

Top
   
PostPosted: Fri May 22, 2009 5:14 am 
Offline
Banned

Joined: Fri Nov 14, 2008 7:06 am
Posts: 439
Why don't people ever use Ruby to do their programing? Its a beautiful and element language.


Top
   
PostPosted: Fri May 22, 2009 7:40 am 
Offline

Joined: Thu Aug 28, 2008 10:09 am
Posts: 501
Actualy this is quite nice. Sure it doesn't use any fancy features such as object orientation or a full-on config file parser, but that actualy makes it more approachable. This would be an excellent starting point for someone with only elementary programming knowledge to produce their own customised sector generator, tailored to a specific setting or variant or expanded world generation rules.

Best regards,

Simon


Top
   
PostPosted: Fri May 22, 2009 7:48 am 
Offline
User avatar

Joined: Thu Jul 03, 2008 5:41 am
Posts: 2168
Location: Yavne, Israel
simonh wrote:
Actualy this is quite nice.

Thanks :)

_________________
We are but a tiny candle flickering against the darkness of our times.

Stellagama Publishing - Visit our Blog, Den of the Lizard King


Top
   
PostPosted: Sun May 24, 2009 7:46 pm 
Offline
User avatar

Joined: Thu Jul 03, 2008 5:41 am
Posts: 2168
Location: Yavne, Israel
A new version of the SecGen script is ready, this time utilizing Constantine Thomas' (EDG's) excellent stellar-generation rules as part of the "real" option. "canon" generation still uses LBB6 rules.


Attachments:
File comment: SecGen v0.2 Alpha
secgen0.2.zip [6.83 KiB]
Downloaded 78 times

_________________
We are but a tiny candle flickering against the darkness of our times.

Stellagama Publishing - Visit our Blog, Den of the Lizard King
Top
   
PostPosted: Sun May 24, 2009 8:00 pm 
Offline
Administrator
User avatar

Joined: Thu Jul 03, 2008 1:22 am
Posts: 5313
Have you tried it with Python 3 yet? I keep meaning to learn it, I'll take a look at your code and see if that gives me ideas - I find I'm so much better at building on existing stuff than starting on my own (and I learn a lot more that way too) :)

_________________
SFRPG Owner/Admin
This post (or any other post I made here) may not be quoted or copied beyond the SF RPG boards without my explicit permission.
evildrganymede.net - visit the The Worldbuilding Hub
Check out my Youtube channel for all my streamed gaming videos!


Top
   
PostPosted: Sun May 24, 2009 10:49 pm 
Offline

Joined: Sun May 03, 2009 4:10 pm
Posts: 27
For those who use *real* operating systems: :ugeek:

Code:
dos2unix secgen.py
chmod 755 secgen.py
vi secgen.py

and insert as the first line:
Code:
  #!/usr/bin/env python


Golan2072, nice script, lots of good work! I'm learning Python as well, so I'll suggest a couple things. First, avoid Python 3.x for the nonce. It breaks simple things like print, and not a lot of folks are using 3.x yet.

Secondly, hop on Freenode IRC and join #python. Lots of *very* smart and uber-helpful folks there.

Allesandro

p.s. Here's a different way to do dice, as gleaned from the #python folks. It would be a function in your python script.

Code:

import random
import sys

def roll(n_die, modify=0):
   result = modify
   for x in xrange(n_die):
      result += random.randint(1,6)
   return result


You'd call it with
Code:
roll(2, +3)
for a 2d6 roll with a +3 modifier. If you have no modifier it defaults to 0.

A.


Top
   
PostPosted: Sun May 24, 2009 11:04 pm 
Offline
Administrator
User avatar

Joined: Thu Jul 03, 2008 1:22 am
Posts: 5313
Allesandro Domici wrote:
I'm learning Python as well, so I'll suggest a couple things. First, avoid Python 3.x for the nonce. It breaks simple things like print, and not a lot of folks are using 3.x yet.


I'm not sure that's wise advice - Python 3 is where it's going after all, and more and more literature and help is coming out for it all the time (I've got a good book called "Programming in Python" by Mark Summerfield that covers Python 3 quite well).

As time goes on, more and more people with use Python 3, and sticking to an older version of the language isn't going to do you any favours.

_________________
SFRPG Owner/Admin
This post (or any other post I made here) may not be quoted or copied beyond the SF RPG boards without my explicit permission.
evildrganymede.net - visit the The Worldbuilding Hub
Check out my Youtube channel for all my streamed gaming videos!


Top
   
PostPosted: Mon May 25, 2009 12:23 am 
Offline

Joined: Sun May 03, 2009 4:10 pm
Posts: 27
EDG wrote:
Allesandro Domici wrote:
I'm learning Python as well, so I'll suggest a couple things. First, avoid Python 3.x for the nonce. It breaks simple things like print, and not a lot of folks are using 3.x yet.


I'm not sure that's wise advice - Python 3 is where it's going after all, and more and more literature and help is coming out for it all the time (I've got a good book called "Programming in Python" by Mark Summerfield that covers Python 3 quite well).

As time goes on, more and more people with use Python 3, and sticking to an older version of the language isn't going to do you any favours.


Most of the python books should be close in general syntax. However, I'd suggest Python 2.x for anything you want to share for the next year or three. From what I've read the 2.6 and 2.7 stuff will continue to be supported while the various modules get a P 3 port. P3 will break a *lot* of things and time will be needed to get it all settled.

Of course, if you're just learning then you can use either. It's the import statements that will get you, if the module hasn't gotten a port.

Allesandro


Top
   
PostPosted: Mon May 25, 2009 7:43 am 
Offline
User avatar

Joined: Thu Jul 03, 2008 5:41 am
Posts: 2168
Location: Yavne, Israel
Allesandro Domici wrote:
Golan2072, nice script, lots of good work! I'm learning Python as well, so I'll suggest a couple things.

Thanks!

Allesandro Domici wrote:
Secondly, hop on Freenode IRC and join #python. Lots of *very* smart and uber-helpful folks there.

Thanks for the advice. I'll definitely look into this channel when I'll have free time at hand.

Allesandro Domici wrote:
p.s. Here's a different way to do dice, as gleaned from the #python folks. It would be a function in your python script.

Code:

import random
import sys

def roll(n_die, modify=0):
   result = modify
   for x in xrange(n_die):
      result += random.randint(1,6)
   return result


You'd call it with
Code:
roll(2, +3)
for a 2d6 roll with a +3 modifier. If you have no modifier it defaults to 0..

This is indeed a good way to roll 2d6; however, my dice(n, sides) function is designed for any kind of dice, not only d6's. It is simply a fast way to make a sum of multiple random.randints.

For the time being I'm using Python 2.6 as most material available (including libraries) is for Python 2; eventually I'll learn Python 3 as well, and I'll probably switch over to it once it'll be better supported.

_________________
We are but a tiny candle flickering against the darkness of our times.

Stellagama Publishing - Visit our Blog, Den of the Lizard King


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 21 posts ]  Go to page 1 2 3 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited