intfiction.org

The Interactive Fiction Community Forum
It is currently Mon Nov 20, 2017 2:53 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Nov 18, 2016 2:12 pm 
Offline

Joined: Thu Mar 27, 2014 8:47 am
Posts: 438
This is not a post-mortem in the strictest sense of the word, but I have had a few PM’s and emails asking ‘how did you do that?’ – in reference in particular to the fact the graphical elements are injected into the HTML framework from Inform, and the AI of the opponent.

GoW TOURNAMENT is just a card game I thought was fun, and I wanted people to play. It placed slightly higher in the comp than I thought it would – most reviews were entirely correct in their assessment of ‘this is quite fun, but I’m supposed to be judging IF here!’ and I expected and was entirely ok with that – I would have written the same thing.

The graphical elements use Furkle’s excellent little framework to inject elements from Inform into the framing Javascript. I’ve written a blog post about it:
http://www.interactivefables.com/blog/worldsmith-devblog-integrating-the-parser-and-the-web-page

It is not perfect, but it really is worth experimenting with if you get the chance. I don’t think I’ve even scratched the surface of potential here. In theory, you could use Inform as a meta-language to manage entirely the front-end – specifically as a kind of user-command led wrapper around a suite of Javascript functions.

Each card has a little meta-description in the code. For example:

Code:
Scion of Uther is a GameCard. The description of it is "Arcana: Mind[line break]Name : Scion of Uther[line break]Effect : Four turns[line break]Description: Halves progress of your opponent's Lifeform towards the next stage of Evolution.[paragraph break][italic type]He was the scion of an ancient noble family; she an orphan without money or friends_*|CFICODE: './interpreter/Assets/Scion_Uther.jpg', 'Scion of Uther'|*_.[roman type]". The target_type of it is opposition. The priority of Scion of Uther is 4. The printed name of Scion of Uther is "[set link 1302]Scion of Uther[end link]".


This has the effect of replacing the image and text in the sidebar every time the description of the card is printed out in the main parser screen.
It would be interesting to see some experimentation with this. Each output in Inform could theoretically, for example be redirected to a different part of the page. Hmmmm….

The other aspect of the game that was interesting to develop was the AI. It’s actually quite a complicated thing. It’s a four-pass AI:

Code:
Each turn:
1.   Assign Strategy to myself from aggressive, passive, builder, defender from game’s current state and the cards in hand.
2.   Optimise Cards – A little non-linear optimization function that prioritises each card depending on the strategy and game’s current state
3.   Optimise Field – Assess impact of each card on field of play.
4.   …..rinse and repeat recursively until an optimal choice is reached according to a fairly arbitrary ceiling


With this, the opponent can quite easily play the absolute optimal card every time – that maximizes its winning chance based on the state of play. Interestingly, this made the game too hard. It wasn’t much fun. Even when the player fully understood every mechanic of the game, and played optimally, the average win-rate was 50%.

So I had to do a ‘de-optimize’ step 5. You’ll notice that the opponent quite often will play a foolish card. Basically, every now and again, the opponent will ignore its optimized card and choose a ‘non-optimal’ card from its hand. The frequency and chance of this decreases as you progress through the competition.

The rulebook is a Twine. It is called directly from the game into a modal window using the BROWSE action. If anyone is interested, here is the code:

Code:
browsing is an action applying to one thing.
Understand "browse [something]" as browsing.

Does the player mean browsing the game of worlds rulebook: it is very likely.

Check browsing:
   if the noun is not the Game of Worlds Rulebook:
      say "That is not browsable." instead.
   
Carry out browsing:
   if the noun is the Game of Worlds Rulebook:
      say "You _*|INCOPEN: './interpreter/Assets/Rulebook.html'|*_open the rulebook.";


And here is the little javascript function that sits inside Furkle’s framework:

Code:
var ROUTINES = {
   'INCOPEN': doIncModal,
};
// Get the modal
var incmodal = document.getElementById('myIncModal');

//To launch the Rulebook modal window
function doIncModal(source)   {
   var txtmod = document.getElementById('books');
   txtmod.src = source;
   var modal = document.getElementById('myIncModal');
   modal.style.display = "block";
   }

Finally, as a note to self - I’m adding a commandment to the canon of ‘thou should not’ for authors:

Quote:
Thou should NOT expect players to know about or immediately use the inventory command. If the player starts the game carrying something that is vital for gameplay, tell them about it!


I lost count of the number of people who overlooked the Rulebook. This was my fault entirely.

Great competition. Great entries. Thanks to all who participated.

Ade.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Fri Nov 18, 2016 3:34 pm 
Offline
User avatar

Joined: Mon Oct 03, 2011 12:03 pm
Posts: 1021
Location: Reading
Seriously impressed by the technical achievement here. And the game was very fun and well balanced. One issue I did have is that once you have an advantage over the opponent, it's very straightforward to use multiplier effects to widen that advantage, such that a lot of games were a bit of a steamroll.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Fri Nov 18, 2016 4:19 pm 
Offline

Joined: Thu Mar 27, 2014 8:47 am
Posts: 438
Thank you, and,yeah, agreed. that's some of what I need to work on for a next release. in addition, some of the cards plus multiplier are overpowered. Desolation + a multiplier towards the end of the game is devastating for example.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sat Nov 19, 2016 12:51 am 
Offline

