Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrej-Marsic committed Sep 13, 2023
1 parent 61d0551 commit 5182f47
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 28 deletions.
50 changes: 29 additions & 21 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,34 @@
<body>
<div class="head">
<div class="headerobjectswrapper">
<div class="weatherforcastbox"><span style="font-style: italic;">Weatherforcast for the next 24 hours: Plenty of Sunshine</span><br><span>Wind: 7km/h SSE; Ther: 21°C; Hum: 82%</span></div>
<div class="weatherforcastbox"><span style="font-style: italic;">Standing:

England 6;


Russia 6;


Turkey 5;


France 5;


Austria 4;


Italy 4;


Germany 4;


</span></div>
<header>Diplomacy Today</header>
</div>

<div class="subhead">York, MA - Thursday August 30, 1903 - Seven Pages</div>
<div class="subhead">York, MA - Fall 1903 - Seven Pages</div>
</div>
<div class="content">
<div class="collumns">
Expand Down Expand Up @@ -43,34 +66,19 @@
The French forces have successfully defended the strategic territory of Mar against an aggressive Italian incursion. The Italian forces, originating from Pie and LYO, launched an unchallenged support move towards Mar, only to be met with a stronger French defense. Despite the Italian's unchallenged advance, their attack strength was not greater than the French defense, resulting in a failed move. This victory is a testament to the strategic prowess of General Pierre Leclerc, who led the French forces in this critical battle. The French government has praised Leclerc's leadership, stating that his tactical acumen was instrumental in safeguarding French sovereignty. Meanwhile, the Italian government is facing criticism for its failed military strategy, with many questioning the leadership of General Luigi Rossi. As the dust settles on the battlefield, the geopolitical landscape of Europe continues to shift, with France standing strong in the face of adversity.
</div>

<div class="collumn">
<div class="head"><span class="headline hl3">Italian Fleet Conquers Western Mediterranean!</span><p><span class="headline hl4">A Strategic Victory for Italy as it Asserts Dominance in the Mediterranean Sea</span></p></div>
The Italian fleet has successfully moved from the Tyrrhenian Sea to the Western Mediterranean. The audacious maneuver, led by Admiral Luigi Amadeo, Duke of the Abruzzi, has been hailed as a strategic masterstroke, significantly bolstering Italy's naval strength and influence in the region. The move has been met with mixed reactions from neighboring countries, with some expressing concern over Italy's growing naval power. The Italian government, however, has assured that this move is purely defensive and aims to protect Italy's maritime interests. The Western Mediterranean, a crucial maritime route, is now under the control of the Italian fleet, marking a significant shift in the balance of power in the region.
</div>

<div class="collumn">
<div class="head"><span class="headline hl3">Venetian Uprising: Italy Reclaims Lost Territory!</span><p><span class="headline hl4">Italian Forces Triumph in Venice, Reestablishing National Unity</span></p></div>
Italy has successfully reclaimed the city of Venice from insurgent forces. The operation, led by General Luigi Martino from Tuscany, saw the Italian army overpower the rebels with superior attack strength. The victory marks a significant turning point in Italy's struggle for national unity, quelling fears of a potential split. The city's residents have reportedly welcomed the Italian forces, expressing relief at the restoration of order. The government in Rome has hailed the operation as a testament to Italy's resilience and determination.
</div>

<div class="collumn">
<div class="head"><span class="headline hl3">The Bear Roars: Russia Captures Berlin!</span><p><span class="headline hl4">A Shocking Display of Power as Russian Forces Overwhelm German Defenses</span></p></div>
Russian forces, led by the audacious General Ivan Petrovich, have successfully seized control of Berlin from Germany. The attack, originating from Prussia, was a masterstroke of military strategy, overwhelming the German defenses with superior strength. The fall of Berlin marks a significant shift in the balance of power in Europe, leaving the continent in a state of shock and uncertainty. The German Chancellor, Friedrich von Hohenberg, is expected to make a statement later today.
</div>

<div class="collumn">
<div class="head"><span class="headline hl3">The Lion Holds Its Ground: England's Unchallenged Stand in Norway</span><p><span class="headline hl4">A Show of Strength Amidst Rising Tensions in Europe</span></p></div>
England has successfully maintained its hold on the Norwegian territory. The move, which went unchallenged by other European powers, has sent a clear message of England's determination to protect its interests in the region. The decision to hold rather than advance has been attributed to the strategic foresight of General Arthur Wellington, who is known for his cautious yet effective approach to warfare. This development has sparked a wave of speculation about the future of European geopolitics, with many wondering if this is a sign of England's growing dominance or a prelude to a larger conflict.
</div>

<div class="collumn">
<div class="head"><span class="headline hl3">The Silent Standoff in Sevastopol</span><p><span class="headline hl4">Russian Forces Maintain Control Amidst Tensions</span></p></div>
Russian forces in Sevastopol held their ground yesterday, successfully maintaining control of the strategic port city. Despite the rising tensions in the region, the Russian command's decision to hold rather than advance was unchallenged, leading to a tense but quiet day in Sevastopol. The move, orchestrated by the enigmatic General Ivan Kuznetsov, has left European powers on edge, as they wait to see what Russia's next move will be in this high-stakes game of Diplomacy.
<div class="head"><span class="headline hl3">French Forces Maintain Control Over Tunis Amidst Italian Tensions</span><p><span class="headline hl4">Unchallenged French Troops Hold Their Ground in Tunis, Sparking Diplomatic Unease</span></p></div>
French forces stationed in Tunis have successfully held their position, despite rising tensions with Italy. The move, which went unchallenged by Italian forces, has sparked a diplomatic standoff between the two nations. The French General, Pierre Duval, has been praised for his strategic decision to hold the territory, further solidifying France's influence in North Africa. Meanwhile, Italian officials, led by Prime Minister Giovanni Rossi, have expressed their discontent, hinting at possible retaliatory measures. The situation in Tunis remains a powder keg, with the potential to ignite a broader conflict in the region.
</div>

