UnorganizedCompany / HyperGame

0 stars 3 forks source link

01. 유사회사 Yachu #2

Open ytbeom opened 2 years ago

ytbeom commented 2 years ago

개요

구성

게임 화면

TO DO

jbeomchoi commented 2 years ago

테스트용 알고리즘

사용법

예시 커맨드

java -cp /Users/user/env/scala/lib/scala-library.jar:/Users/user/private/pseudo_company/yacht-decision/yacht-decision-runner/target/scala-2.12/yacht-decision-runner-assembly.jar com.unorganized.example.Runner webserver --port 9910

  - 포트는 필수 arg 는 아니고 default 는 9902 로 설정되어 있음.

- 웹서버 요청 방법
```sh
curl -X POST -H "Content-Type: application/json" -d @{json file path} {host:port}/decide

## 예시 커맨드
curl -X POST -H "Content-Type: application/json" -d @./json/example.json http://localhost:9910/decide
image

예시 커맨드

java -cp /Users/user/env/scala/lib/scala-library.jar:/Users/user/private/pseudo_company/yacht-decision/yacht-decision-runner/target/scala-2.12/yacht-decision-runner-assembly.jar com.unorganized.example.Runner file --file-path ./json/example.json

  - `file-path` 옵션은 필수로 들어가야 하고 안 넣어주면 실행되지 않음.
  - 현재는 그냥 표준출력으로 해두었는데 필요시에는 파일로 쓰기도 가능. 이건 엔진 쪽에서 해달라는 대로 해줌

- 파일 실행 결과 예시
```sh
List((yacht,50), (fives,25))
yacht
jaemoon-sim commented 2 years ago

409 conflict

@jbeomchoi

{
 "turn": 1,
 "player": "0",
 "trial": 1,
 "dices": [
  4,
  5,
  5,
  6,
  6
 ],
 "scoreBoard": {
  "0": {
   "ones": null,
   "twos": null,
   "threes": null,
   "fours": null,
   "fives": null,
   "sixs": null,
   "choice": null,
   "four_of_a_kind": null,
   "full_house": null,
   "small_straight": null,
   "large_straight": null,
   "yacht": null
  },
  "1": {
   "ones": null,
   "twos": null,
   "threes": null,
   "fours": null,
   "fives": null,
   "sixs": null,
   "choice": null,
   "four_of_a_kind": null,
   "full_house": null,
   "small_straight": null,
   "large_straight": null,
   "yacht": null
  }
 }
}

에러 로그

[armeria-common-worker-nio-2-2] WARN com.unorganized.example.RestExceptionHandler - Exception occur.
org.json4s.MappingException: Did not find value which can be converted into java.lang.String
    at org.json4s.reflect.package$.fail(package.scala:56)
    at org.json4s.Extraction$.$anonfun$convert$2(Extraction.scala:882)
    at scala.Option.getOrElse(Option.scala:189)
    at org.json4s.Extraction$.convert(Extraction.scala:882)
    at org.json4s.Extraction$.$anonfun$extract$10(Extraction.scala:457)
    at org.json4s.Extraction$.$anonfun$customOrElse$1(Extraction.scala:781)
    at scala.PartialFunction.applyOrElse(PartialFunction.scala:127)
    at scala.PartialFunction.applyOrElse$(PartialFunction.scala:126)
    at scala.PartialFunction$$anon$1.applyOrElse(PartialFunction.scala:257)
    at org.json4s.Extraction$.customOrElse(Extraction.scala:781)
    at org.json4s.Extraction$.extract(Extraction.scala:455)
    at org.json4s.Extraction$.extract(Extraction.scala:56)
    at org.json4s.ExtractableJsonAstNode$.extract$extension(ExtractableJsonAstNode.scala:22)
    at com.unorganized.example.Decider$.decide(Decider.scala:34)
    at com.unorganized.example.DecisionService.parseModooCuveDocument(DecisionService.scala:25)
    at com.linecorp.armeria.internal.server.annotation.AnnotatedService.invoke(AnnotatedService.java:394)
    at com.linecorp.armeria.internal.server.annotation.AnnotatedService.lambda$serve0$8(AnnotatedService.java:362)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
    at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
    at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147)
    at com.linecorp.armeria.common.util.UnmodifiableFuture.doComplete(UnmodifiableFuture.java:124)
    at com.linecorp.armeria.common.util.UnmodifiableFuture.lambda$wrap$0(UnmodifiableFuture.java:100)
    at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
    at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)
    at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
    at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147)
    at com.linecorp.armeria.common.stream.StreamMessageCollector.onComplete(StreamMessageCollector.java:67)
    at com.linecorp.armeria.common.stream.AbstractStreamMessage$CloseEvent.notifySubscriber(AbstractStreamMessage.java:257)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.notifySubscriberOfCloseEvent0(DefaultStreamMessage.java:291)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.notifySubscriberOfCloseEvent(DefaultStreamMessage.java:283)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.handleCloseEvent(DefaultStreamMessage.java:420)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.notifySubscriber0(DefaultStreamMessage.java:363)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.notifySubscriber(DefaultStreamMessage.java:319)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.addObjectOrEvent(DefaultStreamMessage.java:305)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.close(DefaultStreamMessage.java:427)
    at com.linecorp.armeria.server.Http1RequestDecoder.channelRead(Http1RequestDecoder.java:276)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at com.linecorp.armeria.server.HttpServerUpgradeHandler.channelRead(HttpServerUpgradeHandler.java:216)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.codec.ByteToMessageDecoder.handlerRemoved(ByteToMessageDecoder.java:255)
    at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:517)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:449)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:280)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.flush.FlushConsolidationHandler.channelRead(FlushConsolidationHandler.java:152)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:833)
