Add Senate simulator

This commit is contained in:
dartz 2024-07-26 01:51:59 -04:00
parent 951c2f6f29
commit 7ad89768e1
7 changed files with 371 additions and 288 deletions

View file

@ -4,7 +4,7 @@
height="593" height="593"
version="1.1" version="1.1"
id="svg2" id="svg2"
sodipodi:docname="SenateMap2024.svg" sodipodi:docname="Senate2024.svg"
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)" inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
@ -22,12 +22,12 @@
inkscape:pageopacity="0" inkscape:pageopacity="0"
inkscape:pagecheckerboard="1" inkscape:pagecheckerboard="1"
inkscape:deskcolor="#505050" inkscape:deskcolor="#505050"
inkscape:zoom="1.4142136" inkscape:zoom="1.569697"
inkscape:cx="461.74073" inkscape:cx="625.91697"
inkscape:cy="331.63308" inkscape:cy="365.67566"
inkscape:window-width="1920" inkscape:window-width="1858"
inkscape:window-height="1018" inkscape:window-height="1058"
inkscape:window-x="-8" inkscape:window-x="54"
inkscape:window-y="-8" inkscape:window-y="-8"
inkscape:window-maximized="1" inkscape:window-maximized="1"
inkscape:current-layer="svg2" inkscape:current-layer="svg2"
@ -40,7 +40,7 @@
<dc:format>image/svg+xml</dc:format> <dc:format>image/svg+xml</dc:format>
<dc:type <dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>2024 US presidential election results</dc:title> <dc:title>2020 US presidential election results</dc:title>
</cc:Work> </cc:Work>
</rdf:RDF> </rdf:RDF>
</metadata> </metadata>
@ -222,18 +222,9 @@
font-family="Helvetica Neue" font-family="Helvetica Neue"
font-weight="bold"> font-weight="bold">
<g <g
font-size="28" font-size="28px"
id="g1"> id="g1"
<text transform="translate(0.90094684,3.6037874)">
id="AKn"
x="121.59544"
y="493.18863"
style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan41"
x="121.59544"
y="493.18863"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff" /></text>
<text <text
id="HIn" id="HIn"
x="281.26047" x="281.26047"
@ -249,136 +240,71 @@
x="117.53755" x="117.53755"
y="49.386745" y="49.386745"
style="font-size:13.3333px"><tspan style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan38"
x="117.53755"
y="49.386745"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">WA</tspan><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan39" id="tspan39"
x="117.53755" x="117.53755"
y="66.053368" y="49.386745"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff" /></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">WA</tspan></text>
<text
id="ORn"
x="95.010078"
y="122.48579"
style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan37"
x="95.010078"
y="122.48579"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff" /></text>
<text <text
id="CAn" id="CAn"
x="69.726158" x="69.726158"
y="279.08011" y="279.08011"
style="font-size:13.3333px"><tspan style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan34"
x="69.726158"
y="279.08011"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">CA</tspan><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan35" id="tspan35"
x="69.726158" x="69.726158"
y="295.74673" y="279.08011"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff" /></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">CA</tspan></text>
<text <text
id="NVn" id="NVn"
x="133.35632" x="133.35632"
y="232.08958" y="232.08958"
style="font-size:13.3333px"><tspan style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan32"
x="133.35632"
y="232.08958"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">NV</tspan><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan33" id="tspan33"
x="133.35632" x="133.35632"
y="248.75621" y="232.08958"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff" /></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">NV</tspan></text>
<text <text
id="AZn" id="AZn"
x="188.30663" x="188.30663"
y="358.99054" y="358.99054"
style="font-size:13.3333px"><tspan style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan27"
x="188.30663"
y="358.99054"
style="font-size:13.3333px;fill:#ffffff">AZ</tspan><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan28" id="tspan28"
x="188.30663" x="188.30663"
y="375.65717" y="358.99054"
style="font-size:13.3333px;fill:#ffffff" /></text> style="font-size:13.3333px;fill:#ffffff">AZ</tspan></text>
<text <text
id="UTn" id="UTn"
x="219.70537" x="219.70537"
y="251.48579" y="251.48579"
style="font-size:13.3333px"><tspan style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan25"
x="219.70537"
y="251.48579"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">UT</tspan><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan26" id="tspan26"
x="219.70537" x="219.70537"
y="268.1524" y="251.48579"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff" /></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">UT</tspan></text>
<text
id="IDn"
x="194.15645"
y="151.80695"
style="font-size:13.3333px"><tspan
sodipodi:role="line"
x="194.15645"
y="151.80695"
id="tspan22"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1" /></text>
<text <text
id="MTn" id="MTn"
x="279.21573" x="279.21573"
y="85.347488" y="85.347488"
style="font-size:13.3333px"><tspan style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan15"
x="279.21573"
y="85.347488"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">MT</tspan><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan16" id="tspan16"
x="279.21573" x="279.21573"
y="102.01411" y="85.347488"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff" /></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">MT</tspan></text>
<text <text
id="WYn" id="WYn"
x="298.39981" x="298.39981"
y="182.08109" y="182.08109"
style="font-size:13.3333px"><tspan style="font-size:13.3333px"><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan18"
x="298.39981" x="298.39981"
y="182.08109" y="182.08109"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">WY</tspan><tspan
sodipodi:role="line"
x="298.39981"
y="198.74771"
id="tspan19" id="tspan19"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff" /></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">WY</tspan></text>
<text
id="COn"
x="319.78827"
y="270.08292"
style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan24"
x="319.78827"
y="270.08292"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1" /></text>
<text <text
id="NMn" id="NMn"
x="302.97266" x="302.97266"
@ -399,24 +325,6 @@
x="415.85614" x="415.85614"
y="451.69336" y="451.69336"
style="font-size:13.3333px;fill:#ffffff;fill-opacity:1">TX</tspan></text> style="font-size:13.3333px;fill:#ffffff;fill-opacity:1">TX</tspan></text>
<text
id="OKn"
x="461.73621"
y="358.28769"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1"><tspan
sodipodi:role="line"
id="tspan6"
x="461.73621"
y="358.28769" /></text>
<text
id="KSn"
x="441.22095"
y="289.62161"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1"><tspan
sodipodi:role="line"
id="tspan8"
x="441.22095"
y="289.62161" /></text>
<text <text
id="NEn" id="NEn"
x="414.12476" x="414.12476"
@ -427,16 +335,6 @@
x="414.12476" x="414.12476"
y="221.48842" y="221.48842"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">NE</tspan></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">NE</tspan></text>
<text
id="SDn"
x="415.85419"
y="157.25868"
style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan12"
x="415.85419"
y="157.25868"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1" /></text>
<text <text
id="NDn" id="NDn"
x="417.25748" x="417.25748"
@ -467,26 +365,6 @@
x="579.54468" x="579.54468"
y="159.84668" y="159.84668"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">WI</tspan></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">WI</tspan></text>
<text
id="ILn"
x="596.69891"
y="249.73816"
style="font-size:13.3333px;fill:#ffffff"><tspan
sodipodi:role="line"
id="tspan74"
x="596.69891"
y="249.73816"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff" /></text>
<text
id="IAn"
x="521.78705"
y="212.28769"
style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan44"
x="521.78705"
y="212.28769"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff" /></text>
<text <text
id="MOn" id="MOn"
x="540.95941" x="540.95941"
@ -497,26 +375,6 @@
x="540.95941" x="540.95941"
y="292.93628" y="292.93628"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">MO</tspan></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">MO</tspan></text>
<text
id="ARn"
x="547.24762"
y="374.0896"
style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan52"
x="547.24762"
y="374.0896"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1" /></text>
<text
id="LAn"
x="545.79749"
y="450.64859"
style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan54"
x="545.79749"
y="450.64859"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff" /></text>
<text <text
id="MSn" id="MSn"
x="597.98846" x="597.98846"
@ -527,60 +385,16 @@
x="597.98846" x="597.98846"
y="417.18863" y="417.18863"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">MS</tspan></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">MS</tspan></text>
<text
id="ALn"
x="650.66272"
y="409.38675"
style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan58"
x="650.66272"
y="409.38675"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1" /></text>
<text
id="GAn"
x="714.30121"
y="407.73816"
style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan50"
x="714.30121"
y="407.73816"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1" /></text>
<text <text
id="FLn" id="FLn"
x="763.43597" x="763.88647"
y="504.54953" y="510.85617"
style="font-size:13.3333px"><tspan style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan55"
x="763.43597"
y="504.54953"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#f8f8f8;fill-opacity:1">FL</tspan><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan56" id="tspan56"
x="763.43597" x="763.88647"
y="521.21613" y="510.85617"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#f8f8f8;fill-opacity:1" /></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#f8f8f8;fill-opacity:1">FL</tspan></text>
<text
id="SCn"
x="759.23254"
y="347.11545"><tspan
sodipodi:role="line"
x="759.23254"
y="347.11545"
id="tspan61"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1" /></text>
<text
id="NCn"
x="781.7052"
y="328.48581"
style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan68"
x="781.7052"
y="328.48581"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1" /></text>
<text <text
id="TNn" id="TNn"
x="655.9707" x="655.9707"
@ -591,16 +405,6 @@
x="655.9707" x="655.9707"
y="340.83722" y="340.83722"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">TN</tspan></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">TN</tspan></text>
<text
id="KYn"
x="675.10925"
y="299.28769"
style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan70"
x="675.10925"
y="299.28769"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff" /></text>
<text <text
id="INn" id="INn"
x="644.74738" x="644.74738"
@ -626,16 +430,11 @@
x="700.31543" x="700.31543"
y="235.38675" y="235.38675"
style="font-size:13.3333px"><tspan style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan81"
x="700.31543"
y="235.38675"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">OH</tspan><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan82" id="tspan82"
x="700.31543" x="700.31543"
y="252.05338" y="235.38675"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1" /></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">OH</tspan></text>
<text <text
id="WVn" id="WVn"
x="738.71716" x="738.71716"
@ -661,16 +460,11 @@
x="779.22137" x="779.22137"
y="210.08958" y="210.08958"
style="font-size:13.3333px"><tspan style="font-size:13.3333px"><tspan
sodipodi:role="line"
id="tspan87"
x="779.22137"
y="210.08958"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">PA</tspan><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan88" id="tspan88"
x="779.22137" x="779.22137"
y="226.75621" y="210.08958"
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff" /></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff">PA</tspan></text>
<text <text
id="NYn" id="NYn"
x="811.52887" x="811.52887"
@ -683,50 +477,28 @@
style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">NY</tspan></text> style="font-size:13.3333px;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">NY</tspan></text>
<text <text
id="MEn" id="MEn"
x="901.54358" x="893.28827"
y="94.712509" y="89.306831"
style="font-size:16px"><tspan style="font-size:16px"><tspan
style="fill:#ffffff"
id="tspan101" /></text>
<text
id="MEn-9"
x="882.96747"
y="89.878593"
style="font-size:14.7521px;stroke-width:0.52686"><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan5" id="tspan4"
x="882.96747" x="893.28827"
y="89.878593" y="89.306831"
style="fill:#ffffff;stroke-width:0.52686">ME</tspan></text> style="text-align:center;text-anchor:middle;fill:#ffffff">ME</tspan></text>
<text
id="MEn-9-7"
x="877.93567"
y="111.5111"
style="font-size:14.7521px;stroke-width:0.52686"><tspan
sodipodi:role="line"
id="tspan4-0"
x="877.93567"
y="111.5111"
style="fill:#ffffff;stroke-width:0.52686" /><tspan
sodipodi:role="line"
id="tspan5-9"
x="877.93567"
y="129.95123"
style="fill:#ffffff;stroke-width:0.52686" /></text>
<text <text
id="MEn-9-0" id="MEn-9-0"
x="459.24854" x="461.50092"
y="239.60818" y="235.77916"
style="font-size:14.7521px;stroke-width:0.52686"><tspan style="font-size:14.7521px;stroke-width:0.52686"><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan4-6" id="tspan4-6"
x="459.24854" x="461.50092"
y="239.60818" y="235.77916"
style="fill:#ffffff;fill-opacity:1;stroke-width:0.52686">II</tspan><tspan style="fill:#ffffff;fill-opacity:1;stroke-width:0.52686">S</tspan><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan5-2" id="tspan5-2"
x="459.24854" x="461.50092"
y="258.04831" y="254.21928"
style="fill:#ffffff;fill-opacity:1;stroke-width:0.52686" /></text> style="fill:#ffffff;fill-opacity:1;stroke-width:0.52686" /></text>
<text <text
id="DemL" id="DemL"
@ -740,17 +512,10 @@
<g <g
font-size="22" font-size="22"
id="g2"> id="g2">
<text
id="NHn"
x="817.56848"
y="56.648579"
style="font-size:16px"><tspan
style="font-size:16px;fill:#ffffff"
id="tspan92" /></text>
<text <text
id="VTn" id="VTn"
x="818.22137" x="818.83032"
y="81.230995" y="82"
style="font-size:16px"><tspan style="font-size:16px"><tspan
style="fill:#ffffff" style="fill:#ffffff"
id="tspan93">VT</tspan></text> id="tspan93">VT</tspan></text>
@ -802,7 +567,7 @@
y="327" y="327"
style="font-size:16px"><tspan style="font-size:16px"><tspan
style="font-size:16px;fill:#ffffff" style="font-size:16px;fill:#ffffff"
id="tspan100" /></text> id="tspan100">DC 3</tspan></text>
</g> </g>
</g> </g>
<!-- <!--
@ -811,11 +576,11 @@
--> -->
<path <path
id="lines" id="lines"
d="m 854.7108,74.76564 -0.002,-5.99e-4 M 832,86 l 8,17 m 49,50 34,3 m -41,22 41,12 m -57,-6 51,33 m -72,13 50,22 m -58,-2 51,26 m -55,-15 46,33 m -79,-43 0.002,7e-5" d="m 832,86 8,17 m 49,50 34,3 m -41,22 41,12 m -57,-6 51,33 m -72,13 50,22 m -58,-2 51,26 m -55,-15 46,33"
stroke="#000" stroke="#000"
stroke-width="1.6" stroke-width="1.6"
style="stroke:#fdfdfd;stroke-opacity:1" style="stroke:#fdfdfd;stroke-opacity:1"
sodipodi:nodetypes="cccccccccccccccccc" /> sodipodi:nodetypes="cccccccccccccc" />
<path <path
id="frames" id="frames"
d="M215,493v55l36,45 M0,425h147l68,68h85l54,54v46" d="M215,493v55l36,45 M0,425h147l68,68h85l54,54v46"

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View file

@ -1,6 +1,7 @@
enum VoteType { enum VoteType {
Electoral, Electoral,
Popular, Popular,
Senate,
} }
export default VoteType; export default VoteType;

View file

@ -9,7 +9,8 @@ export default interface Election {
candidates : { candidates : {
name : string, name : string,
party : string, party : string,
color : string color : string,
startingSeats? : number
}[], }[],
states : { states : {
[key : string] : { [key : string] : {

View file

@ -0,0 +1,307 @@
import { readFile } from "node:fs/promises";
import Election from "../election.js";
import VoteType from "../VoteType.js";
const Senate_2024 = {
title: "2024 United States Senate Election Simulator",
shortname: "2024",
description: "The CalubViem Press has called the 2024 United States Senate for $WINNER!",
voteType: VoteType.Senate,
svg: await readFile("assets/Senate2024.svg", "utf-8"),
candidates: [
{
name: "Democrats",
party: "Democratic",
color: "#1C408C",
startingSeats: 29,
},
{
name: "Republicans",
party: "Republican",
color: "#BF1D29",
startingSeats: 37,
},
{
name: "Independent",
party: "Independent",
color: "#BFAB22",
startingSeats: 0,
}
],
states: {
"AZ": {
odds: {
"Democratic": 0.51,
"Republican": 0.48,
"Independent": 0.01,
},
population: 2326300 // using 2018 turnout for all of these
},
"CA": {
odds: {
"Democratic": 0.67,
"Republican": 0.33,
"Independent": 0,
},
population: 11113364
},
"CT": {
odds: {
"Democratic": 0.65,
"Republican": 0.37,
"Independent": 0,
},
population: 1371296
},
"DE": {
odds: {
"Democratic": 0.65,
"Republican": 0.37,
"Independent": 0,
},
population: 354512
},
"FL": {
odds: {
"Republican": 0.57,
"Democratic": 0.44,
"Independent": 0,
},
population: 8188977
},
"HI": {
odds: {
"Democratic": 0.70,
"Republican": 0.34,
"Independent": 0,
},
population: 388351
},
"IN": {
odds: {
"Republican": 0.63,
"Democratic": 0.39,
"Independent": 0,
},
population: 2181553
},
"ME": {
odds: {
"Independent": 0.60,
"Republican": 0.30,
"Democratic": 0.15,
},
population: 634345
},
"MD": {
odds: {
"Democratic": 0.61,
"Republican": 0.37,
"Independent": 0,
},
population: 2188631
},
"MA": {
odds: {
"Democratic": 0.65,
"Republican": 0.34,
"Independent": 0.01,
},
population: 2612581
},
"MI": {
odds: {
"Democratic": 0.52,
"Republican": 0.47,
"Independent": 0,
},
population: 4153296
},
"MN": {
odds: {
"Democratic": 0.64,
"Republican": 0.34,
"Independent": 0,
},
population: 2506611
},
"MS": {
odds: {
"Republican": 0.60,
"Democratic": 0.37,
"Independent": 0,
},
population: 917186
},
"MO": {
odds: {
"Republican": 0.60,
"Democratic": 0.36,
"Independent": 0,
},
population: 2367862
},
"MT": {
odds: {
"Republican": 0.51,
"Democratic": 0.49,
"Independent": 0,
},
population: 489839
},
"NE": {
odds: {
"Republican": 0.61,
"Independent": 0.34,
"Democratic": 0.34,
},
population: 673068
},
"NE-02": {
odds: {
"Republican": 0.60,
"Democratic": 0.36,
"Independent": 0,
},
population: 673068
},
"NV": {
odds: {
"Democratic": 0.51,
"Republican": 0.48,
"Independent": 0,
},
population: 931273
},
"NJ": {
odds: {
"Democratic": 0.61,
"Republican": 0.30,
"Independent": 0.20,
},
population: 3069009
},
"NM": {
odds: {
"Democratic": 0.62,
"Republican": 0.37,
"Independent": 0.01,
},
population: 697012
},
"NY": {
odds: {
"Democratic": 0.65,
"Republican": 0.33,
"Independent": 0,
},
population: 6055151
},
"ND": {
odds: {
"Republican": 0.61,
"Democratic": 0.34,
"Independent": 0,
},
population: 324096
},
"OH": {
odds: {
"Democratic": 0.54,
"Republican": 0.46,
"Independent": 0,
},
population: 4409887
},
"PA": {
odds: {
"Democratic": 0.52,
"Republican": 0.48,
"Independent": 0,
},
population: 4927285
},
"RI": {
odds: {
"Democratic": 0.62,
"Republican": 0.37,
"Independent": 0,
},
population: 375898
},
"TN": {
odds: {
"Republican": 0.62,
"Democratic": 0.37,
"Independent": 0,
},
population: 2212933
},
"TX": {
odds: {
"Republican": 0.59,
"Democratic": 0.41,
"Independent": 0.01,
},
population: 8306185
},
"UT": {
odds: {
"Republican": 0.64,
"Democratic": 0.31,
"Independent": 0,
},
population: 993756
},
"VT": {
odds: {
"Independent": 0.70,
"Republican": 0.25,
"Democratic": 0,
},
population: 258464
},
"VA": {
odds: {
"Democratic": 0.58,
"Republican": 0.40,
"Independent": 0,
},
population: 3284683
},
"WA": {
odds: {
"Democratic": 0.60,
"Republican": 0.38,
"Independent": 0,
},
population: 3086168
},
"WV": {
odds: {
"Republican": 0.62,
"Democratic": 0.33,
"Independent": 0,
},
population: 561623
},
"WI": {
odds: {
"Democratic": 0.55,
"Republican": 0.46,
"Independent": 0,
},
population: 2657799
},
"WY": {
odds: {
"Republican": 0.75,
"Democratic": 0.2,
"Independent": 0,
},
population: 197437
},
}
}
export default Senate_2024 as Election;

View file

@ -7,6 +7,7 @@ import Presidential_1940 from "./1940.js";
import Presidential_1968 from "./1968.js"; import Presidential_1968 from "./1968.js";
import Presidential_1992 from "./1992.js"; import Presidential_1992 from "./1992.js";
import Presidential_2024 from "./2024.js"; import Presidential_2024 from "./2024.js";
import Senate_2024 from "./2024_senate.js";
import NK_2019 from "./NK2019.js"; import NK_2019 from "./NK2019.js";
import ROC_2024 from "./ROC2024.js"; import ROC_2024 from "./ROC2024.js";
@ -25,6 +26,7 @@ const Elections = {
"2008": Presidential_2008, "2008": Presidential_2008,
*/ */
"2024": Presidential_2024, "2024": Presidential_2024,
"senate_2024": Senate_2024,
// Other // Other
"nk2019": NK_2019, "nk2019": NK_2019,
"roc2024": ROC_2024, "roc2024": ROC_2024,

View file

@ -165,7 +165,7 @@ if (!config.token) {
.addFields(result.candidates.map(c => { .addFields(result.candidates.map(c => {
return { return {
name: `${(result.winner === c.name ? ":white_check_mark:" : "")} ${c.name} (${c.party})`, name: `${(result.winner === c.name ? ":white_check_mark:" : "")} ${c.name} (${c.party})`,
value: `${election.voteType === VoteType.Electoral ? `${c.electoralVotes} electoral votes\n` : ""}${c.votes.toLocaleString()} votes (${((c.votes / result.totalVotes) * 100).toFixed(2)}%)`, value: `${election.voteType === VoteType.Electoral ? `${c.electoralVotes} electoral votes\n` : ""}${election.voteType === VoteType.Senate ? `${c.seats} seats\n` : ""}${c.votes.toLocaleString()} votes (${((c.votes / result.totalVotes) * 100).toFixed(2)}%)`,
inline: true inline: true
} }
})) }))

View file

@ -19,6 +19,7 @@ export function MakePrediction(election : Election, overlay_image?: string, over
party: candidate.party, party: candidate.party,
votes: 0, votes: 0,
electoralVotes: 0, electoralVotes: 0,
seats: candidate.startingSeats,
}); });
} }
@ -32,6 +33,9 @@ export function MakePrediction(election : Election, overlay_image?: string, over
if (election.voteType === VoteType.Electoral) { if (election.voteType === VoteType.Electoral) {
pred.candidates.find((c : any) => c.party === winner).electoralVotes += election.states[state].electoralVotes; pred.candidates.find((c : any) => c.party === winner).electoralVotes += election.states[state].electoralVotes;
} }
if (election.voteType === VoteType.Senate) {
pred.candidates.find((c : any) => c.party === winner).seats += 1;
}
for (const candidate of election.candidates) { for (const candidate of election.candidates) {
pred.candidates.find((c : any) => c.party === candidate.party).votes += votes[candidate.party]; pred.candidates.find((c : any) => c.party === candidate.party).votes += votes[candidate.party];
} }
@ -74,6 +78,8 @@ export function MakePrediction(election : Election, overlay_image?: string, over
pred.winner = pred.candidates.sort((a : any, b : any) => b.electoralVotes - a.electoralVotes)[0].name; pred.winner = pred.candidates.sort((a : any, b : any) => b.electoralVotes - a.electoralVotes)[0].name;
else if (election.voteType === VoteType.Popular) else if (election.voteType === VoteType.Popular)
pred.winner = pred.candidates.sort((a : any, b : any) => b.votes - a.votes)[0].name; pred.winner = pred.candidates.sort((a : any, b : any) => b.votes - a.votes)[0].name;
else if (election.voteType === VoteType.Senate)
pred.winner = pred.candidates.sort((a : any, b : any) => b.seats - a.seats)[0].name;
pred.totalVotes = pred.candidates.reduce((a : any, b : any) => a + b.votes, 0); pred.totalVotes = pred.candidates.reduce((a : any, b : any) => a + b.votes, 0);
pred.svg = draw.svg(); pred.svg = draw.svg();
pred.png = png; pred.png = png;
@ -87,6 +93,7 @@ export interface Prediction {
name : string, name : string,
party : string, party : string,
electoralVotes : number, electoralVotes : number,
seats : number,
votes : number, votes : number,
}[], }[],
winner: string, winner: string,