<div class="collumn">
<div class="head"><span class="headline hl3">French Forces Maintain Control Over Tunis Amidst Italian Tensions</span><p><span class="headline hl4">Unchallenged French Troops Hold Their Ground in Tunis, Sparking Diplomatic Unease</span></p></div>
French forces stationed in Tunis have successfully held their position, despite rising tensions with Italy. The move, which went unchallenged by Italian forces, has sparked a diplomatic standoff between the two nations. The French General, Pierre Duval, has been praised for his strategic decision to hold the territory, further solidifying France's influence in North Africa. Meanwhile, Italian officials, led by Prime Minister Giovanni Rossi, have expressed their discontent, hinting at possible retaliatory measures. The situation in Tunis remains a powder keg, with the potential to ignite a broader conflict in the region.
<div class="head"><span class="headline hl3">In other news...</span><p><span class="headline hl4">Other movements around Europe</span></p></div>
In other news, Italy has made significant advancements on the Diplomacy front, successfully moving from the Tyrrhenian Sea to the Western Mediterranean, and from Tuscany to Venice - overshadowing their opponents with superior attack strength. Meanwhile, England and Russia maintained their ground in Norway and Sevastopol respectively, without any challenges to their reign in these regions.
</div>

<!-- <div class="collumn"> -->
Expand Down
50 changes: 45 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
from collections import Counter
from pathlib import Path

import yaml
Expand All @@ -18,7 +19,8 @@ def main():
# main_headline = create_main_headline(news)
main_headline = ""
news_list = process_news(news)
generate_newspaper(news_list, main_headline)
standing = get_standing(territories)
generate_newspaper(news_list, main_headline, season, standing)


def get_battles(orders, territories):
Expand Down Expand Up @@ -179,14 +181,25 @@ def get_territories_by_country(country, battle_possessions):

def get_news(summaries):
news = []
for summary in tqdm(summaries):
battle_summaries = [s for s in summaries if s["countries_involved"].count("-") > 1]
for summary in tqdm(battle_summaries):
piece_of_news = create_piece_of_news_prompt(summary)
news += [piece_of_news]
other_summaries = "\n".join(
[
s["pretty_battle_orders"]
for s in summaries
if s["countries_involved"].count("-") == 1
]
)
other_news = create_other_news_prompt(other_summaries)
other_news_format = f"Title: In other news...\nSubtitle: Other movements around Europe\nParagraph: {other_news}"
news += [other_news_format]
return news


def create_piece_of_news_prompt(summary):
prompt = f"""I will share with you the adjunction of orders from a Diplomacy game.
prompt = f"""I will share with you the adjudication of orders from a Diplomacy game.
You will invent the headline for a newspaper that covers European Geopolitics that airs in an alternative 1903. Some territories might be owned by different countries than they were in history.
Invent extra drama and fake people involved.
For each headline, provide a title, subtitle and a paragraph.
Expand All @@ -212,6 +225,22 @@ def create_piece_of_news_prompt(summary):
return answer


def create_other_news_prompt(other_summaries):
prompt = f"""I will share with you the adjudication of orders from a Diplomacy game.
These are only the moves that did not involve any conflict between countries, but these countries could have been in conflicts elsewhere.
You will write a paragraph that will go to the "In other news" section of a newspaper. Try to briefly describe what happened.
Report:
---
{other_summaries}
---
Output:"""
other_news = ping_gpt(prompt, temp=1)

return other_news


def create_main_headline(news):
prompt = f"""I will share with you a series of news from a newspaper covering a Europe at war.
You will invent the main headline for this edition of the newspaper and a sentence briefly listing the news.
Expand Down Expand Up @@ -247,9 +276,20 @@ def process_news(news):
return news_list


def generate_newspaper(news_list, main_headline):
def get_standing(territories):
standing_list = Counter(territories.values()).most_common()
standing = [s[0] + " " + str(s[1]) for s in standing_list]
return standing


def generate_newspaper(news_list, main_headline, season, standing):
env = Environment(loader=FileSystemLoader("."))
template = env.get_template("template.html")

newspaper = template.render(news_list=news_list, main_headline=main_headline)
newspaper = template.render(
news_list=news_list,
main_headline=main_headline,
season=season,
standing=standing,
)
Path("index.html").write_text(newspaper)
9 changes: 7 additions & 2 deletions template.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
<body>
<div class="head">
<div class="headerobjectswrapper">
<div class="weatherforcastbox"><span style="font-style: italic;">Weatherforcast for the next 24 hours: Plenty of Sunshine</span><br><span>Wind: 7km/h SSE; Ther: 21°C; Hum: 82%</span></div>
<div class="weatherforcastbox"><span style="font-style: italic;">Standing:
{% for stand in standing %}
{{ stand }};

{% endfor %}
</span></div>
<header>Diplomacy Today</header>
</div>

<div class="subhead">York, MA - Thursday August 30, 1903 - Seven Pages</div>
<div class="subhead">York, MA - {{season}} - Seven Pages</div>
</div>
<div class="content">
<div class="collumns">
Expand Down

0 comments on commit 5182f47

Please sign in to comment.