[armeria-common-worker-nio-2-2] INFO com.linecorp.armeria.logging.access - 0:0:0:0:0:0:0:1 - - 13/Feb/2022:18:28:49 +0900 "POST /decide#DecisionService/parseModooCuveDocument h1c" 409 12
[armeria-common-worker-nio-2-4] WARN com.unorganized.example.RestExceptionHandler - Exception occur.
org.json4s.MappingException: Did not find value which can be converted into java.lang.String
    at org.json4s.reflect.package$.fail(package.scala:56)
    at org.json4s.Extraction$.$anonfun$convert$2(Extraction.scala:882)
    at scala.Option.getOrElse(Option.scala:189)
    at org.json4s.Extraction$.convert(Extraction.scala:882)
    at org.json4s.Extraction$.$anonfun$extract$10(Extraction.scala:457)
    at org.json4s.Extraction$.$anonfun$customOrElse$1(Extraction.scala:781)
    at scala.PartialFunction.applyOrElse(PartialFunction.scala:127)
    at scala.PartialFunction.applyOrElse$(PartialFunction.scala:126)
    at scala.PartialFunction$$anon$1.applyOrElse(PartialFunction.scala:257)
    at org.json4s.Extraction$.customOrElse(Extraction.scala:781)
    at org.json4s.Extraction$.extract(Extraction.scala:455)
    at org.json4s.Extraction$.extract(Extraction.scala:56)
    at org.json4s.ExtractableJsonAstNode$.extract$extension(ExtractableJsonAstNode.scala:22)
    at com.unorganized.example.Decider$.decide(Decider.scala:34)
    at com.unorganized.example.DecisionService.parseModooCuveDocument(DecisionService.scala:25)
    at com.linecorp.armeria.internal.server.annotation.AnnotatedService.invoke(AnnotatedService.java:394)
    at com.linecorp.armeria.internal.server.annotation.AnnotatedService.lambda$serve0$8(AnnotatedService.java:362)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
    at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
    at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147)
    at com.linecorp.armeria.common.util.UnmodifiableFuture.doComplete(UnmodifiableFuture.java:124)
    at com.linecorp.armeria.common.util.UnmodifiableFuture.lambda$wrap$0(UnmodifiableFuture.java:100)
    at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
    at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)
    at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
    at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147)
    at com.linecorp.armeria.common.stream.StreamMessageCollector.onComplete(StreamMessageCollector.java:67)
    at com.linecorp.armeria.common.stream.AbstractStreamMessage$CloseEvent.notifySubscriber(AbstractStreamMessage.java:257)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.notifySubscriberOfCloseEvent0(DefaultStreamMessage.java:291)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.notifySubscriberOfCloseEvent(DefaultStreamMessage.java:283)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.handleCloseEvent(DefaultStreamMessage.java:420)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.notifySubscriber0(DefaultStreamMessage.java:363)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.notifySubscriber(DefaultStreamMessage.java:319)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.addObjectOrEvent(DefaultStreamMessage.java:305)
    at com.linecorp.armeria.common.stream.DefaultStreamMessage.close(DefaultStreamMessage.java:427)
    at com.linecorp.armeria.server.Http1RequestDecoder.channelRead(Http1RequestDecoder.java:276)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at com.linecorp.armeria.server.HttpServerUpgradeHandler.channelRead(HttpServerUpgradeHandler.java:216)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.codec.ByteToMessageDecoder.handlerRemoved(ByteToMessageDecoder.java:255)
    at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:517)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:449)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:280)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.flush.FlushConsolidationHandler.channelRead(FlushConsolidationHandler.java:152)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:833)
