Skip to content

Commit dc3a66f

Browse files
committed
Merge branch 'master' into client-release
2 parents 8b6e959 + bfa8bdc commit dc3a66f

File tree

104 files changed

+5794
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+5794
-474
lines changed

.github/workflows/release-engine.yml

Lines changed: 73 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -92,82 +92,83 @@ jobs:
9292
9393
- name: Upload specs
9494
run: gsutil -m rsync -a $OBJECT_ACL -r ./specs gs://$GCS_BUCKET/specs/${RELEASE_ARTIFACT_ID}/$RELEASE_VERSION
95-
# release-python:
96-
# name: Release Python
97-
# runs-on: ubuntu-latest
98-
# permissions:
99-
# contents: read
100-
# id-token: write
101-
102-
# steps:
103-
# - uses: conda-incubator/setup-miniconda@v3
104-
# with:
105-
# python-version: 3.12
106-
107-
# - name: Checkout branch
108-
# uses: actions/checkout@v3
109-
110-
# - name: Inject release version
111-
# run: |
112-
# release_version=${GITHUB_REF#refs/*/}
113-
# release_version=${release_version#engine.}
114-
# echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
115-
# echo "The release version is $release_version"
116-
117-
# - name: Authenticate to Google Cloud Platform
118-
# uses: google-github-actions/auth@v1
119-
# with:
120-
# create_credentials_file: true
121-
# workload_identity_provider: projects/830784087321/locations/global/workloadIdentityPools/releases/providers/github-workflow
122-
# service_account: [email protected]
123-
124-
# - name: Set up Google Cloud SDK
125-
# uses: 'google-github-actions/setup-gcloud@v1'
126-
127-
# - name: Clone private maps
128-
# if: ${{ env.IS_PUBLIC != 'YES' }}
129-
# uses: actions/checkout@v3
130-
# with:
131-
# repository: battlecode/private-maps
132-
# token: ${{ secrets.CI_REPOSITORY_CLONE_PAT }}
133-
# path: private-maps
95+
release-python:
96+
name: Release Python
97+
runs-on: ubuntu-latest
98+
permissions:
99+
contents: read
100+
id-token: write
101+
102+
steps:
103+
- uses: conda-incubator/setup-miniconda@v3
104+
with:
105+
python-version: 3.12
106+
107+
- name: Checkout branch
108+
uses: actions/checkout@v3
109+
110+
- name: Inject release version
111+
run: |
112+
release_version=${GITHUB_REF#refs/*/}
113+
release_version=${release_version#engine.}
114+
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
115+
echo "The release version is $release_version"
116+
117+
- name: Authenticate to Google Cloud Platform
118+
uses: google-github-actions/auth@v1
119+
with:
120+
create_credentials_file: true
121+
workload_identity_provider: projects/830784087321/locations/global/workloadIdentityPools/releases/providers/github-workflow
122+
service_account: [email protected]
123+
124+
- name: Set up Google Cloud SDK
125+
uses: 'google-github-actions/setup-gcloud@v1'
126+
127+
- name: Clone private maps
128+
if: ${{ env.IS_PUBLIC != 'YES' }}
129+
uses: actions/checkout@v3
130+
with:
131+
repository: battlecode/private-maps
132+
token: ${{ secrets.CI_REPOSITORY_CLONE_PAT }}
133+
path: private-maps
134134

135-
# - name: Inject private maps
136-
# if: ${{ env.IS_PUBLIC != 'YES' }}
137-
# run: |
138-
# source="private-maps/$RELEASE_ARTIFACT_ID"
139-
# dest="$RELEASE_ARTIFACT_ID/maps"
140-
# if [ -d "$source" ]; then
141-
# cp -r -i "$source/." "$dest/" < /dev/null &> private-maps-copy-log
142-
# if [ -s "private-maps-copy-log" ]; then
143-
# echo "FAILED! Public and private maps should not intersect."
144-
# cat private-maps-copy-log
145-
# exit 1
146-
# fi
147-
# fi
135+
- name: Inject private maps
136+
if: ${{ env.IS_PUBLIC != 'YES' }}
137+
run: |
138+
source="private-maps/$RELEASE_ARTIFACT_ID"
139+
dest="engine/src/main/battlecode/world/resources"
140+
if [ -d "$source" ]; then
141+
cp -r -i "$source/." "$dest/" < /dev/null &> private-maps-copy-log
142+
if [ -s "private-maps-copy-log" ]; then
143+
echo "FAILED! Public and private maps should not intersect."
144+
cat private-maps-copy-log
145+
exit 1
146+
fi
147+
fi
148148
149-
# - name: Build python package
150-
# shell: bash -el {0} # Make sure conda is activated
151-
# run: |
152-
# conda info
153-
# python --version
154-
# pip install --upgrade build
155-
# SETUPTOOLS_SCM_PRETEND_VERSION=${RELEASE_VERSION} python -m build
156-
157-
# - name: Determine access control
158-
# run: |
159-
# [[ "$IS_PUBLIC" = "YES" ]] && acl="public-read" || acl="project-private"
160-
# echo "OBJECT_ACL=$acl" >> $GITHUB_ENV
161-
# echo "Objects will be uploaded with ACL $acl"
162-
163-
# - name: Upload python package to remote repository
164-
# run: |
165-
# mv *.tar.gz battlecode.tar.gz
166-
# gsutil -m cp -a $OBJECT_ACL battlecode.tar.gz gs://$GCS_BUCKET/maven/org/battlecode/${RELEASE_ARTIFACT_ID}-python/${RELEASE_VERSION}/
167-
# working-directory: ./dist
149+
- name: Build python package
150+
shell: bash -el {0} # Make sure conda is activated
151+
run: |
152+
conda info
153+
python --version
154+
pip install --upgrade build
155+
SETUPTOOLS_SCM_PRETEND_VERSION=${RELEASE_VERSION} python -m build
156+
working-directory: engine/src/crossplay_python
157+
158+
- name: Determine access control
159+
run: |
160+
[[ "$IS_PUBLIC" = "YES" ]] && acl="public-read" || acl="project-private"
161+
echo "OBJECT_ACL=$acl" >> $GITHUB_ENV
162+
echo "Objects will be uploaded with ACL $acl"
163+
164+
- name: Upload python package to remote repository
165+
run: |
166+
mv *.tar.gz battlecode.tar.gz
167+
gsutil -m cp -a $OBJECT_ACL battlecode.tar.gz gs://$GCS_BUCKET/maven/org/battlecode/${RELEASE_ARTIFACT_ID}-python/${RELEASE_VERSION}/
168+
working-directory: engine/src/crossplay_python/dist
168169

169170
# TODO: docs?
170-
#- name: Upload javadocs
171+
# - name: Upload javadocs
171172
# run: |
172173
# unzip -d ${{ runner.temp }}/javadoc $HOME/.m2/repository/org/battlecode/$RELEASE_ARTIFACT_ID/$RELEASE_VERSION/*-javadoc.jar
173174
# gsutil -m rsync -a $OBJECT_ACL -r ${{ runner.temp }}/javadoc gs://$GCS_BUCKET/javadoc/$RELEASE_ARTIFACT_ID/$RELEASE_VERSION

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Note, Competitors
66
This is the development repo! You most likely won't need anything in here; do not clone this.
7-
Instead, follow the instructions [here](https://play.battlecode.org/bc26java/quick_start) to get started.
7+
Instead, follow the instructions [here](https://play.battlecode.org/bc26/quick_start) to get started.
88

99
## Repository Structure
1010

build.gradle

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ dependencies {
4040
bots project(":example-bots")
4141
}
4242

43+
task installPythonPackage(type: Exec) {
44+
if (project.findProperty('forceInstallPythonPackage') ?: false) {
45+
commandLine 'python', '-m', 'pip', 'install', '-e', 'engine/src/crossplay_python'
46+
} else {
47+
commandLine 'python', '-c', "import importlib.util,subprocess,sys; pkg='battlecode26'; importlib.util.find_spec(pkg) or subprocess.check_call([sys.executable,'-m','pip','install','-e',pkg])"
48+
}
49+
}
50+
4351
def serverJar = configurations.engine.singleFile
4452

4553
task buildMap(type: JavaExec, dependsOn: [':engine:build']) {
@@ -78,6 +86,8 @@ task headless(type: JavaExec, dependsOn: [':engine:build', ':example-bots:build'
7886
'-Dbc.engine.show-indicators=' + (project.findProperty('showIndicators') ?: 'true'),
7987
'-Dbc.game.team-a=' + project.property('teamA'),
8088
'-Dbc.game.team-b=' + project.property('teamB'),
89+
'-Dbc.game.team-a.language=' + (project.findProperty('languageA') ?: 'java'),
90+
'-Dbc.game.team-b.language=' + (project.findProperty('languageB') ?: 'java'),
8191
'-Dbc.game.team-a.url=' + (project.findProperty('classLocationA') ?: defaultClassLocation),
8292
'-Dbc.game.team-b.url=' + (project.findProperty('classLocationB') ?: defaultClassLocation),
8393
'-Dbc.game.team-a.package=' + (project.findProperty('packageNameA') ?: project.property('teamA')),
@@ -89,10 +99,25 @@ task headless(type: JavaExec, dependsOn: [':engine:build', ':example-bots:build'
8999
]
90100
}
91101

102+
task crossPlayPy(type: Exec, dependsOn: ['installPythonPackage']) {
103+
commandLine 'python', '-m', 'battlecode26',
104+
'--teamA', (project.findProperty('languageA') == 'java' ? '/' : project.property('teamA')),
105+
'--teamB', (project.findProperty('languageB') == 'java' ? '/' : project.property('teamB')),
106+
'--dirA', 'example-bots/src/crossplay_python',
107+
'--dirB', 'example-bots/src/crossplay_python',
108+
'--new-process'
109+
}
110+
92111
// keep the client happy because it references this step
93112
task unpackClient() {}
94113

95-
task run(dependsOn: ['headless', 'unpackClient']) {}
114+
task run(dependsOn: ['unpackClient', 'headless']) {}
115+
116+
if (project.hasProperty('languageA') && project.property('languageA') == 'python' ||
117+
project.hasProperty('languageB') && project.property('languageB') == 'python') {
118+
run.dependsOn crossPlayPy
119+
headless.mustRunAfter crossPlayPy
120+
}
96121

97122
task runClient {
98123
doLast {

client/src/colors.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,35 @@ export const Presets: ColorPreset[] = [
154154
TEAM_TWO: '#c91c7e'
155155
}
156156
}
157+
},
158+
{
159+
displayName: 'Battlecode 2025',
160+
data: {
161+
version: 0,
162+
colors: {
163+
GAMEAREA_BACKGROUND: '#2e2323',
164+
SIDEBAR_BACKGROUND: '#3f3131',
165+
RED: '#ff9194',
166+
PINK: '#ffb4c1',
167+
GREEN: '#00a28e',
168+
CYAN: '#02a7b9',
169+
CYAN_DARK: '#1899a7',
170+
BLUE: '#04a2d9',
171+
BLUE_LIGHT: '#26abd9',
172+
BLUE_DARK: '#00679e',
173+
DARK: '#1f2937',
174+
DARK_HIGHLIGHT: '#140f0f',
175+
BLACK: '#140f0f',
176+
WHITE: '#fcdede',
177+
LIGHT: '#aaaaaa22',
178+
LIGHT_HIGHLIGHT: '#ffffff33',
179+
LIGHT_CARD: '#f7f7f722',
180+
WALLS_COLOR: '#547f31',
181+
TILES_COLOR: '#4c301e',
182+
TEAM_ONE: '#cdcdcc',
183+
TEAM_TWO: '#fee493'
184+
}
185+
}
157186
}
158187
]
159188

client/src/components/sidebar/game/game.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,16 @@ export const GamePage: React.FC<Props> = React.memo((props) => {
143143
<div /*className="flex items-center gap-2"*/>
144144
{/* Note: to keep animation smooth, we should still keep the elements rendered, but we pass showStats into
145145
them so that they don't render any data (since we're likely hiding stats to prevent lag) */}
146+
<ResourceGraph
147+
active={showStats}
148+
property="globalCheeseAmount"
149+
propertyDisplayName="Global Cheese "
150+
/>
151+
<br />
146152
<ResourceGraph
147153
active={showStats}
148154
property="cheeseAmount"
149-
propertyDisplayName="Cheese Amount "
155+
propertyDisplayName="Cheese Transferred "
150156
/>
151157
<br />
152158
<ResourceGraph

client/src/components/sidebar/game/team-table.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export const ResourceTable: React.FC<ResourceTableProps> = ({ map, teamStat, tea
6262
let catDamagePercent = 0
6363
let ratKingCount = 0
6464
let ratKingPercent = 0
65+
let globalCheese = 0
6566

6667
if (map && teamStat) {
6768
cheeseAmount = teamStat.cheeseAmount
@@ -70,6 +71,7 @@ export const ResourceTable: React.FC<ResourceTableProps> = ({ map, teamStat, tea
7071
catDamagePercent = teamStat.catDamagePercent
7172
ratKingCount = teamStat.ratKingCount
7273
ratKingPercent = teamStat.ratKingPercent
74+
globalCheese = teamStat.globalCheeseAmount
7375
}
7476

7577
const formatPercent = (val: number) => (val * 100).toFixed(1).toString() + '%'
@@ -131,6 +133,7 @@ export const ResourceTable: React.FC<ResourceTableProps> = ({ map, teamStat, tea
131133
</div>
132134
</div>
133135
</div>
136+
<div className="flex items-center w-full mt-2 mb-1 text-xs font-bold justify-around">Global Cheese Amount: {globalCheese}</div>
134137
</div>
135138
)
136139
}
@@ -148,9 +151,9 @@ export const UnitsTable: React.FC<UnitsTableProps> = ({ teamStat, teamIdx }) =>
148151
['Baby Rats', <UnitsIcon teamIdx={teamIdx} img="rat" key="3" />]
149152
]
150153

151-
let data: [string, number[]][] = [['Count', [0, 0, 0, 0]]]
154+
let data: [string, number[]][] = [['Count:', [0, 0, 0, 0]]]
152155
if (teamStat) {
153-
data = [['Count', [teamStat.dirtAmount, teamStat.ratTrapAmount, teamStat.catTrapAmount, teamStat.babyRatCount]]]
156+
data = [['Count:', [teamStat.dirtAmount, teamStat.ratTrapAmount, teamStat.catTrapAmount, teamStat.babyRatCount]]]
154157
}
155158

156159
return (

client/src/components/sidebar/map-editor/map-editor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ export const MapEditorPage: React.FC<Props> = (props) => {
187187
}
188188

189189
useEffect(() => {
190+
if (!canvasMouseDown || !hoveredTile) return;
190191
if (canvasMouseDown && hoveredTile) applyBrush(hoveredTile)
191192
// added defensive checks just in case stuff is null for some reason
192193
if (canvasMouseDown && hoveredTile && typeof hoveredTile.x === 'number' && typeof hoveredTile.y === 'number') {

client/src/playback/Map.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,11 @@ export class CurrentMap {
317317
}
318318
if (ratTrap) {
319319
info.push('Rat Trap')
320+
info.push(`Placed by ${TEAM_COLOR_NAMES[ratTrap - 2]}`)
320321
}
321322
if (catTrap) {
322323
info.push('Cat Trap')
324+
info.push(`Placed by ${TEAM_COLOR_NAMES[catTrap - 2]}`)
323325
}
324326
if (cheese) {
325327
info.push(`Cheese: ${cheese}`)

client/src/playback/RoundStat.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export class TeamRoundStat {
1919
ratKingCount: number = 0
2020
ratKingPercent: number = 0
2121
dirtAmount: number = 0
22+
globalCheeseAmount: number = 0
2223
babyRatCount: number = 0
2324
ratTrapAmount: number = 0
2425
catTrapAmount: number = 0
@@ -75,10 +76,13 @@ export default class RoundStat {
7576
let totalCheese = 0
7677
let totalCatDamage = 0
7778
let totalRatKings = 0
79+
80+
7881
for (let i = 0; i < delta.teamIdsLength(); i++) {
82+
const combinedStat = delta.teamAliveRatKings(i)!
7983
totalCheese += delta.teamCheeseTransferred(i)!
8084
totalCatDamage += delta.teamCatDamage(i)!
81-
totalRatKings += delta.teamAliveRatKings(i)!
85+
totalRatKings += (combinedStat%10) //lmao
8286
}
8387

8488
for (let i = 0; i < delta.teamIdsLength(); i++) {
@@ -87,10 +91,14 @@ export default class RoundStat {
8791
const teamStat = this.teams.get(team) ?? assert.fail(`team ${i} not found in team stats in round`)
8892

8993
teamStat.cheeseAmount = delta.teamCheeseTransferred(i) ?? assert.fail('missing cheese amount')
94+
teamStat.globalCheeseAmount = Math.floor(delta.teamAliveRatKings(i)! / 10)
9095
teamStat.cheesePercent = totalCheese ? teamStat.cheeseAmount / totalCheese : 0
9196
teamStat.catDamageAmount = delta.teamCatDamage(i) ?? assert.fail('missing cat damage amount')
9297
teamStat.catDamagePercent = totalCatDamage ? teamStat.catDamageAmount / totalCatDamage : 0
98+
9399
teamStat.ratKingCount = delta.teamAliveRatKings(i) ?? assert.fail('missing rat king count')
100+
teamStat.ratKingCount %= 10
101+
94102
teamStat.ratKingPercent = totalRatKings ? teamStat.ratKingCount / totalRatKings : 0
95103
teamStat.dirtAmount = delta.teamDirtAmounts(i) ?? assert.fail('missing dirt amount')
96104
teamStat.ratTrapAmount = delta.teamRatTrapCount(i) ?? assert.fail('missing rat trap amount')

engine/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ dependencies {
5858
// There are no valid released versions on Maven Central or Sonatype.
5959
// If you need JSI, download jsi-1.0.jar manually and use:
6060
[group: 'net.sf.trove4j', name: 'trove4j', version: '2.1.0'],
61+
62+
[group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.15.2'],
6163
)
6264
// implementation files('lib/jsi-1.0.jar')
6365

0 commit comments

Comments
 (0)