Skip to content

Commit

Permalink
Prepping for v1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeselincourt committed Oct 28, 2018
1 parent 3ed9d4f commit 15f373c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 55 deletions.
19 changes: 11 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,22 @@
<body>
<div id="wrapper">
<div id="menu-wrapper">
<div id="menu" class="container">
<!-- <div id="menu" class="container">
<ul>
<li class="current_page_item"><a href="/">Generator</a></li>
<li><a href="/about.html">About</a></li>
<!--<li><a href="#">Megagame Makers</a></li>
<li><a href="#">Megagame Makers</a></li>
<li><a href="#">Megagame Definers</a></li>
<li><a href="#">Contact</a></li>-->
<li><a href="#">Contact</a></li>
</ul>
</div>
-->
<!-- end #menu -->
<div id="header-wrapper">
<div id="header" class="container">
<div id="logo">
<h1><a href="#">Megagame Generator</a></h1>
<p>Michael de Selincourt</a></p>
<p>v1 - by Michael de Selincourt</a></p>
</div>
</div>
</div>
Expand All @@ -67,7 +68,6 @@ <h2>Generating...</h2>
<span class="byline">The Megagame</span>
</div>
<span id="mainContent">
Generating...
</span>

<!--
Expand All @@ -82,7 +82,9 @@ <h2>Generating...</h2>
<div class="title">
<h2>What is this?</h2>
</div>
<p>Let's start with what it's not: it's not attempting to replace or ridicule megagame designers!</p><p>It's an intellectual exercise (to think about a formalisation of Megagame design), an entertainment, and perhaps one day an inspiration for someone.</p>
<p>Let's start with what it's not: it's not attempting to replace or ridicule megagame designers!</p><p>It's an intellectual exercise (to attempt a formalisation of Megagame design), an entertainment, and perhaps one day an inspiration for someone.</p>
<p>The generated specs are intentionally somewhat abstract - for them to be playable a human designer would need to invent an overlay a theme that explained the ruled.</p>
<p>It's certainly not 'finished' - for example it still often generates self-contradictory ideologies - but ProcJam 2018 is over so it's time to release v1!</p><p>Suggestions for fixes and improvements are very welcome on Megagame Definers (below)</p>
<div>
<h2>Inspirations</h2>
</div>
Expand All @@ -93,8 +95,9 @@ <h2>Inspirations</h2>
<li><a href="https://www.horizonmegagames.com/">Horizon Megagames</a></li>
<li><a href="http://www.procjam.com/">PROCJAM</a></li>
<li><a href="https://www.facebook.com/groups/2241849549381275/">Megagame Definers on Facebook</a></li>
<li><a href="https://mdeselincourt.github.io/metricgames/">Metricgames</a></li>

<li>All the other megagame groups)</li>
<li><a href="https://www.beckybeckyblogs.com/tag/megagames/">BeckyBecky Blogs Megagames</a></li>
<li>You may also like: <a href="https://mdeselincourt.github.io/metricgames/">Metricgames</a></li>
</ul>
</div>
</div>
Expand Down
94 changes: 47 additions & 47 deletions megagame.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,20 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion

generateTeams(megagame); // Requires teamTypes and ideology spaces

$("#mainContent").html(describeMegagame(megagame));

$("#mainTitle h2").html(megagame.name);

//$("#mainContent").html(describeMegagame(megagame));

var descriptionDiv = document.createElement('div');
descriptionDiv.innerHTML = describeMegagame(megagame);
document.getElementById('mainContent').appendChild(descriptionDiv);

drawCharts(megagame);


var briefingsDiv = document.createElement('div');
briefingsDiv.innerHTML = describeBriefings(megagame);
document.getElementById('mainContent').appendChild(briefingsDiv);

outputJSON(megagame);

Expand Down Expand Up @@ -346,15 +353,15 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion
//
function generateIdeologySpaces(mg, universe) {

console.warn("Ideology space generation is not an optimal heuristic - can generate sets of trackers that would be better combined into grids or polygons.");
console.warn("Ideology space generation is not an optimal heuristic - can generate sets of trackers that would be better combined into grids or polygons. Repetition of nodes can also cause the current algorithm to generate self-contradictory ideologies.");

var ideologySpaces = [];

var bagOfEdges = pickFrom(universe["ideologicalEdges"], d(MAX_GAME_IDEOLOGIES_NUMBER));

console.log("Assembling spaces from bag of edges:");
//console.log("Assembling spaces from bag of edges:");

console.log(" " + JSON.stringify(bagOfEdges));
//console.log(" " + JSON.stringify(bagOfEdges));

// Go through the bag one by one, attempting to
while (bagOfEdges.length > 0) {
Expand All @@ -367,7 +374,7 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion

let is = buildGridSpace(bagOfEdges);

console.log("Build 'grid' = " + JSON.stringify(is));
//console.log("Build 'grid' = " + JSON.stringify(is));

ideologySpaces.push(is);
}
Expand All @@ -376,7 +383,7 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion
// Build a polygon (if possible)
let is = buildPolygonSpace(bagOfEdges);

console.log("Build 'polygon' = " + JSON.stringify(is));
//console.log("Build 'polygon' = " + JSON.stringify(is));

ideologySpaces.push(is);
}
Expand Down Expand Up @@ -406,7 +413,7 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion

// Attempts to build a 2D space of 2 mutually exclusive edges. If it fails to find a second edge it will fall back to a tracker.
function buildGridSpace(bagOfEdges) {
console.log("buildGridSpace()");
//console.log("buildGridSpace()");

var newSpace = {"geometry" : "grid"};

Expand All @@ -417,50 +424,50 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion
// Check through the possible Y axes for an INDEPENDENT edge
for (candidateY of bagOfEdges)
{
console.log(" Considering " + candidateY + " to oppose " + xAxis);
//console.log(" Considering " + candidateY + " to oppose " + xAxis);

if(!xAxis.includes(candidateY[0]) && !xAxis.includes(candidateY[1]))
{
console.log(" Suitable Y axis found!");
//console.log(" Suitable Y axis found!");
yAxis = candidateY;
break; // Stop looking
}
else
{
console.log(" edge not suitable. Next.");
//console.log(" edge not suitable. Next.");
}
}
// Handle result of search


if (yAxis == null)
{
console.log(" No independent Y axis found in remaining bag. ");
//console.log(" No independent Y axis found in remaining bag. ");

console.log(" Could not make a grid; use a polygon instead (unless out of edges completely)");
//console.log(" Could not make a grid; use a polygon instead (unless out of edges completely)");

// We couldn't find an independent Y axis

console.log(" Trying a remaining-edges-in-bag-naive polygon");
//console.log(" Trying a remaining-edges-in-bag-naive polygon");

yAxis = popRandomFrom(bagOfEdges);

console.log("yAxis = " + JSON.stringify(yAxis));
//console.log("yAxis = " + JSON.stringify(yAxis));

if (bagOfEdges.length == 0)
{
console.log(" There AREN'T any more axes, making a tracker.");
//console.log(" There AREN'T any more axes, making a tracker.");
newSpace = {"geometry": "tracker", "edges": [xAxis]};
}
else
{
console.log(" There's another edge; making a (order-naive) polygon");
//console.log(" There's another edge; making a (order-naive) polygon");
newSpace = {"geometry": "polygon", "edges" : [xAxis,yAxis]};
}
}
else
{
console.log("Completing grid with y Axis");
//console.log("Completing grid with y Axis");
// Put the chosen edges into the space
newSpace["edges"] = [xAxis,yAxis];

Expand All @@ -472,7 +479,7 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion
}

function buildPolygonSpace(bagOfEdges) {
console.log("buildPolygonSpace()");
//console.log("buildPolygonSpace()");

// Try to assemble a polygon perimeter.

Expand All @@ -488,42 +495,42 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion

for (freeEdgeIndex = 0; freeEdgeIndex < 6; freeEdgeIndex++) {

console.log(" Seeking edge to add to polygon after [" + freeEdgeIndex + "] of up to [5]");
//console.log(" Seeking edge to add to polygon after [" + freeEdgeIndex + "] of up to [5]");

var freeEdge = newSpace["edges"][freeEdgeIndex]; // Get a reference to the free edge

console.log(" free edge is now " + freeEdge);
//console.log(" free edge is now " + freeEdge);

var freeNode = freeEdge[1]; // Get a reference to the free edge's free node

console.log(" ([" + freeEdgeIndex + "] of " + newSpace["edges"].length + ")");
//console.log(" ([" + freeEdgeIndex + "] of " + newSpace["edges"].length + ")");

// Keep track as we search of whether we've found what we want...
var nextEdgeFound = false;

console.log(" Starting to iterate through bag of " + bagOfEdges.length + " remaining edges");
//console.log(" Starting to iterate through bag of " + bagOfEdges.length + " remaining edges");

// Search each remainder in the bag for a suitable edge to add
for (candidateNext of bagOfEdges) {

console.log(" Considering " + freeEdge + " <--?--< " + candidateNext + " from a bag of " + bagOfEdges.length);
//console.log(" Considering " + freeEdge + " <--?--< " + candidateNext + " from a bag of " + bagOfEdges.length);

if(candidateNext.includes(freeNode)) {

// We can add this edge; but which way around?
console.log(" Found a suitable edge");
//console.log(" Found a suitable edge");

nextEdgeFound = true;

if (freeNode == candidateNext[0])
{
console.log(" " + freeEdge + " <--- " + candidateNext);
//console.log(" " + freeEdge + " <--- " + candidateNext);
// Attach this the right way around
newSpace.edges[freeEdgeIndex+1] = candidateNext;
}
else
{
console.log(" " + freeEdge + " <--- " + candidateNext[1] + "'" + candidateNext[0]);
//console.log(" " + freeEdge + " <--- " + candidateNext[1] + "'" + candidateNext[0]);
newSpace.edges[freeEdgeIndex+1] = [candidateNext[1],candidateNext[0]];
}

Expand All @@ -536,19 +543,19 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion
}
else
{
console.log(" Cannot add this edge"); // Because neither of its nodes match the free node.
//console.log(" Cannot add this edge"); // Because neither of its nodes match the free node.
}

} // End of search for a successor edge

console.log("Finished going through bag in attempt to add edge " + freeEdgeIndex + ", nextEdgeFound = " + nextEdgeFound);
//console.log("Finished going through bag in attempt to add edge " + freeEdgeIndex + ", nextEdgeFound = " + nextEdgeFound);

// We are done going through the bag, did we find anything?
if (nextEdgeFound == false) { break; }// Do not attempt to find another edge

} // End of loop attempting to add another edge

console.log("Finished space assembly, setting final properties and pushing");
//console.log("Finished space assembly, setting final properties and pushing");

// Complete configuring the space

Expand Down Expand Up @@ -615,8 +622,8 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion

function generateTeams(mg) {

console.log("Generating teams into current game:");
console.log(JSON.stringify(mg));
//console.log("Generating teams into current game:");
//console.log(JSON.stringify(mg));

//var briefings = "<h1>Abstract Briefings</h1>";

Expand Down Expand Up @@ -671,10 +678,8 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion

for (idIndex in mg.ideologySpaces) {

console.log("ids = [" + idIndex + "]");
//console.log("ids = [" + idIndex + "]");

console.warn("WARNING - still odd cases where roles don't seem to have enough sympathies");

var ids0 = mg.ideologySpaces[idIndex];

//console.log("ids0 = " + JSON.stringify(ids0));
Expand Down Expand Up @@ -885,11 +890,6 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion
// Describe economy
description += describeEconomy(mg);

console.warn("This code organisation makes it hard to put this under the diagrams");

// Generate briefings
description += describeBriefings(mg);

return description;

}
Expand Down Expand Up @@ -982,7 +982,7 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion

description += "<h1>Briefings (experimental!)</h1>";

description += "<p><i>Disclaimer: this generator lacks a real designer's historical/genre knowledge, so generated teams are arbitrary!</i></p>";
description += "<p><i>Disclaimer: this generator lacks the historical/genre knowledge to create a coherent theme, so generated teams are arbitrary.</i></p>";

for (tt of mg.teamTypes)
{
Expand All @@ -1009,7 +1009,7 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion
//console.log("t.ideologicalPositions = " + JSON.stringify(t.ideologicalPositions));

// List ideologies which under current space-building logic may not be unique.
description += "<p>Your organisation is ideologically " + arrayToProseList(uniqueOnly(t.ideologicalPositions)).toLowerCase() + ". ";
description += "<p>You are an ideologically " + arrayToProseList(uniqueOnly(t.ideologicalPositions)).toLowerCase() + " " + tt.name.toLowerCase() + " team. ";

switch (tt.cooperationLevel) {
case 1:
Expand All @@ -1034,11 +1034,11 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion
// List sympathies which under current logic should be unique??
if (r.sympathies.length)
{
description += "Though your primary ideology is that of your team, you have " + arrayToProseList(r.sympathies).toLowerCase() + " sympathies. ";
description += "Though your primary ideology is " + arrayToProseList(uniqueOnly(t.ideologicalPositions)).toLowerCase() + ", you have " + arrayToProseList(r.sympathies).toLowerCase() + " sympathies. ";
}

if (r.selfishness == 1) { description += "You are strongly motivated by personal ambition. "; }
else if (r.selfishness == -1) { description += "You put your team's interests first. "; }
else if (r.selfishness == -1) { description += "You put your team's interests before your own. "; }

if (r.honesty == 1) { description += "You prefer to be honest in dealing with others. "; }
else if (r.honesty == -1) { description += "You are devious and Machiavellian in pursuing your goals. "; }
Expand Down Expand Up @@ -1176,13 +1176,13 @@ const ANIMALS = ["Ant 🐜", "Bear 🐻", "Eagle 🦅", "Kitten 🐱", "Lion
// HTML-ify the JSON and display
function outputJSON(mg) {

var newHeader = document.createElement('h2');
newHeader.innerHTML = "MegagameML:";
var megagameMLHeader = document.createElement('h1');
megagameMLHeader.innerHTML = "MegagameML:";
var newPara = document.createElement('p');
var newPre = document.createElement('pre');
newPre.innerHTML = syntaxHighlight(mg);

document.getElementById('mainContent').appendChild(newHeader);
document.getElementById('mainContent').appendChild(megagameMLHeader);
document.getElementById('mainContent').appendChild(newPara);
newPara.appendChild(newPre);

Expand Down

0 comments on commit 15f373c

Please sign in to comment.