| Bytes | Lang | Time | Link |
|---|---|---|---|
| 211 | C#6 | 161125T130627Z | Link Ng |
| 128 | Python 2 | 161120T163431Z | Sp3000 |
| 079 | 05AB1E | 161120T161303Z | Emigna |
C#6, 211 bytes
using static System.Math;(h,f,x,y)=>{int b=h>5?24/(50/h)*100:Min(f%2<1?(int)Ceiling(f*.1)<<h+2:10<<h,200),c=-(int)Ceiling(b*.1*(y?2:x?6:4))*100,d=-(int)Ceiling(b*.1*(y?x?2:1:0))*100;return new[]{-c-d*2,c,d,d};};
Contains an idea shamelessly stolen from @Sp3000.
Assign to Func<int,int,bool,bool,int[]>
h=han
f=fu
x=true if dealer wins, false if non-dealer wins
y=true if self draw, false if discard
returns int[], [0]=winner, [1]-[3]:loser
repl.it demo
Ungolfed + explanations
// b is base score / 10
int b=h>5
// han is [6,13], use Sp3000's idea
?24/(50/h)*100
// han <= 5, calculate base score (/ 10) from formula...
// Yes this formula works for han==5 also
:Min(
f%2<1
// round up to 10, then times 2^(h+2)
?(int)Ceiling(f*.1)<<h+2
// b=2.5*2^(h+2)=10*2^h=10<<h
:10<<h
// Cap at 200, thus base score is capped at 2000
,200),
// Multiply 0.1b by 2/4/6 according to input, then multiply by 100 to get actual score
c=-(int)Ceiling(b*.1*(y?2:x?6:4))*100,
d=-(int)Ceiling(b*.1*(y?x?2:1:0))*100;
// Array type implied from arguments
return new[]{-c-d*2,c,d,d};
Python 2, 128 bytes
def m(h,f,o,t):C=100;b=[24/(50/h)*1000,min(2000,[-f/10*~9,f][f%2]<<h+2)][h<5];x=(o|2-t)*-2*b/C*C;y=~o*t*b/C*C;return-x-y-y,x,y,y
h is han, f is fu, o is dealer (1/0), t is self-draw (1/0). Outputs in the same order as the test cases. ideone link.
Expanded slightly:
def m(h,f,o,t):
C = 100
# Base score
b = [24/(50/h)*1000, min(2000,[-f/10*~9,f][f%2]<<h+2)][h<5]
# Player scores - uses the -x/100*-100 approach to round up
x = (o|2-t)*-2*b/C*C
y = ~o*t*b/C*C
return -x-y-y, x, y, y
Indirect thanks to @MartinEnder.
05AB1E, 79 bytes
05AB1E uses CP-1252 encoding.
Input order:
Han
Fu
Dealer = 1, Non-dealer = 0
Self = 2, Discard = 0
Code:
3‹i6b‚ï{0è}¹5‹iÐT/îT*‚sÈè¹Ìo*3°·‚{0èë\•j¤È°•¹è3°*}U•é2TˆÞ•S3ôŠ+èX*Tn/îTn*(DOĸì
Explanation to come.