Skip to content

Instantly share code, notes, and snippets.

@bsullins
Last active May 31, 2016 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsullins/faf637290007a08703b11af8a22f1781 to your computer and use it in GitHub Desktop.
Save bsullins/faf637290007a08703b11af8a22f1781 to your computer and use it in GitHub Desktop.
Game of Thrones Battles in D3
name year battle_number attacker_king defender_king source attacker_2 attacker_3 attacker_4 target defender_2 defender_3 defender_4 attacker_outcome battle_type major_death major_capture value defender_size attacker_commander defender_commander summer location region note
Battle of the Golden Tooth 298 1 Joffrey/Tommen Baratheon Robb Stark Lannister Tully win pitched battle yes no 15000 4000 Jaime Lannister Clement Piper, Vance 1 Golden Tooth The Westerlands
Battle at the Mummer's Ford 298 2 Joffrey/Tommen Baratheon Robb Stark Lannister Baratheon win ambush yes no 120 Gregor Clegane Beric Dondarrion 1 Mummer's Ford The Riverlands
Battle of Riverrun 298 3 Joffrey/Tommen Baratheon Robb Stark Lannister Tully win pitched battle no yes 15000 10000 Jaime Lannister, Andros Brax Edmure Tully, Tytos Blackwood 1 Riverrun The Riverlands
Battle of the Green Fork 298 4 Robb Stark Joffrey/Tommen Baratheon Stark Lannister loss pitched battle yes yes 18000 20000 Roose Bolton, Wylis Manderly, Medger Cerwyn, Harrion Karstark, Halys Hornwood Tywin Lannister, Gregor Clegane, Kevan Lannister, Addam Marbrand 1 Green Fork The Riverlands
Battle of the Whispering Wood 298 5 Robb Stark Joffrey/Tommen Baratheon Stark Tully Lannister win ambush yes yes 1875 6000 Robb Stark, Brynden Tully Jaime Lannister 1 Whispering Wood The Riverlands
Battle of the Camps 298 6 Robb Stark Joffrey/Tommen Baratheon Stark Tully Lannister win ambush no no 6000 12625 Robb Stark, Tytos Blackwood, Brynden Tully Lord Andros Brax, Forley Prester 1 Riverrun The Riverlands
Sack of Darry 298 7 Joffrey/Tommen Baratheon Robb Stark Lannister Darry win pitched battle no no Gregor Clegane Lyman Darry 1 Darry The Riverlands
Battle of Moat Cailin 299 8 Balon/Euron Greyjoy Robb Stark Greyjoy Stark win pitched battle no no Victarion Greyjoy 1 Moat Cailin The North
Battle of Deepwood Motte 299 9 Balon/Euron Greyjoy Robb Stark Greyjoy Stark win siege no no 1000 Asha Greyjoy 1 Deepwood Motte The North
Battle of the Stony Shore 299 10 Balon/Euron Greyjoy Robb Stark Greyjoy Stark win ambush no no 264 Theon Greyjoy 1 Stony Shore The North Greyjoy's troop number based on the Battle of Deepwood Motte, in which Asha had 1000 soldier on 30 longships. That comes out to ~33 per longship. In the Battle of the Stony Shore, Theon has 8 longships, and just we can estimate that he has 8*33 =265 troops.
Battle of Torrhen's Square 299 11 Robb Stark Balon/Euron Greyjoy Stark Greyjoy win pitched battle no no 244 900 Rodrik Cassel, Cley Cerwyn Dagmer Cleftjaw 1 Torrhen's Square The North Greyjoy's troop number comes from the 264 estimate to have arrived on the stony shore minus the 20 Theon takes to attack Winterfell. Thus 264-20=244
Battle of Winterfell 299 12 Balon/Euron Greyjoy Robb Stark Greyjoy Stark win ambush no yes 20 Theon Greyjoy Bran Stark 1 Winterfell The North It isn't mentioned how many Stark men are left in Winterfell, other than "very few".
Sack of Torrhen's Square 299 13 Balon/Euron Greyjoy Balon/Euron Greyjoy Greyjoy Stark win siege no yes Dagmer Cleftjaw 1 Torrhen's Square The North
Sack of Winterfell 299 14 Joffrey/Tommen Baratheon Robb Stark Bolton Greyjoy Stark win ambush yes no 618 2000 Ramsay Snow, Theon Greyjoy Rodrik Cassel, Cley Cerwyn, Leobald Tallhart 1 Winterfell The North Since House Bolton betrays the Starks for House Lannister, we code this battle as between these two houses. Greyjoy men, numbering only 20, don't play a major part in the fighting and end up dying anyway.
Battle of Oxcross 299 15 Robb Stark Joffrey/Tommen Baratheon Stark Tully Lannister win ambush yes yes 6000 10000 Robb Stark, Brynden Tully Stafford Lannister, Roland Crakehall, Antario Jast 1 Oxcross The Westerlands
Siege of Storm's End 299 16 Stannis Baratheon Renly Baratheon Baratheon Baratheon win siege yes no 5000 20000 Stannis Baratheon, Davos Seaworth Renly Baratheon, Cortnay Penrose, Loras Tyrell, Randyll Tarly, Mathis Rowan 1 Storm's End The Stormlands
Battle of the Fords 299 17 Joffrey/Tommen Baratheon Robb Stark Lannister Tully loss pitched battle no no 20000 10000 Tywin Lannister, Flement Brax, Gregor Clegane, Addam Marbrand, Lyle Crakehall, Leo Lefford Edmure Tully, Jason Mallister, Karyl Vance 1 Red Fork The Riverlands
Sack of Harrenhal 299 18 Robb Stark Joffrey/Tommen Baratheon Stark Lannister win ambush yes no 100 100 Roose Bolton, Vargo Hoat, Robett Glover Amory Lorch 1 Harrenhal The Riverlands
Battle of the Crag 299 19 Robb Stark Joffrey/Tommen Baratheon Stark Lannister win ambush no no 6000 Robb Stark, Smalljon Umber, Black Walder Frey Rolph Spicer 1 Crag The Westerlands
Battle of the Blackwater 299 20 Stannis Baratheon Joffrey/Tommen Baratheon Baratheon Lannister loss pitched battle yes yes 21000 7250 Stannis Baratheon, Imry Florent, Guyard Morrigen, Rolland Storm, Salladhor Saan, Davos Seaworth Tyrion Lannister, Jacelyn Bywater, Sandor Clegane, Tywin Lannister, Garlan Tyrell, Mace Tyrell, Randyll Tarly 1 King's Landing The Crownlands
Siege of Darry 299 21 Robb Stark Joffrey/Tommen Baratheon Darry Lannister win siege no no Helman Tallhart 1 Darry The Riverlands
Battle of Duskendale 299 22 Robb Stark Joffrey/Tommen Baratheon Stark Lannister loss pitched battle yes no 3000 Robertt Glover, Helman Tallhart Randyll Tarly, Gregor Clegane 1 Duskendale The Crownlands
Battle of the Burning Septry 299 23 Brotherhood without Banners Brave Companions win pitched battle no no 1 The Riverlands
Battle of the Ruby Ford 299 24 Joffrey/Tommen Baratheon Robb Stark Lannister Stark win pitched battle no no 6000 Gregor Clegane Roose Bolton, Wylis Manderly Ruby Ford The Riverlands
Retaking of Harrenhal 299 25 Joffrey/Tommen Baratheon Lannister Brave Companions win pitched battle yes no Gregor Clegane Vargo Hoat 1 Harrenhal The Riverlands
The Red Wedding 299 26 Joffrey/Tommen Baratheon Robb Stark Frey Bolton Stark win ambush yes yes 3500 3500 Walder Frey, Roose Bolton, Walder Rivers Robb Stark 1 The Twins The Riverlands This observation refers to the battle against the Stark men, not the attack on the wedding
Siege of Seagard 299 27 Robb Stark Joffrey/Tommen Baratheon Frey Mallister win siege no yes Walder Frey Jason Mallister 1 Seagard The Riverlands
Battle of Castle Black 300 28 Stannis Baratheon Mance Rayder Free folk Thenns Giants Night's Watch Baratheon loss siege yes yes 100000 1240 Mance Rayder, Tormund Giantsbane, Harma Dogshead, Magnar Styr, Varamyr Stannis Baratheon, Jon Snow, Donal Noye, Cotter Pyke 0 Castle Black Beyond the Wall
Fall of Moat Cailin 300 29 Joffrey/Tommen Baratheon Balon/Euron Greyjoy Bolton Greyjoy win siege no no Ramsey Bolton 0 Moat Cailin The North
Retaking of Deepwood Motte 300 31 Stannis Baratheon Balon/Euron Greyjoy Baratheon Karstark Mormont Glover Greyjoy win pitched battle no no 4500 200 Stannis Baratheon, Alysane Mormot Asha Greyjoy 0 Deepwood Motte The North
Battle of the Shield Islands 300 32 Balon/Euron Greyjoy Joffrey/Tommen Baratheon Greyjoy Tyrell win pitched battle no no Euron Greyjoy, Victarion Greyjoy 0 Shield Islands The Reach
Invasion of Ryamsport, Vinetown, and Starfish Harbor 300 33 Balon/Euron Greyjoy Joffrey/Tommen Baratheon Greyjoy Tyrell win razing no no Euron Greyjoy, Victarion Greyjoy 0 Ryamsport, Vinetown, Starfish Harbor The Reach
Second Seige of Storm's End 300 34 Joffrey/Tommen Baratheon Stannis Baratheon Baratheon Baratheon win siege no no 200 Mace Tyrell, Mathis Rowan Gilbert Farring 0 Storm's End The Stormlands
Siege of Dragonstone 300 35 Joffrey/Tommen Baratheon Stannis Baratheon Baratheon Baratheon win siege no no 2000 Loras Tyrell, Raxter Redwyne Rolland Storm 0 Dragonstone The Stormlands
Siege of Riverrun 300 36 Joffrey/Tommen Baratheon Robb Stark Lannister Frey Tully win siege no no 3000 Daven Lannister, Ryman Fey, Jaime Lannister Brynden Tully 0 Riverrun The Riverlands
Siege of Raventree 300 37 Joffrey/Tommen Baratheon Robb Stark Bracken Lannister Blackwood win siege no yes 1500 Jonos Bracken, Jaime Lannister Tytos Blackwood 0 Raventree The Riverlands
Siege of Winterfell 300 38 Stannis Baratheon Joffrey/Tommen Baratheon Baratheon Karstark Mormont Glover Bolton Frey 5000 8000 Stannis Baratheon Roose Bolton 0 Winterfell The North
<!DOCTYPE html>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<style>
.tooltip {
position: absolute;
max-width: 400px;
height: auto;
padding: 5px;
background-color: white;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
pointer-events: none; /* MUY IMPORTANTE! */
font-family: sans-serif;
font-size:12px;
}
path.link {
fill: none;
stroke-width: 2px;
}
path.link.win{
stroke: #a6d96a;
}
path.link.loss{
stroke: #ca0020;
}
text {
fill: #000;
font: 10px sans-serif;
pointer-events: none;
}
</style>
<body>
<!--<h1>Game of Thrones Battles</h1>-->
<p>Every battle beteween major houses and groups. Hover the line for details.</p>
<script>
// get the data
d3.csv("battles.csv", function(error, links) {
var nodes = {};
// Compute the distinct nodes from the links.
links.forEach(function(link) {
link.source = nodes[link.source] ||
(nodes[link.source] = {name: link.source});
link.target = nodes[link.target] ||
(nodes[link.target] = {name: link.target});
link.value = +link.value;
});
//setup our window
var width = window.innerWidth*0.8,
height = window.innerHeight*0.8;
//build the layout
var force = d3.layout.force()
.nodes(d3.values(nodes))
.links(links)
.size([width, height])
.linkDistance(100)
.charge(-1800)
.on("tick", tick)
.start();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
//add hovercard
var hovercard = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0)
.style("width",400);
// build the arrow.
svg.append("svg:defs").selectAll("marker")
.data(["end"]) // Different link/path types can be defined here
.enter().append("svg:marker") // This section adds in the arrows
.attr("id", String)
.attr("viewBox", "0 -5 10 10")
.attr("refX", 25)
.attr("refY", -1.5)
.attr("markerWidth", 6)
.attr("markerHeight", 6)
.attr("orient", "auto")
.attr("fill", "#404040")
.append("svg:path")
.attr("d", "M0,-5L10,0L0,5");
// add the links and the arrows
var path = svg.append("svg:g").selectAll("path")
.data(force.links())
.enter().append("svg:path")
.attr("class", function(d) { return "link " + d.type; })
.attr("class", "link")
.attr("marker-end", "url(#end)");
// define the nodes
var node = svg.selectAll(".node")
.data(force.nodes())
.enter().append("g")
.attr("class", "node")
.call(force.drag);
// add the nodes matching the images
// node.append("circle")
// .attr("r", 25)
node.append("image")
.attr("xlink:href", function(d) { return "https://raw.githubusercontent.com/bsullins/got-images/master/img/"+encodeURI(d.name).toLowerCase().replace(/'/g, '')+".png"; })
.attr("x", function(d) { return -25;})
.attr("y", function(d) { return -25;})
.attr("height", 50)
.attr("width", 50);
// add the text
node.append("text")
.attr("text-anchor", "middle")
.attr("dy", ".35em")
.attr("y",-32)
.text(function(d) { return d.name; });
// add the curvy lines
function tick() {
path.attr("d", function(d, i) {
var dx = d.target.x - d.source.x + (i*10), //separate the lines
dy = d.target.y - d.source.y + (i*10),
dr = Math.sqrt(dx * dx + dy * dy);
return "M" +
d.source.x + "," +
d.source.y + "A" +
dr + "," + dr + " 0 0,1 " +
d.target.x + "," +
d.target.y;
});
path.attr("class", function(d) { return "link "+ d.attacker_outcome});
path.on("mouseover", function(d) {
hovercard.transition()
.duration(500)
.style("opacity", 1);
var tip =
"<h2>" + d.name + "</h2>" +
"<h4> " +d.source.name + " attacked " + d.target.name + " and the outcome was a " + d.attacker_outcome + "</h4>" +
"<h3>Details</h3>" +
"<strong> Attacker King: </strong>" + d.attacker_king + "<br/>" +
"<strong> Battle Type: </strong>" + d.battle_type + "<br/>" +
"<strong> Major Death?: </strong>" + d.major_death + "<br/>" +
"<strong> Major Capture?: </strong>" + d.major_capture + "<br/>" +
"<strong> Attacker Size: </strong>" + d.value + "<br/>" +
"<strong> Defender Size: </strong>" + d.defender_size + "<br/>" +
"<strong> Region / Location: </strong>" + d.region + " / " + d.location + "<br/>" +
"<strong> Attacking Commander: </strong>" + d.attacker_commander + "<br/>" +
"<strong> Defending Commander: </strong>" + d.defender_commander;
hovercard.html(tip)
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY) + "px");
});
path.on("mouseout", function(d) {
hovercard.transition()
.duration(500)
.style("opacity", 0);
});
node
.attr("transform", function(d) {
return "translate(" + d.x + "," + d.y + ")"; });
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment