RISK probabilities

I played the old game Risk and thought that at table with probabilities would be nice to have sometimes. So I made one.

Below are the probabilities of winning if you over and over attack the same country and from the beginning you have i troops and the opponent has j troops. The table supposes you always attack with the maximum number of troops you can attack with (=min(3,number of troops you have)), I am quite sure that strategy is optimal. The numbers of troops you attack with are in the rows, the number of troops the opponent uses in the columns. They might be totally wrong, I dunno, they look quite reasonable. I made them up with a simple program I wrote in ten minutes.

1234567891011121314151617181920212223242526272829
141.66667%10.60957%2.70151%0.68788%0.17516%0.04460%0.01136%0.00289%0.00074%0.00019%0.00005%0.00001%0.00000%0.00000%0.00000%0.00000%0.00000%0.00000%0.00000%0.00000%0.00000%0.00000%0.00000%0.00000%0.00000%0.00000%0.00000%0.00000%0.00000%
275.42438%36.26543%20.60664%9.13035%4.91348%2.13505%1.13288%0.48967%0.25881%0.11170%0.05897%0.02544%0.01343%0.00579%0.00306%0.00132%0.00070%0.00030%0.00016%0.00007%0.00004%0.00002%0.00001%0.00000%0.00000%0.00000%0.00000%0.00000%0.00000%
391.63746%65.59540%47.02511%31.49943%20.59419%13.36985%8.37418%5.35023%3.27695%2.07540%1.25542%0.79114%0.47513%0.29854%0.17853%0.11198%0.06679%0.04185%0.02493%0.01561%0.00929%0.00581%0.00346%0.00216%0.00129%0.00080%0.00048%0.00030%0.00018%
497.15441%78.54543%64.16229%47.65309%35.86062%25.25027%18.14856%12.33954%8.61723%5.71907%3.91677%2.55451%1.72527%1.11063%0.74234%0.47311%0.31370%0.19835%0.13069%0.08211%0.05382%0.03364%0.02196%0.01366%0.00889%0.00551%0.00357%0.00221%0.00143%
599.03171%88.97887%76.93749%63.82946%50.62028%39.67536%29.74181%22.40476%16.15579%11.82753%8.29203%5.94240%4.07854%2.87518%1.94097%1.35060%0.89977%0.61954%0.40830%0.27870%0.18203%0.12336%0.07996%0.05385%0.03468%0.02323%0.01488%0.00992%0.00632%
699.67051%93.39797%85.69198%74.48749%63.77205%52.06826%42.33302%32.94825%25.77745%19.34338%14.69768%10.72073%7.96256%5.67884%4.14194%2.90072%2.08466%1.43823%1.02104%0.69565%0.48880%0.32951%0.22951%0.15331%0.10598%0.07024%0.04824%0.03175%0.02168%
799.88788%96.66495%90.99420%83.37390%73.63956%64.00731%53.55339%44.55806%35.69336%28.67610%22.18670%17.33135%13.03884%9.95613%7.32065%5.48617%3.95801%2.92021%2.07340%1.50969%1.05743%0.76131%0.52703%0.37576%0.25750%0.18204%0.12364%0.08676%0.05846%
899.96185%98.03082%94.67994%88.78009%81.84101%72.95558%64.29414%54.73596%46.39852%37.98720%31.17313%24.70449%19.73474%15.22116%11.88937%8.96380%6.87079%5.08124%3.83283%2.78820%2.07442%1.48771%1.09375%0.77474%0.56368%0.39495%0.28473%0.19759%0.14129%
999.98702%99.01146%96.69917%92.98201%87.29365%80.76408%72.60798%64.64118%55.80698%47.99353%39.98733%33.37489%26.97147%21.94329%17.27681%13.75261%10.58886%8.27265%6.24819%4.80325%3.56776%2.70443%1.97971%1.48231%1.07125%0.79344%0.56692%0.41587%0.29415%
1099.99558%99.41952%98.10996%95.39335%91.62835%86.10911%79.98330%72.39700%65.00598%56.75929%49.39522%41.74948%35.33829%29.02606%23.98018%19.21139%15.54036%12.18213%9.67480%7.44129%5.81543%4.39883%3.38942%2.52626%1.92234%1.41415%1.06417%0.77374%0.57649%
1199.99850%99.70930%98.83882%97.20410%94.30417%90.52209%85.20487%79.41151%72.30344%65.38261%57.62945%50.65002%43.32782%37.11006%30.90396%25.86774%21.03434%17.25231%13.73603%11.06577%8.64751%6.85658%5.27012%4.12006%3.12035%2.40886%1.80040%1.37426%1.01499%
1299.99949%99.82967%99.34924%98.19904%96.37007%93.35412%89.61223%84.48643%78.98809%72.28362%65.76179%58.42981%51.78670%44.75635%38.72336%32.63143%27.62416%22.75461%18.89014%15.24621%12.43767%9.85694%7.91645%6.17208%4.88803%3.75536%2.93685%2.22661%1.72160%
1399.99983%99.91478%99.60302%98.93183%97.58133%95.61124%92.54099%88.85741%83.91562%78.67557%72.31940%66.14007%59.17362%52.82732%46.06187%40.20406%34.23001%29.26510%24.38098%20.45691%16.71064%13.78523%11.06221%8.98692%7.09669%5.68609%4.42523%3.50146%2.68926%
1499.99994%99.95011%99.78097%99.32126%98.49793%96.99124%94.92899%91.83846%88.22651%83.45706%78.44710%72.39515%66.51474%59.86947%53.78798%47.26425%41.57215%35.71695%30.80373%25.92153%21.95621%18.12876%15.10502%12.25785%10.06155%8.03731%6.50792%5.12444%4.09810%
1599.99998%99.97505%99.86710%99.60467%99.01508%98.06471%96.44142%94.31805%91.23122%87.69618%83.08786%78.28395%72.50098%66.88436%60.52441%54.68113%48.37909%42.84355%37.10638%32.25127%27.38365%23.39187%19.50096%16.39493%13.43981%11.13527%8.98841%7.34811%5.84806%
1699.99999%99.98540%99.92754%99.75137%99.40087%98.69662%97.64389%95.93290%93.77194%90.70417%87.24830%82.79018%78.17233%72.62947%67.24804%61.14385%55.51645%49.41867%44.03106%38.41001%33.61731%28.77399%24.76776%20.82825%17.65381%14.60518%12.20412%9.94545%8.20203%
17100.00000%99.99270%99.95621%99.85729%99.61209%99.17959%98.37706%97.24161%95.46573%93.28390%90.24556%86.86880%82.55074%78.10194%72.77523%67.60530%61.73218%56.30168%50.39290%45.14514%39.63758%34.91008%30.09853%26.08760%22.11200%18.88118%15.75186%13.26498%10.90467%
18100.00000%99.99573%99.97635%99.91097%99.76801%99.45533%98.94898%98.06273%96.86106%95.03785%92.84756%89.84544%86.54654%82.35923%78.06494%72.93423%67.95589%62.29297%57.04306%51.30984%46.19442%40.79732%36.13667%31.36263%27.35495%23.35381%20.07702%16.87841%14.31547%
19100.00000%99.99786%99.98575%99.94951%99.85132%99.66331%99.28704%98.71495%97.75796%96.50351%94.64673%92.45713%89.49568%86.27264%82.20758%78.05524%73.10338%68.29974%62.82916%57.74574%52.17615%47.18612%41.89623%37.30324%32.57108%28.57315%24.55539%21.24169%17.98389%
20100.00000%99.99875%99.99236%99.96870%99.91234%99.77909%99.54687%99.11172%98.48175%97.46528%96.16913%94.28956%92.10747%89.18947%86.03989%82.08937%78.06805%73.28031%68.63687%63.34322%58.41396%52.99740%48.12631%42.94027%38.41517%33.72818%29.74531%25.71849%22.37573%
21100.00000%99.99937%99.99541%99.98243%99.94429%99.86553%99.69653%99.42191%98.93300%98.25240%97.18615%95.85738%93.96357%91.79407%88.92112%85.84242%81.99943%78.09956%73.46317%68.96735%63.83725%59.05130%53.77826%49.02018%43.93460%39.47714%34.83781%30.87433%26.84485%
22100.00000%99.99963%99.99756%99.98917%99.96755%99.91264%99.81022%99.60575%99.29117%98.75363%98.02897%96.92127%95.56737%93.66607%91.51296%88.68587%85.67539%81.93356%78.14670%73.65048%69.29134%64.31302%59.66079%54.52273%49.87216%44.88369%40.49330%35.90341%31.96287%
23100.00000%99.99982%99.99853%99.99397%99.97952%99.94752%99.87427%99.74764%99.50872%99.15691%98.57567%97.81284%96.67081%95.29797%93.39459%91.26067%88.47966%85.53476%81.88831%78.20695%73.84110%69.60899%64.77207%60.24501%55.23423%50.68606%45.79144%41.46731%36.92812%
24100.00000%99.99989%99.99922%99.99630%99.98819%99.96619%99.92247%99.82987%99.67907%99.40716%99.02097%98.40068%97.60490%96.43464%95.04799%93.14683%91.03418%88.29907%85.41715%81.86079%78.27825%74.03407%69.92046%65.21573%60.80620%55.91569%51.46521%46.66127%42.40241%
25100.00000%99.99995%99.99954%99.99796%99.99259%99.97992%99.94911%99.89267%99.78023%99.60569%99.30255%98.88483%98.22976%97.40566%96.21239%94.81619%92.92071%90.83084%88.14115%85.31972%81.84863%78.35892%74.22865%70.22595%65.64518%61.34629%56.56970%52.21252%47.49621%
26100.00000%99.99997%99.99975%99.99875%99.99577%99.98716%99.96900%99.92836%99.85855%99.72614%99.52860%99.19612%98.74962%98.06372%97.21538%96.00357%94.60137%92.71433%90.64832%88.00338%85.24003%81.84980%78.44751%74.42422%70.52564%66.06144%61.86698%57.19849%52.93055%
27100.00000%99.99998%99.99985%99.99931%99.99736%99.99245%99.97982%99.95538%99.90415%99.82056%99.66837%99.44876%99.08891%98.61626%97.90310%97.03410%95.80760%94.40238%92.52600%90.48457%87.88357%85.17601%81.86259%78.54284%74.62028%70.81971%66.46542%62.36975%57.80403%
28100.00000%99.99999%99.99992%99.99958%99.99850%99.99520%99.98784%99.97048%99.93911%99.87672%99.77920%99.60764%99.36703%98.98176%98.48544%97.74825%96.86176%95.62387%94.21811%92.35418%90.33778%87.77982%85.12588%81.88554%78.64390%74.81643%71.10835%66.85793%62.85591%
29100.00000%100.00000%99.99995%99.99977%99.99907%99.99720%99.99214%99.98182%99.95912%99.92030%99.84639%99.73497%99.54461%99.28413%98.87537%98.35766%97.59938%96.69819%95.45175%94.04754%92.19746%90.20637%87.69048%85.08810%81.91741%78.74983%75.01232%71.39173%67.23969%

