Giter Site home page Giter Site logo

bquast / who-academy-challenge-round-1-ron-grahams-game Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 1.31 MB

WHO Academy MLE Challenge Round 1: Ron Graham's Game with Optimiser

License: MIT License

Python 100.00%
ron-graham-game numeric-tic-tac-toe numeric-noughts-and-crosses aima game

who-academy-challenge-round-1-ron-grahams-game's Introduction

Ron Graham's Game

Ron Graham's Game is a numerical variant of Naughts and Crosses / Tic-Tac-Toe. In the general form, the board is a square matrix of length L >= 3, Player 1 has stones for all the Odd numbers in the range 1:L^2, Player 2 has stones for all the Even numbers in the range 2:(L^2-1), a player wins if it completes a row/column/diagonal and the sum equals (1:L)L/2.

Ron Graham's Game is the variant where L==3, it has shown that Ron Graham's Game has an optimal strategy for the Player 1 (Odds), the variant where L=4 has been shown to have an optimal strategy for Player 2 (Evens).

Markowsky's definition

In the Journal of Recreational Mathematics (ISSN: 0022-412X) Vol. 22(2) 114-123, 1990 George Markowsky defines Ron Graham's Game as follows:

Ron Graham's Game uses the standard 3x3 Tic-Tac-Toe board. Instead of calling the players X and O, we call them Odd and Even. Odd gets the numbers 1, 3, 5, 7, and 9, while Even gets the numbers 2, 4, 6, and 8. Odd goes first, after which the players take turns placing one of their numbers in the empty cells of the standard Tic-Tac-Toe board. Numbers may be used only once. The object of the game is to be the player who completes a line that sums to 15. As in Tic-Tac-Toe, a line is a row, column, or diagonal. Completing a line means putting the final number in the line so it sums to 15. Players are allowed to use numbers placed by the opponent to reach the sum of 15. Once a line contains two numbers whose sum is 15 or greater there is no way to complete that line, although filling in the remaining cell might be necessary to complete a different line. The setup for playing Graham's Game is quite simple. Start out with a piece of paper which has the familiar Tic-Tac-Toe board on it. To one side write a row with the numbers 1 3 5 7 9 in it and below it write a row with the numbers 2 4 6 8 in it. As the players use the numbers they must cross them off. Figure 1 shows the setup for playing Graham's Game. Before you read the analyses of Graham's Game, I recommend that you play it several times so you can form your own opinion about the best strategy.

Figure 1

Usage

The file RonGrahamsGame.py is a self contained Python 3 file including the game and the optimiser to play against, it can be executed using:

$ python RonGrahamsGame.py

It will first prompt you if you wish to level up (play against the optimiser), you can chose to do so, simply by pressing Enter (since it is the default option).

demonstration

Troubleshooting

If you encounter the error:

  File "RonGrahamsGame.py", line 71
    print('{} '.format(move), end='')
                             ^
SyntaxError: invalid syntax

This is caused by executing with Python 2 instead of Python 3, because your system has Python 2 as its default. In that case you can execute using:

$ python3 RonGrahamsGame.py

Development

RonGrahamsGame.py was developed with Python 3.8.3 on a Arch Linux machine with Kernel v.5.7.1, it should run on any Python 3 machine.

License

The LICENSE is MIT.

Attribution

The game implementation is adapted from Alec Roques, the optimiser is based on Peter Norvig's AIMA code.

who-academy-challenge-round-1-ron-grahams-game's People

Contributors

bquast avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.