Skip to content

Commit

Permalink
Merge branch 'master' into ci-autoconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
mm304321141 committed Aug 12, 2024
2 parents 1052159 + 2f10822 commit fec7773
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
23 changes: 9 additions & 14 deletions .github/workflows/connect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ on:
required: false
type: number
default: 6
level:
description: "Level"
required: false
type: number
default: 8
bpm:
description: "BPM"
required: false
type: number
default: 200

jobs:
connect:
Expand All @@ -48,6 +38,12 @@ jobs:
with:
exclude_inputs: os, next_count, level, bpm
- uses: actions/checkout@v4
- name: Upgrade glibc
if: ${{ inputs.os == 'ubuntu' }}
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install --only-upgrade libstdc++6
- name: Build Project
uses: ./.github/actions/build_dotnet
with:
Expand All @@ -64,15 +60,14 @@ jobs:
import json
config = {
"NextCnt": ${{ inputs.next_count }},
"Level": ${{ inputs.level }},
"BPM": ${{ inputs.bpm }},
"Token": "${{ inputs.token }}",
"RoomKey": "${{ inputs.master_key }}"
"RoomKey": "${{ inputs.master_key }}",
"Quiet": True
}
json.dump(config, open("${{ env.OUTPUT_FOLDER }}/botconfig.json", "w"))
- name: Run bot
shell: bash
run: |
pushd ${{ env.OUTPUT_FOLDER }}
chmod +x ${{ env.PROJECT_NAME }}
./${{ env.PROJECT_NAME }} --quiet
./${{ env.PROJECT_NAME }}
6 changes: 5 additions & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ jobs:
with:
name: ${{ env.PROJECT_NAME }}_${{ matrix.os }}
path: ${{ env.OUTPUT_FOLDER }}/*
- name: Prepare for release
if: ${{ (startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v'))}}
run: |
7z a -tzip ${{ env.PROJECT_NAME }}_${{ matrix.os }}.zip ${{ env.OUTPUT_FOLDER }}/*
- name: Upload release
if: ${{ (startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v'))}}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: |
${{ env.OUTPUT_FOLDER }}/*
${{ env.PROJECT_NAME }}_${{ matrix.os }}.zip
prerelease: ${{ startsWith(github.ref, 'refs/tags/pre') }}
3 changes: 2 additions & 1 deletion BotrisBattle.NET/BotrisType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ public enum Block
// Enum for Command
public enum Command
{
hold, move_left, move_right, sonic_left, sonic_right,
hold, move_left, move_right, sonic_left, sonic_right, hard_drop,
rotate_cw, rotate_ccw, drop, sonic_drop
}


// Enum for ClearName
public enum ClearName
{
Expand Down
27 changes: 12 additions & 15 deletions ZZZTOJ.Botris/ZZZBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,17 @@ public MoveResult GetMove(RequestMovePayload requestMovePayload)

//}
int[] comboTable = new int[] { 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 4,4,4,4, -1 };

if (!BotSetting.Quiet) {
Console.WriteLine("T={0},X={1},Y={2},R={3}",requestMovePayload.GameState.current.piece[0],requestMovePayload.GameState.current.x, requestMovePayload.GameState.current.y, requestMovePayload.GameState.current.rotation);
}
var path = ZZZTOJCore.BotrisAI3(field1, 10, 22, requestMovePayload.GameState.b2b ? 1 : 0,
requestMovePayload.GameState.combo,
requestMovePayload.GameState.queue.Select(s => s[0]).ToArray(),

requestMovePayload.GameState.held == null ? ' ': requestMovePayload.GameState.held[0],
requestMovePayload.GameState.canHold, requestMovePayload.GameState.current.piece[0], 3, 1, 0, true, false, requestMovePayload.GameState.garbageQueued.Length, comboTable, BotSetting.NextCnt, BotSetting.Duration);
requestMovePayload.GameState.canHold, requestMovePayload.GameState.current.piece[0],
requestMovePayload.GameState.current.x, 20 - requestMovePayload.GameState.current.y, requestMovePayload.GameState.current.rotation,
true, false, requestMovePayload.GameState.garbageQueued.Length, comboTable, BotSetting.NextCnt, BotSetting.Duration);
string resultpath = Marshal.PtrToStringAnsi(path);
_IOBoard.NextQueue.Enqueue(TetrisMino.Z);
Console.WriteLine(resultpath.PadRight(50));
Expand All @@ -150,22 +155,16 @@ public MoveResult GetMove(RequestMovePayload requestMovePayload)
case 'z':
case 'Z':
_IOBoard.LeftRotation();

moveResult.moves.Add(Command.rotate_ccw);
break;
case 'c':
case 'C':
_IOBoard.RightRotation();

moveResult.moves.Add(Command.rotate_cw);

break;
case 'l':
_IOBoard.MoveLeft();

moveResult.moves.Add(Command.move_left);


break;
case 'L':
while (_IOBoard.MoveLeft()) ;
Expand All @@ -179,14 +178,14 @@ public MoveResult GetMove(RequestMovePayload requestMovePayload)
case 'R':
while (_IOBoard.MoveRight()) ;
moveResult.moves.Add(Command.sonic_right);

break;
case 'd':
_IOBoard.SoftDrop();
moveResult.moves.Add(Command.drop);
break;
case 'D':
_IOBoard.SonicDrop();

moveResult.moves.Add(Command.sonic_drop);

break;
case 'v':
//_IOBoard.OnHold();
Expand Down Expand Up @@ -229,19 +228,17 @@ public MoveResult GetMove(RequestMovePayload requestMovePayload)
// moveResult.expected_cells[i][0] = list[i].Y;
//}
_IOBoard.HardDrop();

moveResult.moves.Add(Command.drop);

//moveResult.moves.Add(Command.hard_drop);
break;
default:
break;
}
if (move == 'V') break;
}

_IOBoard.PrintBoard();

if (!BotSetting.Quiet) {
_IOBoard.PrintBoard();
Console.WriteLine($"combo: {requestMovePayload.GameState.combo,-3} b2b: {requestMovePayload.GameState.b2b} garbage: {requestMovePayload.GameState.garbageQueued.Length,-3}");
Console.WriteLine($"mino: {requestMovePayload.GameState.current.piece} pos: {requestMovePayload.GameState.current.x} {requestMovePayload.GameState.current.y}");
}
Expand Down

0 comments on commit fec7773

Please sign in to comment.