jaemoon-sim commented 2 years ago

yachtengine v0 배포

ytbeom commented 2 years ago

@jaemoon-sim 님, readme 보고 코멘트가 있습니다.

  1. decision을 한 경우에는 keep이 0, 1, 2, 3, 4로 고정되어 들어오는 식으로 되어있는게 맞을까요?
  2. log에 player를 추가해주실 수 있을까요? string list 형태로 추가해주시면 참 좋을 것으로 사료됩니다.
  3. final은 제가 미처 생각하지 못했는데 꼼꼼히 챙겨주셔서 감사합니다.
jaemoon-sim commented 2 years ago

@ytbeom

  1. decision을 한 경우에는 keep이 0, 1, 2, 3, 4로 고정되어 들어오는 식으로 되어있는게 맞을까요?

사실 구현상으로는, choice가 비어있지 않으면 decision을 했다고 처리하고 있습니다. keep대신에 choice 필드를 봐주세요

  1. log에 player를 추가해주실 수 있을까요? string list 형태로 추가해주시면 참 좋을 것으로 사료됩니다.

  1. final은 제가 미처 생각하지 못했는데 꼼꼼히 챙겨주셔서 감사합니다.

🔥

jaemoon-sim commented 2 years ago

@ytbeom 수정하여 push도 해뒀고, MyBox에 yachtengine_0218_00.zip 으로 배포해두었습니다 👍

ytbeom commented 2 years ago

YachtKorge

jbeomchoi commented 2 years ago

Yacht 룰

image

기본적으로 점수 계산은 상단 이미지를 따름 (ref: https://namu.wiki/w/%EC%9A%94%ED%8A%B8(%EA%B2%8C%EC%9E%84)?from=%EC%95%BC%EC%B6%94#s-2.2)

image

보너스는 63 이상일 때 +35점

jaemoon-sim commented 2 years ago

yachtengine_0306_00.zip 업데이트 되었읍니다 1) keep dice 버그 수정 2) trial = 3일 때 choice 없으면 실패하도록 처리 3) 플레이어 실수로 게임이 멈추면, 반칙패 하도록 추가

https://github.com/jaemoon-sim/HyperGame/blob/main/YachtEngine/README.md

ytbeom commented 2 years ago

@jaemoon-sim 님, 버그로 보이는 현상이 있어 제보드립니다.

{
"state": {
    "turn": 2,
    "player": "tb",
    "trial": 3,
    "dices": [
     4,
     3,
     6,
     4,
     5
    ],
    "scoreBoard": {
     "hk": {
      "aces": null,
      "deuces": 6,
      "threes": null,
      "fours": null,
      "fives": null,
      "sixes": null,
      "subtotal": 6,
      "choice": null,
      "fourKind": null,
      "fullHouse": null,
      "smallStraight": null,
      "largeStraight": null,
      "yacht": null,
      "total": 6
     },
     "tb": {
      "aces": null,
      "deuces": null,
      "threes": null,
      "fours": null,
      "fives": null,
      "sixes": null,
      "subtotal": 0,
      "choice": null,
      "fourKind": null,
      "fullHouse": 23,
      "smallStraight": null,
      "largeStraight": null,
      "yacht": null,
      "total": 23
     }
    }
   },
   "decision": {
    "keep": [],
    "choice": "smallStraight"
   }
}

이렇게 넣었는데 smallStraight에 0점이 들어갔어요ㅠㅠ

jbeomchoi commented 2 years ago

그냥 여기서 보는 게 편하실 거 같아서... 올립니다

파일 위치 : 공유폴더 > 유사회사 > 야추 파일 공유용 > 알고리즘_정범

다운받아야 하는 파일 : scala-library.jar, yacht-decision-runner-assembly-v1.jar

실행 커맨드 ( 꼭 cmd 창에서 실행 )

java -cp scala-library.jar;yacht-decision-runner-assembly-v1.jar com.unorganized.example.Runner webserver --port {포트번호}