Author Topic: Random mission generator  (Read 8255 times)

0 Members and 1 Guest are viewing this topic.

Random mission generator
Hi all, I'm currently trying to work on a random mission generator for our favorite game ;)
The goal is not to create very advanced mission involving many sexps, but to allow the creation of simple missions of 5 basic types, with simple sexps just for testing purpose.

As I don't have any coding skills I'm doing it using an excel sheet with a macro to generate the file. It's nothing spectacular for now but I'm able to generate a readable mission file for one type of mission (with just fighters for now).
The downside of this method is that you don't read vp's so data has to be entered beforehand (but the sheet already contains standard FS2 data as well as some custom).
All data in the lists are optional during mission generation so you can add multiple mod to the data tables and just select the data that will be used with userforms.

How it works:
The sheet contains a "Data" and a "Name" sheet that contains class names for weapons and ships by category, and names for wings/individual ships.
When you generate the file it prompts userforms to allow options and to select the savefile.
It then write to the file with parameters generated depending on the type of mission and difficulty.

I just started working on it yesterday but I can already generate a small "patrol" mission with one line briefing, enemy wings spawning after a timer elapsed, and directives appearing to destroy those wings.

Main functions are being implemented to add more variety, and many parameters are still not working.
It does not generate background for now but options are in to allow it at later time.

If people are interested to lend a helping hand I'd be happy to share it ;)

 

Offline potterman28wxcv

  • 27
  • Just a fan player
Re: Random mission generator
Just imagine the possibilities if there was a way to include mission generation code (e.g. in Python, or another interpreted script language) directly within Freespace SCP.. You could vary the content of missions dynamically based on the results of the previous one, or actually have random generation integrated in a campaign, or play a mix of turn-based with real time battles.. In terms of modding it would be heaven.

I know it's a huge amount of work.. But a man can dream  :)

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: Random mission generator
Hi all, I'm currently trying to work on a random mission generator for our favorite game ;)
The goal is not to create very advanced mission involving many sexps, but to allow the creation of simple missions of 5 basic types, with simple sexps just for testing purpose.

As I don't have any coding skills I'm doing it using an excel sheet with a macro to generate the file. It's nothing spectacular for now but I'm able to generate a readable mission file for one type of mission (with just fighters for now).
The downside of this method is that you don't read vp's so data has to be entered beforehand (but the sheet already contains standard FS2 data as well as some custom).
All data in the lists are optional during mission generation so you can add multiple mod to the data tables and just select the data that will be used with userforms.

How it works:
The sheet contains a "Data" and a "Name" sheet that contains class names for weapons and ships by category, and names for wings/individual ships.
When you generate the file it prompts userforms to allow options and to select the savefile.
It then write to the file with parameters generated depending on the type of mission and difficulty.

I just started working on it yesterday but I can already generate a small "patrol" mission with one line briefing, enemy wings spawning after a timer elapsed, and directives appearing to destroy those wings.

Main functions are being implemented to add more variety, and many parameters are still not working.
It does not generate background for now but options are in to allow it at later time.

If people are interested to lend a helping hand I'd be happy to share it ;)

I would suggest using LUA, it will be immensely helpful in this endeavor, trust me. I did not know programming much beyond R and Excel but was able to pick up LUA and, over the past year, I have been able to integrate it with when-argument sexps to create something with random generation and player persistence (ie the player gains rank, fleet grows, previous missions affect next missions). If you would like I can give you some extra pointers that I found out the hard way.
« Last Edit: January 28, 2018, 10:55:24 am by wookieejedi »

 
Re: Random mission generator
Your system seems very interesting indeed but it's a different approach if i understand you're using the built-in lua system to alter existing missions and track player through a whole campaign. You still need to create a mission in fred and add random elements via scripting. I didn't thought about that.

My generator on the other way don't start from an existing mission but attempts to create a .fs2 file from scratch.
Taking both method might lead to intersting things ^^ for now i focus on getting playable random missions with the generator, then i'll perhaps look into lua.

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: Random mission generator
Your system seems very interesting indeed but it's a different approach if i understand you're using the built-in lua system to alter existing missions and track player through a whole campaign. You still need to create a mission in fred and add random elements via scripting. I didn't thought about that.

My generator on the other way don't start from an existing mission but attempts to create a .fs2 file from scratch.
Taking both method might lead to intersting things ^^ for now i focus on getting playable random missions with the generator, then i'll perhaps look into lua.

I probably didn't explain that well...my bad. My generator uses lua to create a new mission each time (ie new .fs2 file). And it uses a template, thus once the mission is created nothing has to be changed and it can be played directly. If Excel works for you then I would say go with it! To each their own :)

 
Re: Random mission generator
Ok i understand better, well your idea is probably better as it allows more things to be done (as lua can access much more data related to the game).
But i'll need to learn lua more seriously if i have the time ^^

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: Random mission generator
Ok i understand better, well your idea is probably better as it allows more things to be done (as lua can access much more data related to the game).
But i'll need to learn lua more seriously if i have the time ^^

Excel might work better for allowing someone else to use it though, especially if macro buttons are used. It all really just depends on your ultimate goal for the generator I think. Mine is more of a self sustained black box, whereas I think you  want yours to me more available as a tool to the public?

 
Re: Random mission generator
Well for now it's a simple entertainment, i'll see how far it can go and perhaps release it if i find it useful.

