Question: How to simulate the card game war

Just for fun last night I thought I'd try to whip up a simulation of the simple card game war.  The hoyle rulebook - evenly divide the cards up between 2 players facedown, turn over top card, highest card wins.  In the event of a tie the higher of the next overturned card wins (the more common variant is to play 3 facedown cards and turn up the 4th) - but that introduces more complexity to the programming ... I thought I'd tackle that later, but first ...

So it seemed simple enough, in thought anyway I would have the programming complete in about 5 minutes, but  I'm stuck after only one iteration.

I thought I would just start out with two small lists and try to get it working from there also leaving out any tie events as it was complicating matters. 

restart; gc()
with(combinat):
container:=[1,2,3,4,5,6,7,8]  # create a container of values to choose from.

a:=randcomb(container,4)  # randomly select 4 numbers from the container
b:=[op( {op(container) } minus { op(a) } ) ]   # select the remaining 4

a:=randperm(a):  b:=randperm(b):  # shuffle the list

c:=[ ]:     # empty container for a's winnings
d:=[ ]:     # empty container for b's winnings

for i from 1 to min(nops(a),nops(b) do
  if a[i] > b[i] then c:=[ op(c),a[i],b[i] ] elif b[i] > a[i] then d:=[ op(d),a[i],b[i] ] end if:
end do:
a:=randperm(c);     # randomly shuffle a's winnings and store back into a
b:=randperm(d);     # randomly shuffle b's winnings back into b

I'm not really sure how to move on from here? 

Please Wait...