• One From The Vault: Connect-4 (v2) (2K)

    From Cameron Kaiser@21:1/5 to All on Mon Jun 8 17:40:02 2020
    ******************************************************************
    *** ***
    *** comp.binaries.cbm is a moderated binaries- ***
    *** only newsgroup (no discussion or ***
    *** crossposting allowed) for Commodore 8-bits ***
    *** ***
    *** For information on comp.binaries.cbm visit ***
    *** http://www.floodgap.com/comp.binaries.cbm/ ***
    *** ***
    *** This file is available via mailing list at ***
    *** http://lists.trikaliotis.net/listinfo/comp-binaries-cbm/ ***
    *** to list subscribers ***
    *** Allow time for submission to be received ***
    *** ***
    ******************************************************************

    * One from the Vault is a collection of frequently requested, useful or just
    plain interesting past posts sent to comp.binaries.cbm, as archived by the
    moderators. If you have a request, please send it to the address in the
    headers. In addition to being selected and reposted by moderation staff,
    some of these postings are regularly posted on Mondays and Fridays on a
    rotating schedule.

    Take care when replying to these messages, as many were posted years ago.


    From: Keith Pomakis <pomakis@pobox.com>
    Reply-to: Keith Pomakis <pomakis@pobox.com>
    X-Original-Posting-Date: Sat, 24 May 1997 14:47:32 -0400 (EDT)

    Hello!

    [Note: This is a newer version of the game "connect4" than was posted last fall. It is approximately five times faster.]

    I thought I'd share with the rest of the Commodore world a little program I recently wrote. It's a game of Connect-4, where the human player tries to
    beat the computer. In case you're not familiar with the rules of the game, they are as follows:

    Connect-4 is a two-player game in which one player is designated `X'
    and the other is designated `O'. Each player has a stack of chips. A
    7x6 board is placed between the two players, propped up vertically. It
    has seven `slots' at the top of it, one slot for each column. When a
    game chip is dropped into one of these slots, it slides down until it
    either rests at the bottom of the board or on top of another chip. The
    two players take turns dropping a chip into a slot of their choice.
    The first player to connect four of his/her color in a row is the
    winner. This connection can be vertical, horizontal or diagonal, but
    it must lie in a straight line and must be connected.

    In this computerized version of the game, a human (`X') plays a computer opponent (`O'). At the beginning of each game you will be asked what skill level you wish the computer to play at. This is equivalent to the number
    of moves the computer looks ahead in the game. On a stock C=64, skill
    levels 4 and 5 are good levels (any less and the computer is easy to beat,
    any more and the computer takes too long to make a move). If you have the
    new 20Mhz accelerator chip from CMD, you can comfortably play a game at
    level 6 and enjoy a more challenging game.

    The first thing you'll notice about the game is that it has a very simple interface. There are no fancy graphics or sound effects. The main
    challenge of writing this game was to prove to myself that I could write a challenging Connect-4 AI routine that would be fast and efficient enough to
    be playable on an 8-bit 1Mhz machine. A secondary goal of mine was to
    squeeze the game into as few bytes as possible. I managed to achieve both goals, and thus I present to you a challenging Connect-4 game for the
    Commodore 64 that is a mere 1520 bytes in size.

    The AI algorithm used in this game is based on an algorithm I developed in
    LISP about four years ago. Since then I've converted the LISP code into
    more portable, more generic ANSI C code, and have written a few interfaces
    to this code (one of which is an HTML interface, playable via the World-
    Wide Web - see "http://www.pobox.com/~pomakis/c4/"). This C=64 version was written entirely in 6502 assembly language using the BUDDY assembler.

    Without further adue (I've rambled on long enough), here's the game. Just
    load and run it as you would a BASIC program. Press 'Q' or '0' at any time
    to abort a game or return to BASIC. Feel free to e-mail me with any
    comments you might have on the game.

    -nucode-begin 1 connect4
    begin 640 connect4 M`0A*"```GC(Q,C0ZCR*3C0D.PT].3D5#5"`TC8U"62#+14E42"#03TU!2TE3 MC5!/34%+25-`4$]"3U@N0T]-C<U!62P@,3DY-XT```"B$[4&G>X-RM#XJ0V% M^ZD(A?P@L0@@Q0BB$[WN#94&RM#X8""Q""#D_\D`\/G)4=`'(-+_H`#P$<DP M,!/).!`/2"#2_V@XZ3"H(,`(3,`(K"#0J0*-(-"EHAAI!,6BT/R,(-#PP4B@ M`+'[\`8@TO_(T/9H8*D-3-+_(.T)J72%^ZD)A?P@;PC``-`!8(0+J0"%!R"K M":"\L0C)__`.J:*%^ZD)A?P@L0A,Q0B@O;$(R0?0`6"D![ER"8V#":E]A?NI M"87\(&\(P`#PKH@@)PJPXR"K"2#`"*"\L0C)__`.J9>%^ZD)A?P@L0A,Q0B@ MO;$(R0?0#JF0A?NI"87\(+$(3,4(I0=)`84'J8>%^ZD)A?P@L0@@&`L@P`@@ MP`BE!TD!A0=,W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#`T2#1L-)PTU#4$-2@T``%`-5@U?#6L->0V%#8X- M``"4#9D-H`VI#;0-O0W$#0``R0W-#=(-V`W@#>8-ZPT#&"W_`P(;,/\#`@0> M,_\#`@0!!0`&_P($`20\_P0!)S__`2I"_R$8&2[_(38;'"TQ_R$V.1X?,#0& M_R$V.0<%(C,W.CS_-CD')"4`/3__.0<G*$!"_P<J*T/_"!@9&B__"`D;'!TN M,@;_"`D*'A\@+3$U.CS_"`D*"P4B(S`T.#L]/_\)"@LD)28S-SY`0O\*"R<H M*0!!0_\+*BLL1/\,&!D:!O\,#1L<'2\Z//\,#0X>'R`N,CL]/_\,#0X/!2(C M+3$U/D!"_PT.#R0E)C`T.$%#_PX/)R@I,S=$_P\J*RP`_Q`9&CK_$!$<'3L] M_Q`1$A\@+SY`_Q`1$A,B(RXR04/_$1(3)28Q-43_$A,H*30X_Q,K+#?_%!H[ C_Q05'3[_%!46($'_%!46%R,O1/\5%A<F,O\6%RDU_Q<L./\`
    `
    end
    -nucode-end 1 1520 588dc775

    .--------------------+--------------------------------------------.
    | Keith Pomakis | Don't take life too seriously. |
    | pomakis@pobox.com | After all, you'll never make it out alive. | +--------------------+--------------------------------------------+
    | WWW home page: "http://www.pobox.com/~pomakis/" | `-----------------------------------------------------------------'

    --
    Cameron Kaiser * ckaiser@floodgap.com * posting with a Commodore 128
    Floodgap Systems: http://www.floodgap.com/
    personal page: http://www.cameronkaiser.com/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)