And for all you coders, here is the source:

#include <stdio.h> #define MAX 30 double table[MAX][MAX]; void swap(int *a, int *b){ int t; t=*a; *a=*b; *b=t; } int main(void){ FILE *out=fopen("risk.html", "w"); int i, j, iloss, jloss; int a,b,c,d,e,a2,b2,c2,d2,e2; for(i=1;i<MAX;i++) table[i][0]=1; fprintf(out, "<tr><td></td>"); for(j=1;j<MAX;j++){ table[0][j]=0; fprintf(out, "<th>%d</th>", j); } fprintf(out, "</tr>\n"); for(i=1;i<MAX;i++){ fprintf(out, "<tr><th>%d</th>", i); for(j=1;j<MAX;j++){ // anfaller med i, försvarar med j for(a=1;a<=6;a++) for(b=1;b<=6;b++) for(c=1;c<=6;c++) for(d=1;d<=6;d++) for(e=1;e<=6;e++){ a2=a;b2=b;c2=c;d2=d;e2=e; if(i>1){ if(a2<b2)swap(&a2,&b2); if(i>2 && b2<c2)swap(&b2,&c2); if(a2<b2)swap(&a2,&b2); } if(j>1 && d2<e2)swap(&d2,&e2); iloss=jloss=0; if(a2>d2) jloss++; else iloss++; if(i>1 && j>1){ if(b2>e2) jloss++; else iloss++; } table[i][j]+=table[i-iloss][j-jloss]/(double)(6*6*6*6*6); } fprintf(out, "<td>%.5lf%%</td>", table[i][j]*(double)100); } fprintf(out, "</tr>\n"); } return 0; }