Joined: Sun Nov 16, 2008 11:40 pm
Posts: 48
This was a lot of fun to play. I did notice the disjointed nature of the AI, in the sense that usually it would play pretty optimally but occasionally would play something completely silly. AI is a hard problem, though, and I was really impressed at how well it did normally. It took me several matches before I got enough of a sense of the cards to make a decent strategy. I got really flattened the first few times. Eventually I found that some cards were almost never useful, though, like the ones that changed the resource levels of the planet. I only played those when I didn't have anything else useful to play. I'm curious about how the AI decided whether to use a counter token or not. Sometimes it would counter me multiple times and sometimes it would let me counter things unopposed.

Quote:
The rulebook is a Twine.

Does this mean that this piece is actually a combination of Inform 7 and Twine? That's really unusual, but brilliant. I don't understand the usage of the INCOPEN routine or why it's in the middle of the say statement, but if it works, awesome. Thanks for sharing some of the technical details.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sat Nov 19, 2016 1:18 am 
Offline

Joined: Sun Apr 13, 2014 2:34 am
Posts: 78
ReikoYukawa wrote:
Does this mean that this piece is actually a combination of Inform 7 and Twine?

Oh god, they're combining. Soon the circle will be complete, the distinction between parser and choice games will be moot, and we'll enter a brave new world of interactive fiction.

Tongue out of cheek: If this is true, or even if it's not, the technical impressiveness of what I've heard about this game makes me really want to try it.

_________________
Hello!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sat Nov 19, 2016 3:00 am 
Offline

Joined: Mon Sep 28, 2015 5:11 pm
Posts: 158
ReikoYukawa wrote:
This was a lot of fun to play. I did notice the disjointed nature of the AI, in the sense that usually it would play pretty optimally but occasionally would play something completely silly. AI is a hard problem, though, and I was really impressed at how well it did normally. It took me several matches before I got enough of a sense of the cards to make a decent strategy. I got really flattened the first few times. Eventually I found that some cards were almost never useful, though, like the ones that changed the resource levels of the planet. I only played those when I didn't have anything else useful to play. I'm curious about how the AI decided whether to use a counter token or not. Sometimes it would counter me multiple times and sometimes it would let me counter things unopposed.

Quote:
The rulebook is a Twine.

Does this mean that this piece is actually a combination of Inform 7 and Twine? That's really unusual, but brilliant. I don't understand the usage of the INCOPEN routine or why it's in the middle of the say statement, but if it works, awesome. Thanks for sharing some of the technical details.


Reiko, the basic concept is that there's a small little Javascript module that watches every bit of text that gets appended to the document. If text is rendered to the document matching the pattern _*PATTERN*_ (I think, it's been a bit), this is understood as a command to be executed, and the related Javascript fires, and the text is deleted. This way, the writer has some degree of control over what Javascript executes when, and the player (ideally, as far as I've seen) never sees the command at all.

In case this doesn't answer why it's in the say statement, the Inform virtual machine is very complicated, and requires some degree of collaboration and understanding to hook into, so instead of listening to or modifying the parser runtime, patterns intended to be understood as calling are only "heard" if they're a part of text outputted by the Inform engine.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sat Nov 19, 2016 10:03 am 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 5115
Location: Burlington, VT
I enjoyed this and was very technically impressed, and the code sounds very awesome and useful!

How plausible do you reckon it would be to tinker with this sort of framework if you basically don't know any Javascript? Do you see it as something that someone could plausibly use as an alternative to Flexible Windows?


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sat Nov 19, 2016 11:29 am 
Offline

Joined: Thu Mar 27, 2014 8:47 am
Posts: 438
matt w wrote:
I enjoyed this and was very technically impressed, and the code sounds very awesome and useful!

How plausible do you reckon it would be to tinker with this sort of framework if you basically don't know any Javascript? Do you see it as something that someone could plausibly use as an alternative to Flexible Windows?


For browser delivery of the game, yes. Furkle's framework is a deceptively simple thing. In theory, all text could be parsed through the framework, calling simple Javascript functions to stream the output / manage several HTML elements. In my other game that uses this, Worldsmith, I'm using it to manage at least 6 elements in the page.

I'm going to experiment a little. I think it would be interesting to see how you could use this to stream some of the output into separate little 'windows', and manage more atomically the user UI,.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sun Nov 20, 2016 3:10 am 
Offline

Joined: Mon Sep 28, 2015 5:11 pm
Posts: 158
matt, please feel free to drop by the euphoria channel or message me on twitter (@furkle_) if you want to talk about integrating web stuff into parser. i can't make any huge promises, and it certainly won't work as well as if zarf wrote a glulx opcode for you, but i'm sure we can figure something out.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sun Nov 20, 2016 12:05 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 5115
Location: Burlington, VT
Thanks furkle! I am pretty much infinitely far away from having anything that I might want to put in this framework but if I get something I might want to mock up I'll get in touch! Bookmarking this thread for future reference.

(Aside, having looking at your twitter TL I'm literally laughing out loud at this.)


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours [ DST ]


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:  
Powered by phpBB® Forum Software © phpBB Group