For now it's not really functionnal (it generates only a mission with a bunch of fighter wings spawning at random time to random place within an ally's range, directive to destroy spawning wings and a random background. All ship classes are set random from a list you choose from before generating the mission) but i'd like to be able to make escort and assault missions.
Also by using lists to select from you can add as much ship and weapons classes as you want (you can choose to select them or not if they appear in the mod you intent to run the mission with).

And as i said in my first post if someone is willing to help i can share the unprotected file (i try to comment the code as much as i can) there's no secret and still much much work to do ;)
« Last Edit: January 28, 2018, 11:57:30 am by krevett62 »

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: Random mission generator
Well for now it's a simple entertainment, i'll see how far it can go and perhaps release it if i find it useful.

For now it's not really functionnal (it generates only a mission with a bunch of fighter wings spawning at random time to random place within an ally's range, directive to destroy spawning wings and a random background. All ship classes are set random from a list you choose from before generating the mission) but i'd like to be able to make escort and assault missions.
Also by using lists to select from you can add as much ship and weapons classes as you want (you can choose to select them or not if they appear in the mod you intent to run the mission with).

And as i said in my first post if someone is willing to help i can share the unprotected file (i try to comment the code as much as i can) there's no secret and still much much work to do ;)

Nice. That's a good feature, and I wish you the best of luck with your progress!

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Random mission generator
I have an incomplete random mission generator written in python... somewhere... it was very, very simple. To be honest, the most advanced part of it was the squadron name generator, intended for the briefing.
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: Random mission generator
Nice. Writing the custom briefing generator based on script generated ships selection, system name, enemy and friendly strength, and mission objectives made me realize how simple the sentences had to be in order to be modular  :lol:

  
Re: Random mission generator
Well after 3 days here's a sample mission file generated with it.
A bit buggy but can be opened without errors in FRED and in FSO.

Still missing many things I'm currently working on (briefing and debriefing sections as well as global success and failure events for now don't pay attention to these ^^), but wing writing and directives are working as intended.

Things I'm currently working on:
*write briefing and debriefing sections
*add individual ships to missions for variety (code already written, must add random names ^^) as well as sentry guns for assault (base type)
*generate other types of missions (assault, escord and defend are my priorities)
*add more arrival events sexp types
*generate working goals ("success" and "failure" sexps events)
*better random background generator (not my top priority for now)
*other ideas i'll find while working ;)


Edit: BTW I know some of you have some imagination ^^ I'm after a list of names (friendly ans hostile alike) for single ships (cruisers, transports, capital or installation)


[attachment stolen by Russian hackers]
« Last Edit: January 30, 2018, 08:34:41 am by krevett62 »

 

Offline HLD_Prophecy

  • PVD_Hope in a former life
  • 29
Re: Random mission generator
Wow, this looks like an intriguing and entertaining idea. You're good with coding krevett!  :yes:

 
Re: Random mission generator
Thanks but i'm not that good you know just looking here and there learning some tricks but i'm not a serious scripter (my former school course is about physics and chemistry nothing about computers lol) anyway you're right its intriguing and entertaining that's why i'm playing with that ^^

 
Re: Random mission generator
Ok i've encountered a little problem. It probably has to do with the way I write data to the file but it really bugs me out ^^

Let me explain, if I generate a file fresh from the generator and play it directly in FSO, first I can't select my ship/weapons as wings are blanked out in the selection screen (but I can press continue and play with the default ship that was assigned without knowing wich it is). And second arrival cues of wings don't work at all, every ship is here from start and directives to destroy them don't appear.

However, if I open the file in FRED first and just save it under the editor (without even doing anything to it), everything works as intended.

What bugs me out is that there must be a formatting error somewhere, but then why does FRED opens the file without even complaining? Or perhaps a missing important line?

Here is an example (I post the files because copying the text is too long for the forum):
Mission-Copie.fs2 is the untouched generated file
Mission. fs2 is just Mission-Copie.fs2 opened in FRED and saved immediately (without opening a single menu)

Mission.fs2 works as it should but not the original (but it is read by FRED, wings, arrival cues, everything is there). Does anyone sees where the problem lies (someone who knows how mission files are parsed by the FSO engine).

I'm probably missing to write an important line somewhere...

Edit: added the generator in it's current state if someone is curious (there's no readme but I tried to comment the code as much as I could) please bear in mind that I still have some functions to add and the random thing for now is just putting values to test the functions (only patrol and escort options are valid).

[attachment stolen by Russian hackers]
« Last Edit: January 31, 2018, 12:20:31 am by krevett62 »

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Random mission generator
FRED is pretty good about correcting errors. There are lots of differences between the generated mission and the one you have resaved in FRED.

Nothing immediately leaps out at me as the cause of the problem but I did notice you have been writing the arrival cues for ships in wings as true. If you set those to false you can now loadout your ships. But they don't appear by default so that is only half of the problem solved.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 
Re: Random mission generator
Well indeed I will take a look at the arrival cues.
Main differences include subsystem listing but it does not prevent the ships from using their turrets with default weapons listed in the tbl (as far as I have tested).
Thanks for taking a bit of your time to look at the mission ;)

 
Re: Random mission generator
Well I feel silly to not have seen this before, thanks karajorma! Settings arrival cue to false for ships that belong to wings solved all the problems ^^ (In fact wings had their arrival cue already set so the second part was not really a problem)

 
Re: Random mission generator
nice job
make it so it generates story campaign

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: Random mission generator
nice job
make it so it generates story campaign

So this is quite difficult...I would suggest if you want a story campaign generator, perhaps try making one yourself?