Git Product home page Git Product logo

gomoku's Introduction

Gomoku engine

set up the environment

$ conda create --name gomoku python=3.10 -y

$ conda activate gomoku

$ python -m pip install -r requirements.txt

Develop your model

To develop your model, rewrite the take_action function in your main.py file under src/competition/competitors/<YourName>/main.py.

Competition

To run a competition, this command should be run:

python -m src.competition.run_competition

Development

Running the tests:

$ python -m unittest discover

Running pre-commit for all files (recommended before commit):

$ pre-commit run --all

Running pre-commit for given files:

$ pre-commit run --files some_file.py some_file_2.py

Using the engine

>>> from src.engine import GomokuEngine
>>> from src.state import Action
>>>
>>> engine = GomokuEngine(3, win_len=3)
>>> print(engine.state.board)
[[0 0 0]
 [0 0 0]
 [0 0 0]]
>>> actions = engine.state.get_possible_actions()
>>> len(actions)
9
>>> actions[0]
Action(row=0, col=0)
>>>
>>> state = engine.step(actions[0])
>>> print(engine.state.board)
[[1 0 0]
 [0 0 0]
 [0 0 0]]
>>>
>>> actions = engine.state.get_possible_actions()
>>> state = engine.step(actions[0])
>>> print(engine.state.board)
[[ 1 -1  0]
 [ 0  0  0]
 [ 0  0  0]]
>>>
>>> actions = engine.state.get_possible_actions()
>>> state = engine.step(actions[2])
>>>
>>> print(engine.state.board)
[[ 1 -1  0]
 [ 0  1  0]
 [ 0  0  0]]
>>>
>>> engine.step(Action(row=1, col=0))
>>> engine.state.is_over
False
>>>
>>> engine.step(Action(row=2, col=2))
>>> print(engine.state.board)
[[ 1 -1  0]
 [-1  1  0]
 [ 0  0  1]]
>>>
>>> engine.state.is_over
True
>>> engine.state.winner
1

Competition 2024-04-17

Balazs vs Jona. Balazs won 53 times, Jona won 47 times, draw 0 times.

Balazs vs David. Balazs won 46 times, David won 54 times, draw 0 times.

Jona vs Balazs. Jona won 53 times, Balazs won 47 times, draw 0 times.

Jona vs David. Jona won 43 times, David won 57 times, draw 0 times.

David vs Balazs. David won 45 times, Balazs won 55 times, draw 0 times.

David vs Jona. David won 53 times, Jona won 47 times, draw 0 times.

*** Final results ***

1. Balazs: 395

2. Jona: 394

3. David: 383

gomoku's People

Contributors

avandavad avatar nofreewill42 avatar

Stargazers

 avatar  avatar

Watchers

 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.