Author Topic: New and BETTER Challenge. Make a game 20-lines or less.  (Read 7726 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: New and BETTER Challenge. Make a game 20-lines or less.
« Reply #15 on: September 30, 2018, 08:55:27 pm »
Hey TempodiBasic!

Yeah! Your code reminded me of the first post I ever made on a forum, I called it "War and Peace". It ran a little longer than this:
Code: QB64: [Select]
  1. _TITLE "War for QB64 B+ 2018-09-30"
  2. DIM deck$(51)
  3. FOR i% = 0 TO 51
  4.     deck$(i%) = MID$(" 2 3 4 5 6 7 8 910 J Q K A", 2 * ((i% MOD 13)) + 1, 2) + MID$("", INT(i% / 13) + 1, 1)
  5. FOR i% = 51 TO 1 STEP -1 'shuffle
  6.     r% = INT(RND * i%) + 1
  7.     SWAP deck$(r%), deck$(i%)
  8. FOR i% = 0 TO 50 STEP 2
  9.     IF INSTR(" 2 3 4 5 6 7 8 910 J Q K A", LEFT$(deck$(i%), 2)) - INSTR(" 2 3 4 5 6 7 8 910 J Q K A", LEFT$(deck$(i% + 1), 2)) > 0 THEN p = p + t + 2
  10.     IF INSTR(" 2 3 4 5 6 7 8 910 J Q K A", LEFT$(deck$(i%), 2)) - INSTR(" 2 3 4 5 6 7 8 910 J Q K A", LEFT$(deck$(i% + 1), 2)) < 0 THEN ai = ai + t + 2
  11.     IF INSTR(" 2 3 4 5 6 7 8 910 J Q K A", LEFT$(deck$(i%), 2)) - INSTR(" 2 3 4 5 6 7 8 910 J Q K A", LEFT$(deck$(i% + 1), 2)) = 0 THEN t = t + 2 ELSE t = 0
  12.     PRINT deck$(i%); " vrs "; deck$(i% + 1); "  Player:"; p; " Opponent:"; ai; " Ties:"; t;
  13.     INPUT "   Enter to continue...", wate$
  14.  
  15.  

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: New and BETTER Challenge. Make a game 20-lines or less.
« Reply #16 on: October 01, 2018, 11:30:27 am »
Hi Bplus,
fine your War and Peace, the differences between pick highest card and War and Peace , IMHO, are
1. you project a tie option so the seed make no difference, while in my project the rule "Come Quando Fuori Piove = Cuori Quadri Fiori Picche" used also in the game of poker decides who wins when the value of the card is the same. In English Hearts Diamonds Clubs Spades from the higher to the lower.
2. in the code you have preferred to use the data as string while I have preferred to use data as integer number
3. you have choosen to create a deck of french cards of 52 cards, to shuffle it and to pick sequentially the cards, one for each player, until the deck is finished. To replay you must add a loop like DO..LOOP or a GOTO to the beginning of the code.
In the while I have choosen to create at moment one card for each player at each cycle of the game. This emulates that the cards used are put in the deck and this deck is shuffled at each cycle of the game.

Two version of the same game or if you prefer two similar games...
Thanks to read
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: New and BETTER Challenge. Make a game 20-lines or less.
« Reply #17 on: October 01, 2018, 01:17:21 pm »
Hi TempodiBasic,

In my actual game of War and Peace, I did use the suit to decide between ties in card value ie in times of Peace Hearts trump all (Hearts > Spades > Diamonds > Clubs) whereas in times of War, Clubs trumped all in reverse direction Clubs > Diamonds > Spades > Hearts. But this is not that game.

Now in the card game of WAR, which I depicted a shortened version here, there are no trump or suit favoritism, so when there is a tie, say Queen against Queen WAR is declared and the next person who gets highest card value gets all the cards that had tied. Here in this shortened version, I use points instead of cards and only go through deck once. It would take me more than 20 lines to simulate the actual card game of WAR fully (to which there is usually no end).

You call 52 card decks "french cards" ?

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: New and BETTER Challenge. Make a game 20-lines or less.
« Reply #18 on: October 01, 2018, 04:24:40 pm »
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: New and BETTER Challenge. Make a game 20-lines or less.
« Reply #19 on: October 01, 2018, 05:03:27 pm »
Cool card history!

Turns out I did not get the rules to "War" quite right. According to what I read here:
https://www.bicyclecards.com/how-to-play/war/

with a tie, 2 cards are put face down and then 2 more cards face up, highest card takes all 6 cards!

If another tie and winner on next turn, they would get 10 cards, 4 face down + 6 battle cards.
« Last Edit: October 01, 2018, 05:09:04 pm by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: New and BETTER Challenge. Make a game 20-lines or less.
« Reply #20 on: October 03, 2018, 04:57:51 am »
Thank Bplus
you let me to know  War and Peace that I thought it was an your game.
It is like a my local card game called Stoppa, yes War and Peace is not hazard game and it is simpler, but the logic behind is the same.
https://it.wikipedia.org/wiki/Stoppa_(gioco_di_carte) It needs deck of 40 cards to play.
Programming isn't difficult, only it's  consuming time and coffee