Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

66%
+2 −0
Challenges Three Number Monte

The "Uppers" def oneup(data, history): if len(history) > 0: prev = history[-1] if prev[2] > 1: better = [prev[0] + 1, prev[1] + 1, prev[2] - 2] elif prev[1] > 1: better...

posted 2y ago by Quintec‭

Answer
#1: Initial revision by user avatar Quintec‭ · 2021-07-30T01:44:29Z (over 2 years ago)
# The "Uppers"

```py
def oneup(data, history):
	if len(history) > 0:
		prev = history[-1]
		if prev[2] > 1:
			better = [prev[0] + 1, prev[1] + 1, prev[2] - 2]
		elif prev[1] > 1:
			better = [prev[0] + 1, prev[1] - 2, prev[2] + 1]
		else:
			better = [prev[0] - 2, prev[1] + 1, prev[2] + 1]
		random.shuffle(better)
		return better
	return [[180, 180, 0], [180, 0, 180], [0, 180, 180]][random.randint(0, 2)]

def avgup(data, history):
	if 't1' not in data:
		data['t1'] = 0
		data['t2'] = 0
		data['t3'] = 0
	if len(history) > 0:
		prev = history[-1]
		prev.sort()
		data['t1'] += prev[0]
		data['t2'] += prev[1]
		data['t3'] += prev[2]
		a1 = data['t1'] / len(history)
		a2 = data['t2'] / len(history)
		a3 = data['t3'] / len(history)
		if math.ceil(a1) + math.ceil(a2) <= 360:
			better = [math.ceil(a1), math.ceil(a2), 360 - math.ceil(a1) - math.ceil(a2)]
		else:
			better = [math.ceil(a1), 360 - math.ceil(a1), 0]
		random.shuffle(better)
		return better
	return [[180, 180, 0], [180, 0, 180], [0, 180, 180]][random.randint(0, 2)]
```

Two bots based off a single concept that seem to perform reasonably well. One takes the last submission the opponent made, and "one-ups" it - increments 2 values by 1 and decrements 1 value by 2. The other does the same thing, except with the average of all previous submissions by the opponent.