Giter Club home page Giter Club logo

m5n's Introduction

M5N

A simple swap2-based gomoku server/broker, written in C#, compatible with CPython 3.11

Requirement

Compiling

  • .NET SDK 8.0 or above
  • GCC (MinGW on Windows)
  • CPython 3.11

Runtime

  • CPython 3.11 (Only with python backend.)

Ruleset

Each player can do:

  • dye : Choose colour
  • put : Put stone

Let player A, B.

  1. A put 3-times.
  2. B choose:
    1. B dye.
    2. B put 2-times. A dye.
  3. Continue with gomoku-ruleset.

Disclaimer

  • Virtual-environment or such things are not supported.
  • set_colour, set_stone, choose_colour, place_stone, make_decision, victory, defeat is reserved function/handler.
    • Do not rename these functions.
    • Do not change function signature. Or may cause the client to crash.
  • Only tested on pure python (without any packages)

How to write client

See working sample code with python. You can prove application manually with sample-code!

...or you can use C/C++ with same constants: See sample code with C++.

How to run client

Let your (python) source codes are in ./app folder.

Then, you can run client by:

M5N.Slave <endpoint> Python ./app <module>

M5N also supports native-backend built into dll/so. To use native-backend, Use below command:

M5N.Slave <endpoint> C path/to/your/binary.dll

These syntax is mnemonic with a below rule:

M5N.Slave <endpoint> <engine> [<engine-option>+] <module>

How to run server

M5N.Master <port>

Server will be listening on specified port number.

m5n's People

Contributors

sharp0802 avatar

Stargazers

EXON avatar

Watchers

 avatar

m5n's Issues

오류 질문

Server Log

C:\Users\hello>M5N.Master 7890
Game established.
trce: M5N.Master.Master[0]
      Master.Run has called
trce: M5N.Master.Master[0]
      Master.SwapColour has called
trce: M5N.Master.Master[0]
      Master.AcceptCoordinateFrom has called
trce: M5N.Master.Master[0]
      Master.AcceptDTOFrom has called
trce: M5N.Master.Master[0]
      Master.SwapColour has called
trce: M5N.Master.Master[0]
      Master.AcceptCoordinateFrom has called
trce: M5N.Master.Master[0]
      Master.AcceptDTOFrom has called
Unhandled exception. System.ArgumentOutOfRangeException: The value needs to translate in milliseconds to -1 (signifying an infinite timeout), 0, or a positive integer less than or equal to the maximum allowed timer duration. (Parameter 'timeout')
   at M5N.Channel.Receive(Memory`1 buffer, TimeSpan& timeout) in D:\develop\M5N\src\M5N\Channel.cs:line 41
   at M5N.Channel.ReceiveCode(TimeSpan& timeout, ControlCode& ctrl, UInt16& code) in D:\develop\M5N\src\M5N\Channel.cs:line 76
   at M5N.Channel.Request[T](TimeSpan timeout) in D:\develop\M5N\src\M5N\Channel.cs:line 94
   at M5N.Master.Master.AcceptDTOFrom[T](Byte id) in D:\develop\M5N\src\M5N.Master\Master.cs:line 47
   at M5N.Master.Master.AcceptCoordinateFrom(Byte id, CoordinateDTO& coord) in D:\develop\M5N\src\M5N.Master\Master.cs:line 63
   at M5N.Master.Master.Run() in D:\develop\M5N\src\M5N.Master\Master.cs:line 188
   at Program.<Main>$(String[] args) in D:\develop\M5N\src\M5N.Master\Program.cs:line 30

Client(임의로 작성한 테스트용 코드)

def place_stone():
    print("place_stone")

    global my_map
    seq = sequence_check()
    if seq == 0:
        x, y = 7, 7
    else:
        temp_map = copy.deepcopy(my_map)

        x, y = computer(N, temp_map, my_colour)
        if my_map[x][y] != 0:
            x, y = random.randint(0, 14), random.randint(0, 14)

    print("put: ", x, y)

    return x, y

Client 로그

checking computer...
movePoints:  6 7
computer move:  6 7
put:  6 7
Unhandled exception. Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'M5N.Interop.Python.PythonInteropModule' does not contain a definition for 'PlaceStone'
   at CallSite.Target(Closure, CallSite, Object)
   at M5N.Slave.Slave.InquiryStone() in D:\develop\M5N\src\M5N.Slave\Slave.cs:line 43
   at M5N.Slave.Shared.SlaveChannel.Frame() in D:\develop\M5N\src\M5N.Slave.Shared\SlaveChannel.cs:line 37
   at M5N.Slave.Shared.SlaveChannel.Run() in D:\develop\M5N\src\M5N.Slave.Shared\SlaveChannel.cs:line 103
   at Program.<Main>$(String[] args) in D:\develop\M5N\src\M5N.Slave\Program.cs:line 43

그냥 랜덤값 출력하게끔 하면 문제 없이 잘 돌아가지만 AI를 넣고 돌리면

Unhandled exception. Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'M5N.Interop.Python.PythonInteropModule'` does not contain a definition for 'PlaceStone'

이 오류가 뜹니다

compute 알고리즘이 문제가 있다면 x,y 값이 비정상적이어야 한다고 생각이 드는데
print("put: ", x, y)에 x,y값이 제대로 들어갔는데 안 되는 이유가 뭘까요?
자꾸PythonInteropModule에 PlaceStone이 포함되어 있지 않다는 오류가 뜨네요.. 뭔가 고려할 점이 있을까요?

기타사항

  • checking computer...
    movePoints: 6 7 부분은 AI 내에서 체크용으로 박아둔 print 부분이고
    최종적으로 compute 함수가 잘 돌아가는 지 체크하기 위해 다음과 같이 put 프린트를 사용함.
  • 참고로 중복된 값을 compute가 반환하지는 않았음
  • 하드코딩으로 박아 둔 7 7은 작동하지만, compute 함수에서 주변 노드를 탐색한 후 6, 7 stone을 반환하면 오류가 발생함, 다만 원인을 모르겠음

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.