Just a quick answer here, war actually is a game, because how players pick up the cards, affects the outcome. You can choose to pick up the cards in different orders after each round. But it is very difficult to play strategically.
As for the question at hand, I built my own simulation, and for 5 trials, with shuffling, I got:
58, 144, 354, 428, 189
This comes to an average of 234 rounds. Obviously, you can do more trials, to get a more accurate number, but it's definitely a long game to play!
My source code is
<html>
<head>
<script>
window.addEventListener("load", () => goto(WAR));
// player decks and discards
let D1, D2, TABLE, ROUND;
function rank(x){
let r = (x%13) + 1;
if(r == 1) r = 14;
return r;
}
function card(x){
let r = rank(x);
let suit = Math.floor(x/13);
if(r > 10){
r = ["Jack", "Queen", "King", "Ace"][r - 11]; }
suit = ["Clubs", "Spades", "Hearts", "Diamonds"][suit];
return `${r} of ${suit}`;
}
function deck(){
return [...Array(52).keys()];
}
function shuffle(d){
if(!d) d=deck();
for(let i=0; i<d.length; ++i){
let j = i + Math.floor((d.length-i) * Math.random());
[d[i], d[j]] = [d[j], d[i]];
}
return d;
}
function draw(d,n,result){
if(!d) d=deck();
if(!n) n = 1;
if(!result) result = [];
n = Math.min(n, d.length);
for(let i=0; i<n; ++i){
result.push(d.shift()); }
return result;
}
function ShowCounts(next){
return next;
}
function WAR(){
D1 = shuffle();
D2 = draw(D1, 26);
console.log(D1, D2);
TABLE = [];
ROUND = 1;
disp(`Welcome to War`);
return WAIT;
}
function WAIT(){
let handlers = [];
more(`Press [Enter] or click anywhere to continue.`);
wait(handlers, document.body, 'mousedown', null, FIGHT);
wait(handlers, document.body, 'keydown', (e)=>(e.keyCode == 13), FIGHT);
return null;
}
function FIGHT(){
disp(`Fight! (Round ${ROUND++})`);
more(`Player 1: ${D1.length} cards.`);
more(`Player 2: ${D2.length} cards.`);
more();
if(D1.length == 0 || D2.length == 0) return END;
let a = D1.shift();
let b = D2.shift();
TABLE.push(a);
TABLE.push(b);
more(`${card(a)} vs ${card(b)}.`);
let x = rank(a);
let y = rank(b);
if(x == y){
return TIE; }
let winner = (x > y)? D1 : D2;
more(`Player ${x>y? 1 : 2} wins ${TABLE.length} cards.`);
draw(shuffle(TABLE), TABLE.length, winner);
more();
return WAIT;
}
function TIE(){
more("Round is tied.");
more("Each player draws 3 more facedown cards.");
draw(D1, 3, TABLE);
draw(D2, 3, TABLE);
if(D1.length == 0 || D2.length == 0){
return END; }
return sleep(0.0, FIGHT);
}
function END(){
if(D1.length > D2.length){
disp("Player 1 Wins!"); }
else{
disp("Player 2 Wins!"); }
more(`After ${ROUND} rounds.`);
return RESTART;
}
function RESTART(){
return sleep(2.5, ()=>{
more("Restarting ...");
sleep(2.5, WAR)})
}
function goto(target){ // targets return the next function to run.
while(target){
target = target(); }
}
function wait(handlers, target, name, test, after){
if(!handlers) handlers = [];
let handler = function(evt){
if(test && !test(evt)) return;
for(let tuple of handlers){
let [other_target, other_name, other_handler] = tuple;
other_target.removeEventListener(other_name, other_handler);
}
goto(after);
}
handlers.push([target, name, handler]);
target.addEventListener(name, handler);
return null;
}
function sleep(n, after){
setTimeout(()=>goto(after), n*1000);
return null;
}
function disp(x){
if(x == undefined) x = "";
document.getElementById("disptext").innerHTML = x;
}
function more(x){
if(x == undefined) x = "";
document.getElementById("disptext").innerHTML += "\n" + x;
}
function randint(n){
return Math.floor(Math.random() * n);
}
function Download(){
var zip = new JSZip();
// Generate a directory within the Zip file structure
var guessgame = zip.folder("war");
guessgame.file("index.html", document.documentElement.outerHTML);
// Generate the zip file asynchronously
zip.generateAsync({type:"blob"}).then(function(content){
// Force down of the Zip file
saveAs(content, "wargame.zip");
});
}
</script>
<style>
*{ font-size: 108%; font-family: monospace; }
#editor{ height: 70%; width: 100%; overflow-x: scroll; }
</style>
</head>
<body>
<p><pre id="disptext"></pre></p>
<!--<input id='textinput' type='text'></input>
<input id='okaybutton' type='button' value="ok"></input>-->
<!-- <p style="position: fixed; bottom: 0px; right:8px; text-align: right;"> -->
<p>
<!-- <h3> Source Code </h3> -->
<!--<button onclick="editor.innerHTML = document.documentElement.outerHTML; editor.style.display='block'"> View </button>-->
<!--<button onclick="Download();"> Download Game</button>-->
</p>
<p>
<textarea id='editor' wrap='off' style="display:none;" readonly="true"></textarea>
</p>
</body>
</html>